style95 commented on a change in pull request #4940:
URL: https://github.com/apache/openwhisk/pull/4940#discussion_r471996907
##########
File path:
tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala
##########
@@ -131,6 +131,38 @@ class WskRestBasicUsageTests extends TestHelpers with
WskTestHelpers with WskAct
}
}
+ it should "update an action via passing delAnnotations" in
withAssetCleaner(wskprops) { (wp, assetHelper) =>
Review comment:
```suggestion
it should "delete the given annotations using delAnnotations" in
withAssetCleaner(wskprops) { (wp, assetHelper) =>
```
##########
File path: core/controller/src/main/resources/apiv1swagger.json
##########
@@ -1910,6 +1910,13 @@
},
"description": "annotations on the item"
},
+ "delAnnotations": {
Review comment:
I wish we can have a better name for this.
But for now, I have no good idea.
##########
File path:
core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
##########
@@ -537,6 +537,14 @@ trait WhiskActionsApi extends WhiskCollectionAPI with
PostActionActivation with
val exec = content.exec getOrElse action.exec
+ var newAnnotations = action.annotations
Review comment:
I think we would not want to use the `var` variable.
Since the main target here is to remove items from `action.annotations`
which are in the `content.delAnnotations`, I think we can do something similar
to this:
```suggestion
val newAnnotations = content.delAnnotations.map { annotationArray =>
annotationArray.foldRight(action.annotations)((a: String, b:
Parameters) => b - a)
}.map( _ ++ content.annotations).getOrElse(content.annotations ++
action.annotations)
```
##########
File path: tests/src/test/scala/system/basic/WskActionTests.scala
##########
@@ -357,4 +357,39 @@ class WskActionTests extends TestHelpers with
WskTestHelpers with JsHelpers with
}
}
+ it should "not delete previous annotation when update action with new
annotation" in withAssetCleaner(wskprops) {
Review comment:
```suggestion
it should "not delete existing annotations when updating action with new
annotation" in withAssetCleaner(wskprops) {
```
##########
File path: core/controller/src/main/resources/apiv1swagger.json
##########
@@ -1910,6 +1910,13 @@
},
"description": "annotations on the item"
},
+ "delAnnotations": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "del annotations on the item"
Review comment:
```suggestion
"description": "The list of annotations to be deleted from the
item"
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]