Skip to content

Instantly share code, notes, and snippets.

@maasg
Created April 8, 2020 15:53
Show Gist options
  • Save maasg/5b26bf5f93995b0a67eb38dcb3c88ed4 to your computer and use it in GitHub Desktop.
Save maasg/5b26bf5f93995b0a67eb38dcb3c88ed4 to your computer and use it in GitHub Desktop.
import cloudflow.sbt.CloudflowKeys.{cloudflowDockerImageName, cloudflowDockerRegistry, cloudflowDockerRepository}
import cloudflow.sbt.ImagePlugin
import sbt.{AutoPlugin, Def, taskKey}
trait Key {
val cloudflowImageName = taskKey[String]("The name of the Docker image to publish.")
}
object ImageNamePlugin extends AutoPlugin {
override def requires = ImagePlugin
override def trigger = allRequirements
object autoImport extends Key
import autoImport._
override def projectSettings = Seq(
cloudflowImageName := Def.taskDyn{
Def.task{
val maybeImage = for {
img <- cloudflowDockerImageName.value
registry <- cloudflowDockerRegistry.value
namespace <- cloudflowDockerRepository.value
} yield {
s"$registry/$namespace/${img.name}:${img.tag}"
}
maybeImage.getOrElse("")
}
}.value
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment