Commit 6c5b970f authored by Siarhei Symanovich (EPAM)'s avatar Siarhei Symanovich (EPAM)
Browse files

Merge branch 'master' into GONRG-5061-refactor-comm-pipe

parents 27223867 2a32beef
Pipeline #116194 failed with stages
in 7 seconds
......@@ -22,34 +22,23 @@ class IBMBundleStorageClient(BundleStorageClient):
self.client = get_client()
self.bucket_name = os.environ["POLICY_BUCKET"]
self.content_type = "application/x-gtar"
# session = boto3.session.Session()
self.s3_client = boto3.resource('s3',
endpoint_url=os.environ["ENDPOINT_URL"],
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
config=Config(signature_version='s3v4'),
region_name='us-east-1')
def _get_bucket_uri(self, filename: str) -> str:
return f"s3://{self.bucket_name}/{filename}"
def download_file(self, filename: str, file: FileLikeObject) -> Tuple[FileLikeObject, str]:
self.s3_client = boto3.client('s3',
endpoint_url=os.environ["ENDPOINT_URL"],
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
config=Config(signature_version='s3v4'),
region_name='us-east-1')
def download_file(self, key: str, file: FileLikeObject) -> Tuple[FileLikeObject, str]:
try:
uri = self._get_bucket_uri(filename)
if self._does_file_exist(uri):
self.s3_client.download_file(uri, file, self.content_type)
return file, uri
else:
raise FileNotFound(filename)
self.s3_client.download_fileobj(self.bucket_name, key, file)
return file, key
except Exception as e:
logger.error(f"Failed to download file from {uri}")
logger.error(f"Failed to download file")
def upload_file(self, name: str, file: FileLikeObject) -> str:
def upload_file(self, key: str, file: FileLikeObject) -> str:
try:
uri = self._get_bucket_uri(name)
self.s3_client.upload_file(uri, file, self.content_type)
return uri
self.s3_client.upload_fileobj(file, self.bucket_name, key)
return file, key
except Exception as e:
logger.error(f"Failed to upload file to {uri}")
\ No newline at end of file
logger.error(f"Failed to upload file")
ibm_bootstrap:
stage: bootstrap
image: registry.access.redhat.com/ubi8/ubi:latest
needs: ["compile-and-unit-test"]
extends:
- .ibm_variables
script:
......@@ -10,7 +11,7 @@ ibm_bootstrap:
- wget https://dl.min.io/client/mc/release/linux-amd64/mc
- chmod +x mc
- ./mc config host add bundle-server https://$IBM_COS_ENDPOINT $IBM_COS_ACCESS_KEY $IBM_COS_SECRET_KEY --api S3v4
- ./mc cp bundle-opendes.tar.gz bundle-server/$IBM_OPA_BUNDLE_SERVER_BUCKET/
# - ./mc cp bundle-opendes.tar.gz bundle-server/$IBM_OPA_BUNDLE_SERVER_BUCKET/
- ./mc cp bundle.tar.gz bundle-server/$IBM_OPA_BUNDLE_SERVER_BUCKET/
only:
variables:
......
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