You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by st...@apache.org on 2020/08/25 02:02:33 UTC
[openwhisk-cli] branch master updated: Support passing del
annotation (#488)
This is an automated email from the ASF dual-hosted git repository.
style95 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-cli.git
The following commit(s) were added to refs/heads/master by this push:
new f201de1 Support passing del annotation (#488)
f201de1 is described below
commit f201de1fd2613cd34c36635f45ab6c7cd49e9e1d
Author: ningyougang <41...@qq.com>
AuthorDate: Tue Aug 25 10:02:26 2020 +0800
Support passing del annotation (#488)
* Support passing del annotation
* Update comments for del annotation
* fetch other dependent lib latest codes when build
- Openwhisk-client-go
- pflag
Co-authored-by: ning.yougang <ni...@navercorp.com>
---
build.gradle | 4 +--
commands/action.go | 11 ++++++++
commands/flags.go | 33 +++++++++++-----------
.../core/cli/test/WskCliBasicUsageTests.scala | 2 +-
wski18n/resources/en_US.all.json | 4 +++
5 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/build.gradle b/build.gradle
index e4106ce..84e9ccd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -53,11 +53,11 @@ dependencies {
build(['name':'github.com/mitchellh/go-homedir', 'version':'1111e456ffea841564ac0fa5f69c26ef44dafec9', 'transitive':false])
build(['name':'github.com/nicksnyder/go-i18n/i18n/...', 'version':'991e81cc94f6c54209edb3192cb98e3995ad71c1', 'transitive':false])
build(['name':'github.com/spf13/cobra', 'version':'1238ba19d24b0b9ceee2094e1cb31947d45c3e86', 'transitive':false])
- build(['name':'github.com/spf13/pflag', 'version':'367864438f1b1a3c7db4da06a2f55b144e6784e0', 'transitive':false])
+ build(['name':'github.com/spf13/pflag', 'version':'81378bbcd8a1005f72b1e8d7579e5dd7b2d612ab', 'transitive':false])
build(['name':'golang.org/x/sys/unix', 'version':'7f918dd405547ecb864d14a8ecbbfe205b5f930f', 'transitive':false])
build(['name':'gopkg.in/yaml.v2', 'version':'eb3733d160e74a9c7e442f435eb3bea458e1d19f', 'transitive':false])
build(['name':'github.com/ghodss/yaml', 'version':'0ca9ea5df5451ffdf184b4428c902747c2c11cd7', 'transitive':false])
- build(['name':'github.com/apache/openwhisk-client-go/whisk','version':'d8ccb1442651beee6a9245913e3ca0cb182888b1','transitive':false])
+ build(['name':'github.com/apache/openwhisk-client-go/whisk','version':'44551f1f3b715e87c0319b55762d50c71d214460','transitive':false])
build(['name':'github.com/apache/openwhisk-wskdeploy','version':'cbe7c52d99c1ead5172946d3aeb33adb5d5c40b2','transitive':false])
// END - Imported from Godeps
test name:'github.com/stretchr/testify', version:'b91bfb9ebec76498946beb6af7c0230c7cc7ba6c', transitive:false //, tag: 'v1.2.0'
diff --git a/commands/action.go b/commands/action.go
index 35adb33..6c2b11a 100644
--- a/commands/action.go
+++ b/commands/action.go
@@ -480,6 +480,9 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action,
return nil, noArtifactError()
}
+ if update {
+ action.DelAnnotations = Flags.action.delAnnotation
+ }
whisk.Debug(whisk.DbgInfo, "Parsed action struct: %#v\n", action)
return action, err
}
@@ -573,6 +576,13 @@ func augmentWebSecureArg(cmd *cobra.Command, args []string, originalAction *whis
augmentedAction.Annotations = augmentedAction.Annotations.AppendKeyValueArr(getWebSecureAnnotations(existingAction))
}
}
+ // when "--web-secure false", need to delete require-whisk-auth annotation
+ secureSecret := webSecureSecret(Flags.action.websecure) // will be false when "--web-secure false"
+ existingSecret := augmentedAction.Annotations.GetValue(WEB_SECURE_ANNOT)
+ _, disableSecurity := secureSecret.(bool)
+ if existingSecret != nil && disableSecurity {
+ augmentedAction.DelAnnotations = []string{"require-whisk-auth"}
+ }
augmentedAction.Annotations = updateWebSecureAnnotation(Flags.action.websecure, augmentedAction.Annotations)
}
@@ -1305,6 +1315,7 @@ func init() {
actionUpdateCmd.Flags().StringVarP(&Flags.common.paramFile, "param-file", "P", "", wski18n.T("`FILE` containing parameter values in JSON format"))
actionUpdateCmd.Flags().StringVar(&Flags.action.web, WEB_FLAG, "", wski18n.T("treat ACTION as a web action, a raw HTTP web action, or as a standard action; yes | true = web action, raw = raw HTTP web action, no | false = standard action"))
actionUpdateCmd.Flags().StringVar(&Flags.action.websecure, WEB_SECURE_FLAG, "", wski18n.T("secure the web action. where `SECRET` is true, false, or any string. Only valid when the ACTION is a web action"))
+ actionUpdateCmd.Flags().StringArrayVar(&Flags.action.delAnnotation, "del-annotation", []string{}, wski18n.T("the list of annotations to be deleted from the action, e.g. --del-annotation key1 --del-annotation key2"))
actionInvokeCmd.Flags().StringSliceVarP(&Flags.common.param, "param", "p", []string{}, wski18n.T("parameter values in `KEY VALUE` format"))
actionInvokeCmd.Flags().StringVarP(&Flags.common.paramFile, "param-file", "P", "", wski18n.T("`FILE` containing parameter values in JSON format"))
diff --git a/commands/flags.go b/commands/flags.go
index a4f5e05..9a40057 100644
--- a/commands/flags.go
+++ b/commands/flags.go
@@ -136,22 +136,23 @@ type FlagsStruct struct {
}
type ActionFlags struct {
- docker string
- native bool
- copy bool
- web string
- websecure string
- sequence bool
- timeout int
- memory int
- logsize int
- concurrency int
- result bool
- kind string
- main string
- url bool
- save bool
- saveAs string
+ docker string
+ native bool
+ copy bool
+ web string
+ websecure string
+ sequence bool
+ timeout int
+ memory int
+ logsize int
+ concurrency int
+ result bool
+ kind string
+ main string
+ url bool
+ save bool
+ saveAs string
+ delAnnotation []string
}
func IsVerbose() bool {
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
index f907109..cafa462 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala
@@ -669,7 +669,7 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
Parameters(createKey, createValue) ++
Parameters(origKey, origValue)
}
- val updateAnnotations = baseAnnotations ++ Parameters(updateKey, updateValue) ++ Parameters(
+ val updateAnnotations = createAnnotations ++ Parameters(updateKey, updateValue) ++ Parameters(
origKey,
overwrittenValue)
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index a887e03..04f25a1 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -1416,6 +1416,10 @@
"translation": "secure the web action. where `SECRET` is true, false, or any string. Only valid when the ACTION is a web action"
},
{
+ "id": "the list of annotations to be deleted from the action, e.g. --del-annotation key1 --del-annotation key2",
+ "translation": "the list of annotations to be deleted from the action, e.g. --del-annotation key1 --del-annotation key2"
+ },
+ {
"id": "The --web-secure option is only valid when the --web option is enabled.",
"translation": "The --web-secure option is only valid when the --web option is enabled."
},