Skip to content

Commit

Permalink
Change to ensure we can't pass in both --kind and --docker at the sam…
Browse files Browse the repository at this point in the history
…e time. It should produce an error.
  • Loading branch information
jessealva authored and dubee committed Dec 4, 2017
1 parent 7f65275 commit a6bfa01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action,
action.Annotations = annotations.(whisk.KeyValueArr)
}

if len(Flags.action.kind) > 0 && len(Flags.action.docker) > 0 {
errStr := wski18n.T("Cannot specify both --kind and --docker at the same time.")
return nil, whisk.MakeWskError(errors.New(errStr), whisk.NOT_ALLOWED, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
}

if Flags.action.copy {
var copiedQualifiedName = new(QualifiedName)

Expand Down
15 changes: 15 additions & 0 deletions tests/src/test/scala/system/basic/WskActionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import common.ActivationResult
import common.JsHelpers
import common.TestHelpers
import common.TestCLIUtils
import common.TestUtils._
import common.BaseWsk
import common.Wsk
import common.WskProps
Expand Down Expand Up @@ -295,4 +296,18 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
activation.logs.get.mkString(" ") should include(s"hello $utf8")
}
}

it should "not be able to use --kind and --docker at the same time when running action create" in {
val file = TestCLIUtils.getTestActionFilename(s"echo.js")
val out = wsk.action.create(name = "kindAndDockerAction", artifact = Some(file), expectedExitCode = NOT_ALLOWED,
kind = Some("nodejs:6"), docker = Some("mydockerimagename"))
out.stderr should include("Cannot specify both --kind and --docker at the same time")
}

it should "not be able to use --kind and --docker at the same time when running action update" in {
val file = TestCLIUtils.getTestActionFilename(s"echo.js")
val out = wsk.action.create(name = "kindAndDockerAction", artifact = Some(file), expectedExitCode = NOT_ALLOWED,
kind = Some("nodejs:6"), docker = Some("mydockerimagename"), update = true)
out.stderr should include("Cannot specify both --kind and --docker at the same time")
}
}
4 changes: 4 additions & 0 deletions wski18n/resources/en_US.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -1554,5 +1554,9 @@
{
"id": "Cannot create file '{{.name}}': {{.err}}",
"translation": "Cannot create file '{{.name}}': {{.err}}"
},
{
"id": "Cannot specify both --kind and --docker at the same time.",
"translation": "Cannot specify both --kind and --docker at the same time."
}
]

0 comments on commit a6bfa01

Please sign in to comment.