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

Option for Storage Class #35

Merged
merged 4 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ addSbtPlugin("ohnosequences" % "sbt-s3-resolver" % "<version>")
* `s3overwrite`: Controls whether publishing resolver can overwrite artifacts
* `s3acl`: Controls whether published artifacts are accessible publicly via http(s) or not
* `s3sse`: Controls whether publishing resolver will use server side encryption
* `s3storageClass`: Controls storage class for the published S3 objects
* `s3resolver`: Takes name and bucket url and returns an S3 resolver

| Key | Type | Default |
|----------------:|:----------------------------:|:--------------------------|
| `s3credentials` | `AWSCredentialsProvider` | see [below](#credentials) |
| `awsProfile` | `String` | `"default"` |
| `s3region` | `Region` | `EU_Ireland` |
| `s3overwrite` | `Boolean` | same as `isSnapshot` key |
| `s3acl` | `S3ACL` | `PublicRead` |
| `s3sse` | `Boolean` | `false` |
| `s3resolver` | `(String, s3) => S3Resolver` | is set using all above |
| Key | Type | Default |
|:-----------------|:----------------------------:|:--------------------------------|
| `s3credentials` | `AWSCredentialsProvider` | see [below](#credentials) |
| `awsProfile` | `String` | `"default"` |
| `s3region` | `Region` | `DefaultAwsRegionProviderChain` |
| `s3overwrite` | `Boolean` | `isSnapshot.value` |
| `s3acl` | `S3ACL` | `PublicRead` |
| `s3sse` | `Boolean` | `false` |
| `s3storageClass` | `StorageClass` | `Standard` |
| `s3resolver` | `(String, s3) => S3Resolver` | is set using all above |

Where

Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ sbtVersion := "1.0.1"

bucketSuffix := "era7.com"

libraryDependencies += "ohnosequences" % "ivy-s3-resolver" % "0.10.0"
resolvers += Resolver.bintrayRepo("ohnosequences", "maven")

libraryDependencies += "ohnosequences" % "ivy-s3-resolver" % "0.11.0"

dependencyOverrides ++= Set(
"org.scala-lang.modules" %% "scala-xml" % "1.0.6",
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
resolvers += "Era7 maven releases" at "https://s3-eu-west-1.amazonaws.com/releases.era7.com"

addSbtPlugin("ohnosequences" % "nice-sbt-settings" % "0.8.0-RC5")
addSbtPlugin("ohnosequences" % "nice-sbt-settings" % "0.8.0")
48 changes: 30 additions & 18 deletions src/main/scala/SBTS3Resolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ object SbtS3Resolver extends AutoPlugin {

object autoImport {
// Type aliases
type Region = com.amazonaws.regions.Region
type RegionEnum = com.amazonaws.services.s3.model.Region
type Region = com.amazonaws.regions.Region
type RegionEnum = com.amazonaws.services.s3.model.Region
type AWSCredentialsProvider = com.amazonaws.auth.AWSCredentialsProvider
type S3ACL = com.amazonaws.services.s3.model.CannedAccessControlList
type S3ACL = com.amazonaws.services.s3.model.CannedAccessControlList
type StorageClass = com.amazonaws.services.s3.model.StorageClass

case class S3Resolver(
credentialsProvider: AWSCredentialsProvider,
overwrite: Boolean,
region: Region,
acl: S3ACL,
serverSideEncryption: Boolean
serverSideEncryption: Boolean,
storageClass: StorageClass
)(val name: String, val url: s3)
extends ohnosequences.ivy.S3Resolver(name, credentialsProvider, overwrite, region, acl,serverSideEncryption) {
extends ohnosequences.ivy.S3Resolver(name, credentialsProvider, overwrite, region, acl, serverSideEncryption, storageClass) {

def withPatterns(patterns: Patterns): S3Resolver = {
if (patterns.isMavenCompatible) this.setM2compatible(true)
Expand Down Expand Up @@ -78,14 +80,16 @@ object SbtS3Resolver extends AutoPlugin {
implicit def fromProviderToAWSRegion(provider: AwsRegionProvider): Region = regionFromString(provider.getRegion())

// Adding setting keys
lazy val awsProfile = SettingKey[String]("awsProfile", "AWS credentials profile")
lazy val s3credentials = SettingKey[AWSCredentialsProvider]("s3credentials", "AWS credentials provider to access S3")
lazy val s3region = SettingKey[Region]("s3region", "AWS Region for your S3 resolvers")
lazy val s3overwrite = SettingKey[Boolean]("s3overwrite", "Controls whether publishing resolver can overwrite artifacts")
lazy val s3sse = SettingKey[Boolean]("s3sse", "Controls whether publishing resolver will use server side encryption")
lazy val s3acl = SettingKey[S3ACL]("s3acl", "Controls whether published artifacts are accessible publicly via http(s) or not")
lazy val s3resolver = SettingKey[(String, s3) => S3Resolver]("s3resolver", "Takes name and bucket url and returns an S3 resolver")
lazy val showS3Credentials = TaskKey[Unit]("showS3Credentials", "Just outputs credentials that are loaded by the s3credentials provider")
lazy val awsProfile = settingKey[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")
lazy val s3sse = settingKey[Boolean]("Controls whether publishing resolver will use server side encryption")
lazy val s3acl = settingKey[S3ACL]("Controls whether published artifacts are accessible publicly via http(s) or not")
lazy val s3storageClass = settingKey[StorageClass]("Controls storage class for the published S3 objects")
lazy val s3resolver = settingKey[(String, s3) => S3Resolver]("Takes name and bucket url and returns an S3 resolver")

lazy val showS3Credentials = taskKey[Unit]("Just outputs credentials that are loaded by the s3credentials provider")

// S3 bucket url
case class s3(bucketName: String) {
Expand Down Expand Up @@ -125,11 +129,19 @@ object SbtS3Resolver extends AutoPlugin {
new ProfileCredentialsProvider(awsProfile.value) |
new EnvironmentVariableCredentialsProvider() |
InstanceProfileCredentialsProvider.getInstance(),
s3region := new com.amazonaws.regions.DefaultAwsRegionProviderChain(),
s3overwrite := isSnapshot.value,
s3sse := false,
s3acl := com.amazonaws.services.s3.model.CannedAccessControlList.PublicRead,
s3resolver := S3Resolver(s3credentials.value, s3overwrite.value, s3region.value, s3acl.value,s3sse.value),
s3region := new com.amazonaws.regions.DefaultAwsRegionProviderChain(),
s3overwrite := isSnapshot.value,
s3sse := false,
s3acl := com.amazonaws.services.s3.model.CannedAccessControlList.PublicRead,
s3storageClass := com.amazonaws.services.s3.model.StorageClass.Standard,
s3resolver := S3Resolver(
s3credentials.value,
s3overwrite.value,
s3region.value,
s3acl.value,
s3sse.value,
s3storageClass.value
),
showS3Credentials := {
val log = streams.value.log
val creds = s3credentials.value.getCredentials
Expand Down