You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/01/23 18:50:54 UTC
[GitHub] dubee commented on a change in pull request #4058: Add protect
feature to avoid update or delete actions by mistake
dubee commented on a change in pull request #4058: Add protect feature to avoid update or delete actions by mistake
URL: https://github.com/apache/incubator-openwhisk/pull/4058#discussion_r250324890
##########
File path: core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
##########
@@ -523,16 +524,32 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
val exec = content.exec getOrElse action.exec
- WhiskAction(
- action.namespace,
- action.name,
- exec,
- parameters,
- limits,
- content.version getOrElse action.version.upPatch,
- content.publish getOrElse action.publish,
- (content.annotations getOrElse action.annotations) ++ execAnnotation(exec))
- .revision[WhiskAction](action.docinfo.rev)
+ if (content.unlock.getOrElse(false)) {
+ WhiskAction(
+ action.namespace,
+ action.name,
+ exec,
+ parameters,
+ limits,
+ content.version getOrElse action.version.upPatch,
+ content.publish getOrElse action.publish,
+ (content.annotations getOrElse action.annotations) ++ execAnnotation(exec) ++ Parameters(
+ WhiskAction.lockFieldName,
+ JsBoolean(false)))
+ .revision[WhiskAction](action.docinfo.rev)
+ } else {
+ //keep original value not changed
+ WhiskAction(
+ action.namespace,
+ action.name,
+ exec,
+ parameters,
+ limits,
+ content.version getOrElse action.version.upPatch,
+ content.publish getOrElse action.publish,
+ (content.annotations getOrElse action.annotations) ++ execAnnotation(exec))
Review comment:
Instead of having the if statement and duplicate code, can you just keep the original `WhiskAction` block and add something like the below to the annotations?
```
++ content.unlock.map(u => Parameters(WhiskAction.lockFieldName, JsBoolean(false))).getOrElse(Parameters())
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services