Skip to content

Commit

Permalink
Do not delete previous annotation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ningyougang committed Aug 12, 2020
1 parent 35f1a3e commit 37f979b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ case class WhiskActionPut(exec: Option[Exec] = None,
limits: Option[ActionLimitsOption] = None,
version: Option[SemVer] = None,
publish: Option[Boolean] = None,
annotations: Option[Parameters] = None) {
annotations: Option[Parameters] = None,
delAnnotations: Option[Array[String]] = None) {

protected[core] def replace(exec: Exec) = {
WhiskActionPut(Some(exec), parameters, limits, version, publish, annotations)
Expand Down Expand Up @@ -643,5 +644,5 @@ object ActionLimitsOption extends DefaultJsonProtocol {
}

object WhiskActionPut extends DefaultJsonProtocol {
implicit val serdes = jsonFormat6(WhiskActionPut.apply)
implicit val serdes = jsonFormat7(WhiskActionPut.apply)
}
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with

val exec = content.exec getOrElse action.exec

var newAnnotations = action.annotations
content.delAnnotations.map { annotationArray =>
annotationArray.foreach { annotation =>
newAnnotations -= annotation
}
}
newAnnotations = newAnnotations ++ content.annotations

WhiskAction(
action.namespace,
action.name,
Expand All @@ -545,7 +553,7 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
limits,
content.version getOrElse action.version.upPatch,
content.publish getOrElse action.publish,
WhiskActionsApi.amendAnnotations(content.annotations getOrElse action.annotations, exec, create = false))
WhiskActionsApi.amendAnnotations(newAnnotations, exec, create = false))
.revision[WhiskAction](action.docinfo.rev)
}

Expand Down

0 comments on commit 37f979b

Please sign in to comment.