Commit c5caf8ec authored by Martin Abbrent's avatar Martin Abbrent 💬
Browse files

Merge branch 'add-bucket-tags' into 'master'

Add set_bucket_tags methode

See merge request !2
parents 95ccc7c8 5b7fd4f7
Pipeline #51204 passed with stages
in 1 minute and 1 second
......@@ -77,3 +77,12 @@ user has an IAM policy assigned):
```python
svc_creds = mc.create_service_account('my-user')
```
# Tests
There is a integration test tailored for an empty minio container:
```bash
docker run --rm -p 9000:9000 -p 9001:9001 -e MINIO_NOTIFY_KAFKA_ENABLE="on" -e MINIO_NOTIFY_KAFKA_BROKERS="kafka:9092" -e MINIO_NOTIFY_KAFKA_TOPIC="minio-bucket-notifications" minio/minio server /vol0 /vol1 /vol2 /vol3 --console-address :9001
python ./tests/integration_test.py
```
MAJOR = 0
MINOR = 0
PATCH = 10
PATCH = 11
__version__ = '{}.{}.{}'.format(MAJOR, MINOR, PATCH)
......@@ -4,7 +4,7 @@ import subprocess
import tempfile
from minio import Minio
from minio.commonconfig import GOVERNANCE
from minio.commonconfig import GOVERNANCE, Tags
from minio.objectlockconfig import ObjectLockConfig, YEARS
......@@ -93,6 +93,7 @@ class Mc:
err_from_stdout = ret.stdout if json.loads(ret.stdout).get('status') == 'error' else ''
msg = ret.stderr or err_from_stdout or '"Unspecified error: Empty response from minio ' \
'client" '
self.logger.error(msg)
raise MinIoClientError(json.dumps(json.loads(msg), indent=4))
if not confidential:
......@@ -164,3 +165,11 @@ class Mc:
# add event listener
for target in targets:
self._command(['event', 'add', '{}/{}'.format(self.alias, bucket_name), target])
def set_bucket_tags(self, bucket_name: str, plain_tags: dict):
bucket_tags = Tags.new_bucket_tags()
for k, v in plain_tags.items():
bucket_tags[k] = v
self.minio.set_bucket_tags(bucket_name, bucket_tags)
......@@ -5,8 +5,12 @@ parser = argparse.ArgumentParser()
parser.add_argument('--url', default='minio:9000')
args = parser.parse_args()
# Docker container for testing docker run --rm -p 9000:9000 -p 9001:9001 -e
# MINIO_NOTIFY_KAFKA_ENABLE="on" -e MINIO_NOTIFY_KAFKA_BROKERS="kafka:9092" -e
# MINIO_NOTIFY_KAFKA_TOPIC="minio-bucket-notifications" minio/minio server /vol0 /vol1 /vol2
# /vol3 --console-address :9001
m = Mc(args.url, secure=False, access_key='minioadmin', secret_key='minioadmin')
print(m._command(['ls', m.ALIAS]))
m.user_add('test', 'testtesttest')
m.policy_add('test', {
......@@ -33,4 +37,4 @@ m.bucket_exists('test')
m.make_locked_bucket('test')
m.set_bucket_100y_retention('test')
m.enable_bucket_notification('test')
m.set_bucket_tags('test', {'foo': 'bar'})
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