Skip to content

Commit

Permalink
Support passing del annotation (#488)
Browse files Browse the repository at this point in the history
* 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 <ning.yougang@navercorp.com>
  • Loading branch information
ningyougang and ningyougang authored Aug 25, 2020
1 parent 3529787 commit f201de1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
11 changes: 11 additions & 0 deletions commands/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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"))
Expand Down
33 changes: 17 additions & 16 deletions commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions wski18n/resources/en_US.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,10 @@
"id": "secure the web action. where `SECRET` is true, false, or any string. Only valid when the ACTION is a web action",
"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."
Expand Down

0 comments on commit f201de1

Please sign in to comment.