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

Added CombinedCmd and removed EnvCmd #628

Merged
merged 1 commit into from
Jul 24, 2015
Merged
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
32 changes: 24 additions & 8 deletions src/main/scala/com/typesafe/sbt/packager/docker/dockerfile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,38 @@ case class ExecCmd(cmd: String, args: String*) extends CmdLike {
*
* @example
* {{{
* val add = Cmd("ADD", "src/resource/LICENSE.txt /opt/docker/LICENSE.txt")
* val add = Cmd("ADD", "src/resource/LICENSE.txt", "/opt/docker/LICENSE.txt")
* }}}
*
* @example
* {{{
* val copy = Cmd("COPY", "src/resource/LICENSE.txt", "/opt/docker/LICENSE.txt")
* }}}
*
* @example
* {{{
* val env = Cmd("ENV", "APP_SECRET", "7sdfy7s9hfisdufuusud")
* }}}
*/
case class Cmd(cmd: String, arg: String) extends CmdLike {
def makeContent = "%s %s\n" format (cmd, arg)
case class Cmd(cmd: String, args: String*) extends CmdLike {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about this. Cmd(cmd: String, first: String, rest: String*) would represent the old interface more correctly. However with your suggestion zero-argument commands would be possible.

@jsuereth what about binary compatibility?

def makeContent = "%s %s\n" format (cmd, args.mkString(" "))
}

/**
* Environment command
* A command that consists of a CMD string and an CmdLike object
*
* @example {{{
* EnvCmd("FOO_BAR_SECRET_KEY", "HGkhjGKjhgJhgjkhgHKJ")
* @example
* {{{
* val onBuildAdd = CombinedCmd("ONBUILD", Cmd("ADD", "src/resource/LICENSE.txt", "/opt/docker/LICENSE.txt"))
* }}}
*
* @example
* {{{
* val onBuildEnv = CombinedCmd("ONBUILD", Cmd("ENV", "APP_SECRET", "7sdfy7s9hfisdufuusud"))
* }}}
*/
case class EnvCmd(key: String, value: String) extends CmdLike {
def makeContent = "ENV %s %s\n" format (key, value)
case class CombinedCmd(cmd: String, arg: CmdLike) extends CmdLike {
def makeContent = "%s %s\n" format (cmd, arg.makeContent)
}

/** Represents dockerfile used by docker when constructing packages. */
Expand Down