-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Do not delete previous annotation and support delete annotation via CLI #4940
Do not delete previous annotation and support delete annotation via CLI #4940
Conversation
941ca44
to
37f979b
Compare
60334a2
to
24ee986
Compare
Please ignore blow content due to There has one test case run failed: I tried to find the root reason but failed, below is my steps of find the reason for delete annotation, in my local, after click idea's But for my test case in this pr: two key error log is:
Someone konws the reason? |
24ee986
to
b8e2bce
Compare
@@ -1910,6 +1910,13 @@ | |||
}, | |||
"description": "annotations on the item" | |||
}, | |||
"delAnnotations": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we can have a better name for this.
But for now, I have no good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... regarding better name
, i have no idea for this as well.
"items": { | ||
"type": "string" | ||
}, | ||
"description": "del annotations on the item" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "del annotations on the item" | |
"description": "The list of annotations to be deleted from the item" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated accordingly
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should "not delete previous annotation when update action with new annotation" in withAssetCleaner(wskprops) { | |
it should "not delete existing annotations when updating action with new annotation" in withAssetCleaner(wskprops) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated accordingly
@@ -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) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should "update an action via passing delAnnotations" in withAssetCleaner(wskprops) { (wp, assetHelper) => | |
it should "delete the given annotations using delAnnotations" in withAssetCleaner(wskprops) { (wp, assetHelper) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated accordingly
@@ -537,6 +537,14 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with | |||
|
|||
val exec = content.exec getOrElse action.exec | |||
|
|||
var newAnnotations = action.annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
var newAnnotations = action.annotations | |
val newAnnotations = content.delAnnotations.map { annotationArray => | |
annotationArray.foldRight(action.annotations)((a: String, b: Parameters) => b - a) | |
}.map( _ ++ content.annotations).getOrElse(action.annotations ++ content.annotations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated accordingly
Currently, if passing another annotations, original previous annotation will be removed and the passed new annotations will be added. It may give users some confused that why my previous annotation gone. So it is better to not delete user's previous annotation when adding new annotation, but at the same time, need to provide a feature that support to delete annotation by user via ClI, e.g. wsk action update hello --del-annotation key1 --del-annotation key2 CLI side needs to support as well
5a5f527
to
3557896
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ningyougang @style95 i'm curious why this was implemented for annotations only and not parameters (delete individual parameters). Should we extend the functionality to include parameters? |
@rabbah That sounds good to me. |
@rabbah ,oh, i forgot to support |
That's great! Thank you. |
Currently, if passing another annotations, original previous annotation
will be removed and the passed new annotations will be added.
It may give users some confused that why my previous annotation gone.
So it is better to not delete user's previous annotation when adding new
annotation, but at the same time, need to provide a feature that
support to delete annotation by user via ClI, e.g.
CLI side needs to support as well in this pr:
After all above 3 prs merged, supported
when update action with new annotation, the previous old annotation will not be deleted
if want to delete some annotations, user can execute below command via CLI
support pass multiple keys in one line.
Description
Related issue and scope
My changes affect the following components
Types of changes
Checklist: