Skip to content

Commit

Permalink
Revert to old format in boto credentials file to make boto work
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Bohnen committed Oct 4, 2022
1 parent d0e26c4 commit 469dde1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
9 changes: 6 additions & 3 deletions boto_credentials.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[minio-travis-test]
# AWS minio credentials
access_key=minio
secret_key=miniostorage
connect_func=connect_s3
host=http://127.0.0.1:9000
ordinary_calling_format=true
# AWS minio endpoint
host=127.0.0.1
is_secure=false
port=9000
# Legacy boto config
connect_func=connect_s3
ordinary_calling_format=true
25 changes: 21 additions & 4 deletions tests/bucket_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,41 @@ def boto_bucket(


@contextmanager
def boto3_bucket(access_key, secret_key, host=None, bucket_name=None, **kwargs):
# Set environment variables for boto3
def boto3_bucket(
access_key,
secret_key,
host=None,
bucket_name=None,
port=None,
is_secure=None,
**kwargs,
):
import os

import boto3

# Set environment variables for boto3
os.environ["AWS_ACCESS_KEY_ID"] = access_key
os.environ["AWS_SECRET_ACCESS_KEY"] = secret_key
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"

# Build endpoint host
endpoint_url = None
if host:
scheme = "https" if is_secure else "http"
endpoint_url = f"{scheme}://{host}"
if port:
endpoint_url += f":{port}"

name = bucket_name or "testrun-bucket-{}".format(uuid())
s3_client = boto3.client(
"s3",
endpoint_url=host,
endpoint_url=endpoint_url,
)
s3_client.create_bucket(Bucket=name)
s3_resource = boto3.resource(
"s3",
endpoint_url=host,
endpoint_url=endpoint_url,
)
bucket = s3_resource.Bucket(name)

Expand Down

0 comments on commit 469dde1

Please sign in to comment.