Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent S3 information on non-S3 mirrors #27701

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/spack/spack/mirror.py
Expand Up @@ -530,11 +530,16 @@ def add(name, url, scope, args={}):

items = [(n, u) for n, u in mirrors.items()]
mirror_data = url
key_values = ["s3_access_key_id", "s3_access_token", "s3_profile"]
key_values = ["s3_access_key_id",
"s3_access_token",
"s3_profile",
"s3_endpoint_url"]
# On creation, assume connection data is set for both
if any(value for value in key_values if value in args):
# Check for value in each key, instead of presence of each key
if any(vars(args)[value] for value in key_values if value in args):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall that args is now supposed to be a namespace object with attributes instead of a mapping with keys. (That would explain the use of vars, here).

I think that's fine, but something would need to be done about the default for args, since it doesn't make sense to default to an empty dict, anymore.

Maybe default to None and have some branch that handles None?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is only called from one place, and it supplies args. Maybe it should just make args a required argument?

url_dict = {"url": url,
"access_pair": (args.s3_access_key_id, args.s3_access_key_secret),
"access_pair": (args.s3_access_key_id,
args.s3_access_key_secret),
"access_token": args.s3_access_token,
"profile": args.s3_profile,
"endpoint_url": args.s3_endpoint_url}
Expand Down