Skip to content

Commit 188944c

Browse files
committed
Do not delete previous annotation
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
1 parent 138ac18 commit 188944c

File tree

2 files changed

+12
-3
lines changed
  • common/scala/src/main/scala/org/apache/openwhisk/core/entity
  • core/controller/src/main/scala/org/apache/openwhisk/core/controller

2 files changed

+12
-3
lines changed

common/scala/src/main/scala/org/apache/openwhisk/core/entity/WhiskAction.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ case class WhiskActionPut(exec: Option[Exec] = None,
5656
limits: Option[ActionLimitsOption] = None,
5757
version: Option[SemVer] = None,
5858
publish: Option[Boolean] = None,
59-
annotations: Option[Parameters] = None) {
59+
annotations: Option[Parameters] = None,
60+
delAnnotations: Option[Array[String]] = None) {
6061

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

645646
object WhiskActionPut extends DefaultJsonProtocol {
646-
implicit val serdes = jsonFormat6(WhiskActionPut.apply)
647+
implicit val serdes = jsonFormat7(WhiskActionPut.apply)
647648
}

core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala

+9-1
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,14 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
537537

538538
val exec = content.exec getOrElse action.exec
539539

540+
var newAnnotations = action.annotations
541+
content.delAnnotations.map { annotationArray =>
542+
annotationArray.foreach { annotation =>
543+
newAnnotations -= annotation
544+
}
545+
}
546+
newAnnotations = newAnnotations ++ content.annotations
547+
540548
WhiskAction(
541549
action.namespace,
542550
action.name,
@@ -545,7 +553,7 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
545553
limits,
546554
content.version getOrElse action.version.upPatch,
547555
content.publish getOrElse action.publish,
548-
WhiskActionsApi.amendAnnotations(content.annotations getOrElse action.annotations, exec, create = false))
556+
WhiskActionsApi.amendAnnotations(newAnnotations, exec, create = false))
549557
.revision[WhiskAction](action.docinfo.rev)
550558
}
551559

0 commit comments

Comments
 (0)