Created
April 8, 2020 15:53
-
-
Save maasg/5b26bf5f93995b0a67eb38dcb3c88ed4 to your computer and use it in GitHub Desktop.
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
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