-
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
Merged
laughedelic
merged 8 commits into
ohnosequences:master
from
tsuyoshizawa:custom-aws-region-provider-chain
Oct 17, 2017
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1f405e6
Fix to pass awsProfile to AwsRegionProviderChain
tsuyoshizawa 9f5494d
Optional for awsProfile
tsuyoshizawa bdc1cc4
update Readme.md
tsuyoshizawa 1464b29
fix import
tsuyoshizawa 37d5adb
use match for ignore compile error
tsuyoshizawa ab23fb5
support awsProfile to not Option
tsuyoshizawa 4fc7f7c
updated Readme.md
tsuyoshizawa e1e8e45
fix deprecated message and s3credentials
tsuyoshizawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,10 @@ package ohnosequences.sbt | |
import sbt._ | ||
import Keys._ | ||
import java.util.Optional | ||
import com.amazonaws.auth._, profile._ | ||
import com.amazonaws.regions.{ Region, Regions, RegionUtils, AwsRegionProvider } | ||
|
||
import com.amazonaws.auth._ | ||
import com.amazonaws.auth.profile.ProfileCredentialsProvider | ||
import com.amazonaws.regions._ | ||
import com.amazonaws.services.s3.AmazonS3 | ||
|
||
|
||
|
@@ -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") | ||
lazy val s3credentials = settingKey[AWSCredentialsProvider]("AWS credentials provider to access S3") | ||
lazy val s3region = settingKey[Region]("AWS Region for your S3 resolvers") | ||
lazy val s3overwrite = settingKey[Boolean]("Controls whether publishing resolver can overwrite artifacts") | ||
|
@@ -129,12 +131,15 @@ object SbtS3Resolver extends AutoPlugin { | |
|
||
// Default settings | ||
override def projectSettings: Seq[Setting[_]] = Seq( | ||
awsProfile := "default", | ||
awsProfile := None, | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to change
So change this, please, in the same way as the |
||
s3region := new com.amazonaws.regions.DefaultAwsRegionProviderChain(), | ||
s3region := (awsProfile.value match { | ||
case Some(profile) => new AwsProfileRegionProvider(profile) | ||
case _ => new DefaultAwsRegionProviderChain() | ||
}), | ||
s3overwrite := isSnapshot.value, | ||
s3sse := false, | ||
s3acl := Some(com.amazonaws.services.s3.model.CannedAccessControlList.PublicRead), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
toOption[String]
and a deprecation message, which explains that you should write explicitSome(...)
. 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
toOption[String]
according toacl2Option