Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing del annotation #488

Merged
merged 3 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@style95 style95 Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not clear about this, can users pass list of annotations? or they have to use --del-annotation for every annotation?
( --del-annotation key1 --del-annotation key2 vs --del-annotation [key1, key2])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must pass like this --del-annotation key1 --del-annotation key2, in go backend, it will recevie the value by array:
https://github.com/apache/openwhisk-client-go/pull/137/files#diff-7a2fb893e2fa76731b906c5689a14e95R39

}
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add delAnnotation field

}

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