diff --git a/commands/action.go b/commands/action.go index 75aa7c54f..df75ffd64 100644 --- a/commands/action.go +++ b/commands/action.go @@ -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) diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala index b6d35133c..3fa080d99 100644 --- a/tests/src/test/scala/system/basic/WskActionTests.scala +++ b/tests/src/test/scala/system/basic/WskActionTests.scala @@ -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 @@ -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") + } } diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json index acc6e2c07..077731272 100644 --- a/wski18n/resources/en_US.all.json +++ b/wski18n/resources/en_US.all.json @@ -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." } ]