Skip to content

Commit a6bfa01

Browse files
jessealvadubee
authored andcommitted
Change to ensure we can't pass in both --kind and --docker at the same time. It should produce an error.
1 parent 7f65275 commit a6bfa01

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

commands/action.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action,
398398
action.Annotations = annotations.(whisk.KeyValueArr)
399399
}
400400

401+
if len(Flags.action.kind) > 0 && len(Flags.action.docker) > 0 {
402+
errStr := wski18n.T("Cannot specify both --kind and --docker at the same time.")
403+
return nil, whisk.MakeWskError(errors.New(errStr), whisk.NOT_ALLOWED, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
404+
}
405+
401406
if Flags.action.copy {
402407
var copiedQualifiedName = new(QualifiedName)
403408

tests/src/test/scala/system/basic/WskActionTests.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import common.ActivationResult
2424
import common.JsHelpers
2525
import common.TestHelpers
2626
import common.TestCLIUtils
27+
import common.TestUtils._
2728
import common.BaseWsk
2829
import common.Wsk
2930
import common.WskProps
@@ -295,4 +296,18 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
295296
activation.logs.get.mkString(" ") should include(s"hello $utf8")
296297
}
297298
}
299+
300+
it should "not be able to use --kind and --docker at the same time when running action create" in {
301+
val file = TestCLIUtils.getTestActionFilename(s"echo.js")
302+
val out = wsk.action.create(name = "kindAndDockerAction", artifact = Some(file), expectedExitCode = NOT_ALLOWED,
303+
kind = Some("nodejs:6"), docker = Some("mydockerimagename"))
304+
out.stderr should include("Cannot specify both --kind and --docker at the same time")
305+
}
306+
307+
it should "not be able to use --kind and --docker at the same time when running action update" in {
308+
val file = TestCLIUtils.getTestActionFilename(s"echo.js")
309+
val out = wsk.action.create(name = "kindAndDockerAction", artifact = Some(file), expectedExitCode = NOT_ALLOWED,
310+
kind = Some("nodejs:6"), docker = Some("mydockerimagename"), update = true)
311+
out.stderr should include("Cannot specify both --kind and --docker at the same time")
312+
}
298313
}

wski18n/resources/en_US.all.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,5 +1554,9 @@
15541554
{
15551555
"id": "Cannot create file '{{.name}}': {{.err}}",
15561556
"translation": "Cannot create file '{{.name}}': {{.err}}"
1557+
},
1558+
{
1559+
"id": "Cannot specify both --kind and --docker at the same time.",
1560+
"translation": "Cannot specify both --kind and --docker at the same time."
15571561
}
15581562
]

0 commit comments

Comments
 (0)