Skip to content

Commit f201de1

Browse files
authored
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 <[email protected]>
1 parent 3529787 commit f201de1

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ dependencies {
5353
build(['name':'github.com/mitchellh/go-homedir', 'version':'1111e456ffea841564ac0fa5f69c26ef44dafec9', 'transitive':false])
5454
build(['name':'github.com/nicksnyder/go-i18n/i18n/...', 'version':'991e81cc94f6c54209edb3192cb98e3995ad71c1', 'transitive':false])
5555
build(['name':'github.com/spf13/cobra', 'version':'1238ba19d24b0b9ceee2094e1cb31947d45c3e86', 'transitive':false])
56-
build(['name':'github.com/spf13/pflag', 'version':'367864438f1b1a3c7db4da06a2f55b144e6784e0', 'transitive':false])
56+
build(['name':'github.com/spf13/pflag', 'version':'81378bbcd8a1005f72b1e8d7579e5dd7b2d612ab', 'transitive':false])
5757
build(['name':'golang.org/x/sys/unix', 'version':'7f918dd405547ecb864d14a8ecbbfe205b5f930f', 'transitive':false])
5858
build(['name':'gopkg.in/yaml.v2', 'version':'eb3733d160e74a9c7e442f435eb3bea458e1d19f', 'transitive':false])
5959
build(['name':'github.com/ghodss/yaml', 'version':'0ca9ea5df5451ffdf184b4428c902747c2c11cd7', 'transitive':false])
60-
build(['name':'github.com/apache/openwhisk-client-go/whisk','version':'d8ccb1442651beee6a9245913e3ca0cb182888b1','transitive':false])
60+
build(['name':'github.com/apache/openwhisk-client-go/whisk','version':'44551f1f3b715e87c0319b55762d50c71d214460','transitive':false])
6161
build(['name':'github.com/apache/openwhisk-wskdeploy','version':'cbe7c52d99c1ead5172946d3aeb33adb5d5c40b2','transitive':false])
6262
// END - Imported from Godeps
6363
test name:'github.com/stretchr/testify', version:'b91bfb9ebec76498946beb6af7c0230c7cc7ba6c', transitive:false //, tag: 'v1.2.0'

commands/action.go

+11
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action,
480480
return nil, noArtifactError()
481481
}
482482

483+
if update {
484+
action.DelAnnotations = Flags.action.delAnnotation
485+
}
483486
whisk.Debug(whisk.DbgInfo, "Parsed action struct: %#v\n", action)
484487
return action, err
485488
}
@@ -573,6 +576,13 @@ func augmentWebSecureArg(cmd *cobra.Command, args []string, originalAction *whis
573576
augmentedAction.Annotations = augmentedAction.Annotations.AppendKeyValueArr(getWebSecureAnnotations(existingAction))
574577
}
575578
}
579+
// when "--web-secure false", need to delete require-whisk-auth annotation
580+
secureSecret := webSecureSecret(Flags.action.websecure) // will be false when "--web-secure false"
581+
existingSecret := augmentedAction.Annotations.GetValue(WEB_SECURE_ANNOT)
582+
_, disableSecurity := secureSecret.(bool)
583+
if existingSecret != nil && disableSecurity {
584+
augmentedAction.DelAnnotations = []string{"require-whisk-auth"}
585+
}
576586
augmentedAction.Annotations = updateWebSecureAnnotation(Flags.action.websecure, augmentedAction.Annotations)
577587
}
578588

@@ -1305,6 +1315,7 @@ func init() {
13051315
actionUpdateCmd.Flags().StringVarP(&Flags.common.paramFile, "param-file", "P", "", wski18n.T("`FILE` containing parameter values in JSON format"))
13061316
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"))
13071317
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"))
1318+
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"))
13081319

13091320
actionInvokeCmd.Flags().StringSliceVarP(&Flags.common.param, "param", "p", []string{}, wski18n.T("parameter values in `KEY VALUE` format"))
13101321
actionInvokeCmd.Flags().StringVarP(&Flags.common.paramFile, "param-file", "P", "", wski18n.T("`FILE` containing parameter values in JSON format"))

commands/flags.go

+17-16
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,23 @@ type FlagsStruct struct {
136136
}
137137

138138
type ActionFlags struct {
139-
docker string
140-
native bool
141-
copy bool
142-
web string
143-
websecure string
144-
sequence bool
145-
timeout int
146-
memory int
147-
logsize int
148-
concurrency int
149-
result bool
150-
kind string
151-
main string
152-
url bool
153-
save bool
154-
saveAs string
139+
docker string
140+
native bool
141+
copy bool
142+
web string
143+
websecure string
144+
sequence bool
145+
timeout int
146+
memory int
147+
logsize int
148+
concurrency int
149+
result bool
150+
kind string
151+
main string
152+
url bool
153+
save bool
154+
saveAs string
155+
delAnnotation []string
155156
}
156157

157158
func IsVerbose() bool {

tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskCliBasicUsageTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
669669
Parameters(createKey, createValue) ++
670670
Parameters(origKey, origValue)
671671
}
672-
val updateAnnotations = baseAnnotations ++ Parameters(updateKey, updateValue) ++ Parameters(
672+
val updateAnnotations = createAnnotations ++ Parameters(updateKey, updateValue) ++ Parameters(
673673
origKey,
674674
overwrittenValue)
675675

wski18n/resources/en_US.all.json

+4
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,10 @@
14151415
"id": "secure the web action. where `SECRET` is true, false, or any string. Only valid when the ACTION is a web action",
14161416
"translation": "secure the web action. where `SECRET` is true, false, or any string. Only valid when the ACTION is a web action"
14171417
},
1418+
{
1419+
"id": "the list of annotations to be deleted from the action, e.g. --del-annotation key1 --del-annotation key2",
1420+
"translation": "the list of annotations to be deleted from the action, e.g. --del-annotation key1 --del-annotation key2"
1421+
},
14181422
{
14191423
"id": "The --web-secure option is only valid when the --web option is enabled.",
14201424
"translation": "The --web-secure option is only valid when the --web option is enabled."

0 commit comments

Comments
 (0)