Verified Commit b950268b authored by Martin Abbrent's avatar Martin Abbrent 💬
Browse files

Further improving handling output of mc.

parent 1a2b8b78
Pipeline #51035 failed with stages
in 2 minutes and 28 seconds
......@@ -16,7 +16,7 @@ integration-test:
alias: minio
command:
- "server"
- "/vol0"
- "/vol{0...3}"
- "--console-address"
- ":9001"
script:
......
MAJOR = 0
MINOR = 0
PATCH = 9
PATCH = 10
__version__ = '{}.{}.{}'.format(MAJOR, MINOR, PATCH)
......@@ -99,14 +99,21 @@ class Mc:
self.logger.info(ret.stdout)
# Workaround for multiline json returned by mc
val = self.parse_mc_output(ret)
return val
def parse_mc_output(self, ret):
val = {}
if ret.stdout.splitlines():
if len(ret.stdout.splitlines()) > 1:
val['multiline'] = []
for line in ret.stdout.splitlines():
val['multiline'].append(json.loads(line))
try:
val['multiline'].append(json.loads(line or 'null'))
except json.JSONDecodeError:
val['multiline'].append(line)
else:
val = json.load(ret.stdout or 'null')
val = json.loads(ret.stdout or 'null')
return val
def user_add(self, access_key: str, secret_key: str):
......
......@@ -6,4 +6,31 @@ parser.add_argument('--url', default='minio:9000')
args = parser.parse_args()
m = Mc(args.url, secure=False, access_key='minioadmin', secret_key='minioadmin')
ret = m._command(['ls', m.ALIAS])
print(m._command(['ls', m.ALIAS]))
m.user_add('test', 'testtesttest')
m.policy_add('test', {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::{bucket_name}".format(bucket_name='test')
]
}
]
})
m.policy_set_user('test', 'test')
m.create_service_account('test')
m.bucket_exists('test')
m.make_locked_bucket('test')
m.set_bucket_100y_retention('test')
m.enable_bucket_notification('test')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment