in nuvolaris/minio_deploy.py [0:0]
def create_ow_storage(state, ucfg: UserConfig, user_metadata: UserMetadata, owner=None):
minioClient = mutil.MinioClient()
namespace = ucfg.get("namespace")
secretkey = ucfg.get("object-storage.password")
logging.info(f"*** configuring storage for namespace {namespace}")
res = minioClient.add_user(namespace, secretkey)
state['storage_user']=res
if(res):
_add_miniouser_metadata(ucfg, user_metadata)
bucket_policy_names = []
if(ucfg.get('object-storage.data.enabled')):
bucket_name = ucfg.get('object-storage.data.bucket')
logging.info(f"*** adding private bucket {bucket_name} for {namespace}")
res = minioClient.make_bucket(bucket_name)
bucket_policy_names.append(f"{bucket_name}/*")
state['storage_data']=res
if(res):
user_metadata.add_metadata("S3_BUCKET_DATA",bucket_name)
ucfg.put("S3_BUCKET_DATA",bucket_name)
if ucfg.exists('object-storage.quota'):
assign_bucket_quota(bucket_name,ucfg.get('object-storage.quota'), minioClient)
if(ucfg.get('object-storage.route.enabled')):
bucket_name = ucfg.get("object-storage.route.bucket")
logging.info(f"*** adding public bucket {bucket_name} for {namespace}")
res = minioClient.make_public_bucket(bucket_name)
bucket_policy_names.append(f"{bucket_name}/*")
if(res):
user_metadata.add_metadata("S3_BUCKET_STATIC",bucket_name)
ucfg.put("S3_BUCKET_STATIC",bucket_name)
if ucfg.exists('object-storage.quota'):
assign_bucket_quota(bucket_name,ucfg.get('object-storage.quota'), minioClient)
content_path = find_content_path("index.html")
if(content_path):
logging.info(f"uploading example content to {bucket_name} from {content_path}")
res = minioClient.upload_folder_content(content_path,bucket_name)
else:
logging.warn("could not find example static content to upload")
state['storage_route']=res
if(len(bucket_policy_names)>0):
logging.info(f"granting rw access to created policies under namespace {namespace}")
minioClient.assign_rw_bucket_policy_to_user(namespace,bucket_policy_names)
return state