dubeejw closed pull request #172: Change to ensure we can't pass in both --kind
and --docker at the same time
URL: https://github.com/apache/incubator-openwhisk-cli/pull/172
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/commands/action.go b/commands/action.go
index 75aa7c54..df75ffd6 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 b6d35133..3fa080d9 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 acc6e2c0..07773127 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."
}
]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services