MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / updateWebSecureAnnotation

Function updateWebSecureAnnotation

commands/action.go:874–896  ·  view source on GitHub ↗

* * Update the existing annotations with the web security annotation * If the current web security setting and existing setting are the "same", keep the existing value * -> checking for the same "--web-secure true" setting means just checking if the two values are integers * If the current web

(websecure string, annotations whisk.KeyValueArr)

Source from the content-addressed store, hash-verified

872 * If the current web security setting is "false", remove any existing setting
873 */
874func updateWebSecureAnnotation(websecure string, annotations whisk.KeyValueArr) whisk.KeyValueArr {
875 secureSecret := webSecureSecret(websecure) // will be false when "--web-secure false"
876 existingSecret := annotations.GetValue(WEB_SECURE_ANNOT)
877 _, disableSecurity := secureSecret.(bool)
878 _, newSecretIsInt := secureSecret.(int64)
879 var existingSecretIsInt bool = false
880 if existingSecret != nil {
881 _, existingSecretIsInt = existingSecret.(json.Number)
882 }
883
884 if existingSecretIsInt && newSecretIsInt {
885 whisk.Debug(whisk.DbgInfo, "Retaining existing secret number\n")
886 } else if existingSecret != nil && disableSecurity {
887 whisk.Debug(whisk.DbgInfo, "disabling web-secure; deleting annotation: %v\n", WEB_SECURE_ANNOT)
888 annotations = deleteKey(WEB_SECURE_ANNOT, annotations)
889 } else {
890 whisk.Debug(whisk.DbgInfo, "Setting %v annotation; prior secret %v new secret %v\n",
891 WEB_SECURE_ANNOT, reflect.TypeOf(existingSecret), reflect.TypeOf(secureSecret))
892 annotations = annotations.AddOrReplace(&whisk.KeyValue{Key: WEB_SECURE_ANNOT, Value: secureSecret})
893 }
894
895 return annotations
896}
897
898//
899// Generate a secret according to the --web-secure setting

Callers 1

augmentWebSecureArgFunction · 0.85

Calls 2

webSecureSecretFunction · 0.85
deleteKeyFunction · 0.85

Tested by

no test coverage detected