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



##########
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:
       I think this is a little scary to delete all versions if a version 
accidentally isn't supplied. Should there be a delete all parameter flag 
otherwise return an error?
   
   Also is it possible that you have a list of versions and then from backwards 
compatibility still have an action with no version? Does that result in the 
action with no version to get left over after the delete?




----------------------------------------------------------------
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