Skip to content

Commit

Permalink
changed some structure
Browse files Browse the repository at this point in the history
Signed-off-by: Pratiksha Sankhe <[email protected]>
  • Loading branch information
psankhe28 committed Sep 11, 2024
1 parent 6ae493a commit f1736e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
5 changes: 3 additions & 2 deletions cloud_storage_handler/clients/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def get_minio_client():
Returns:
MinioClient: An initialized Minio client with a created bucket.
"""
client = MinioClient()
client.create_bucket()
init_client=MinioClient()
client=init_client.get_client()
init_client.create_bucket()
return client
19 changes: 8 additions & 11 deletions cloud_storage_handler/clients/minio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,16 @@ class MinioClient:
def __init__(self):
"""Initialize the MinIO client and create bucket if necessary."""
config = MinioConfig().get_minio_config()
self.client = self.initialise_minio(
self.client = Minio(
endpoint=f"{config['hostname']}:{config['port']}",
access_key=config["access_key"],
secret_key=config["secret_key"],
secure=False,
secure=False
)
self.bucket_name = config["bucket_name"]

def initialise_minio(self, endpoint, access_key, secret_key, secure):
"""Initialize the MinIO client with provided configurations."""
self.client = Minio(
endpoint=endpoint,
access_key=access_key,
secret_key=secret_key,
secure=False,
)
return self.client
# Create bucket if it doesn't exist
self.create_bucket()

def create_bucket(self):
"""Creation of bucket using the configured bucket name."""
Expand All @@ -96,3 +89,7 @@ def create_bucket(self):
logger.info(f"Bucket '{self.bucket_name}' created.")
else:
logger.info(f"Bucket '{self.bucket_name}' already exists.")

def get_client(self):
"""Return the MinIO client."""
return self.client

0 comments on commit f1736e5

Please sign in to comment.