valamis / sbt-azureblob-resolver   0.11.0

GNU General Public License v3.0 only GitHub

☁️Azure BlobStorage-based resolver for sbt

Scala versions: 2.12
sbt plugins: 1.0

Sbt Azure BlobStorage resolver

Plugin to ease resolving dependencies from and publish to Azure BlobStorage containers, using custom url syntax 'blob://'.

This is a fork of https://github.com/lukaci/sbt-azureblob-resolver with added support for all types of credentials - original plugin supports only shared key credentials.

Thanks to ohnosequences gkatzioura frugalmechanic for the job done on other storage providers

SBT 1.1+ Support

SBT 1.1 support is available using version >= 0.10.0:

addSbtPlugin("com.valamis" %% "sbt-azureblob-resolver" % "0.10.0")

Examples

Resolving

Maven Style:

resolvers += "Blob Snapshots" at "blob://youraccountname/snapshots"

Ivy Style:

resolvers += Resolver.url("Blob Snapshots", url("blob://youraccountname/snapshots"))(Resolver.ivyStylePatterns)

Publishing

Maven Style:

publishMavenStyle := true
publishTo := Some("Blob Snapshots" at "blob://youraccountname/snapshots")

Ivy Style:

publishMavenStyle := false
publishTo := Some(Resolver.url("Blob Snapshots", url("blob://youraccountname/snapshots"))(Resolver.ivyStylePatterns))

Valid blob:// URL Formats

blob://[ACCOUNTNAME]/[ROOT_CONTAINER]

Usage

Add this to your project/plugins.sbt file:

addSbtPlugin("com.valamis" %% "sbt-azureblob-resolver" % "0.10.0")

Note: if you need to resolve other plugins, published to your Azure Blob storage, then you need to put addSbtPlugin line to project/project/project/plugins.sbt file. See here for details

Azure BlobStorage Credentials

Credentials are checked in

  1. Environment variables (token credentials first)
  2. Specific account name property files (token credentials first)

If no credentials found, then anonymous access is used

Environment Variables

SBT_BLOB_TOKEN_CREDENTIALS=<ACCOUNT_NAME_1>:<SECRET_KEY_1>:<ACCOUNT_NAME_2>:<SECRET_KEY_2>:...
SBT_BLOB_SHARED_KEY_CREDENTIALS=<ACCOUNT_NAME_1>:<SECRET_KEY_1>:<ACCOUNT_NAME_2>:<SECRET_KEY_2>:...

Specific property Files

.<account_name>.sbt-blob-token-credentials
.<account_name>.sbt-blob-shared-key-credentials

containing

accountKey=XXXXXX

Custom Credentials

If the default credential providers are not enough for you you can specify your own CredentialsProvider using the blobCredentialsProvider SettingKey in your build.sbt file:

import com.valamis.sbt.azure.blob.resolver._
import com.microsoft.azure.storage.blob.ICredentials

...

blobCredentialsProvider := new AzureBlobStorageCredentialsProvider {

  override val credentialsType: CredentialsTypes.Value = CredentialsTypes.Token

  override def provide(accountName: String): Either[List[String], ICredentials] = {
    // returned value should be an instance of
    // - Left[List[String]] with list of errors if there is a failure
    // - Right[ICredentials] if credentials are successfully provided
  }
}

where credentialsType should have one of these values:

object CredentialsTypes extends Enumeration {
  val Token: CredentialsTypes.Value = Value("token")
  val SharedKey: CredentialsTypes.Value = Value("shared-key")
  val Anon: CredentialsTypes.Value = Value("anon")
  val All: CredentialsTypes.Value = Value("all")
}

Authors

lukaci (GitHub)

Pavel Kornilov (GitHub) - support for all types of credentials

License

GNU General Public License, Version 3.0