-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use awsProfile in s3region and s3credentials #57
Use awsProfile in s3region and s3credentials #57
Conversation
Thanks for the pull-request! It looks good, but I have one doubt which I'd like to discuss before merging:
If you have your region set in, say, environment variable, then you set This is why in the current credentials provider chain, profile provider goes first. I see two solutions here:
I would prefer the second path, because it uses default chains from the Java SDK and follows the path of least surprise for the user: when you set something optional explicitly, you expect it to take the priority over any other (implicit) defaults. What do you think about it @tsuyoshizawa? P.S. I'm marking this pull-request for Hacktoberfest in case you're participating 😉 It doesn't influence anything, just in case you'll make 3 more pull-requests with such label until the end of October, you'll get a nice t-shirt 👕 |
I see. I also prefer the second path. I only concern this change bring breaking compatibility, but user just wrap |
@laughedelic I fixed. Could you check again? I will squash my commits after you review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the Readme. Check my comments below. I want to make the transition for those who already uses awsProfile
smoother and make a breaking change in the default s3credentials
for consistency.
@@ -85,7 +87,7 @@ object SbtS3Resolver extends AutoPlugin { | |||
implicit def fromProviderToAWSRegion(provider: AwsRegionProvider): Region = regionFromString(provider.getRegion()) | |||
|
|||
// Adding setting keys | |||
lazy val awsProfile = settingKey[String]("AWS credentials profile") | |||
lazy val awsProfile = settingKey[Option[String]]("AWS credentials profile") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your concern about breaking change: take a look at the trick we did in #55 (comment) (here). You can add an implicit conversion from String
to Option[String]
and a deprecation message, which explains that you should write explicit Some(...)
. This way users that didn't use the setting, won't notice the change and those who did will get a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an implicit conversion from String
to Option[String]
according to acl2Option
src/main/scala/SBTS3Resolver.scala
Outdated
s3credentials := | ||
new ProfileCredentialsProvider(awsProfile.value) | | ||
new ProfileCredentialsProvider(awsProfile.value.orNull) | | ||
new EnvironmentVariableCredentialsProvider() | | ||
InstanceProfileCredentialsProvider.getInstance(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to change s3credentials
default similarly to the new default for s3region
. I think consistency here is more important than preserving compatibility:
- the default will be mentioned in the readme
- the change will be mentioned in the release notes
- I think it won't affect most people, because usually you either rely on the default credentials chain, or set credentials explicitly. Also if you were using
awsProfile
before, then you also shouldn't notice the change.
So change this, please, in the same way as the s3region
.
I changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of more changes, please
src/main/scala/SBTS3Resolver.scala
Outdated
(awsProfile.value match { | ||
case Some(profile) => new ProfileCredentialsProvider(profile) | ||
case _ => | ||
new ProfileCredentialsProvider() | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of None
, it should use DefaultCredentialsProviderChain
from SDK. The same way as with the region. Sorry if I wasn't clear about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the code to use DefaultAWSCredentialsProviderChain
.
@@ -21,6 +23,9 @@ object SbtS3Resolver extends AutoPlugin { | |||
@deprecated("s3acl is now an Option. Please define it either Some(...) or None if you wish to inherit the bucket default.", "0.18.0") | |||
implicit def acl2Option(acl: S3ACL): Option[S3ACL] = Some(acl) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The end of message (about bucket default) is not related to this setting. Just remove the part about None: "Please define it explicitly with Some(...).". None is default and doesn't use this conversion, so user doesn't need to see this warning if he didn't touch the setting.
78a1dbe
to
e1e8e45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks for the contribution. I'm going to merge it and cut a release a bit later today.
Thank you for review! |
Released as v0.19.0 |
Change to
AwsRegionProviderChain
usesawsProfile
value (#56)AwsProfileNameLoader.DEFAULT_PROFILE_NAME
definesdefault
, so the string should use constants value.