jiangpengcheng commented on a change in pull request #4986:
URL: https://github.com/apache/openwhisk/pull/4986#discussion_r511686626



##########
File path: 
core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
##########
@@ -333,12 +372,74 @@ trait WhiskActionsApi extends WhiskCollectionAPI with 
PostActionActivation with
    * - 500 Internal Server Error
    */
   override def remove(user: Identity, entityName: 
FullyQualifiedEntityName)(implicit transid: TransactionId) = {
-    deleteEntity(WhiskAction, entityStore, entityName.toDocId, (a: 
WhiskAction) => Future.successful({}))
+    parameter('version.as[SemVer] ?) { version =>
+      onComplete(WhiskActionVersionList.get(entityName, entityStore)) {
+        case Success(results) =>
+          version match {
+            case Some(_) =>
+              val docId = 
results.matchedDocId(version).getOrElse(entityName.toDocId)
+              deleteEntity(
+                WhiskAction,
+                entityStore,
+                docId,
+                (a: WhiskAction) => Future.successful({}),
+                postProcess = Some { action: WhiskAction =>
+                  WhiskActionVersionList.deleteCache(entityName)
+                  complete(OK, action)
+                })
+            case None =>
+              val fs =
+                if (results.versions.isEmpty)
+                  Seq(WhiskAction.get(entityStore, entityName.toDocId) flatMap 
{ entity =>
+                    WhiskAction.del(entityStore, entity.docinfo).map(_ => 
entity)
+                  })
+                else
+                  results.versions.values

Review comment:
       ok
   
   since it will fetch a version-id mappings at first, so even for action with 
no version, we can get the id of it and delete action by id




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to