tysonnorris commented on a change in pull request #4935:
URL: https://github.com/apache/openwhisk/pull/4935#discussion_r468942130



##########
File path: 
core/controller/src/main/scala/org/apache/openwhisk/core/controller/Actions.scala
##########
@@ -338,6 +336,56 @@ trait WhiskActionsApi extends WhiskCollectionAPI with 
PostActionActivation with
     deleteEntity(WhiskAction, entityStore, entityName.toDocId, (a: 
WhiskAction) => Future.successful({}))
   }
 
+  /**GET --save which retrieves all source code for an entity **/
+  private def getEntityWithSourceCode(entityName: FullyQualifiedEntityName, 
env: Option[Parameters])(
+    implicit transid: TransactionId) = {
+    getEntity(WhiskAction.resolveActionAndMergeParameters(entityStore, 
entityName), Some { action: WhiskAction =>
+      val mergedAction = env map {
+        action inherit _
+      } getOrElse action
+      complete(OK, mergedAction)
+    })
+  }
+
+  /**Standard GET which just retrieves metadata**/
+  private def getEntityMetaData(entityName: FullyQualifiedEntityName, env: 
Option[Parameters])(
+    implicit transid: TransactionId) = {
+    getEntity(WhiskActionMetaData.resolveActionAndMergeParameters(entityStore, 
entityName), Some {
+      action: WhiskActionMetaData =>
+        val mergedAction = env map {
+          action inherit _
+        } getOrElse action
+        complete(OK, mergedAction)
+    })
+  }
+
+  /** Checks for package binding case. we don't want to allow get for a 
package binding in shared package */
+  private def fetchEntity(entityName: FullyQualifiedEntityName, env: 
Option[Parameters], code: Boolean)(
+    implicit transid: TransactionId) = {
+    if (entityName.path.defaultPackage) {
+      if (code) {
+        getEntityWithSourceCode(entityName, env)
+      } else {
+        getEntityMetaData(entityName, env)
+      }
+    } else {
+      getEntity(
+        WhiskPackage.resolveBinding(entityStore, entityName.path.toDocId, 
mergeParameters = true),

Review comment:
       is there a test for when a bound package goes missing? e.g.
   * create a package
   * create a shared package binding
   * create an action in the package
   * delete the package (not the binding)
   * get the action via the binding (should fail gracefully with whatever the 
same error is when getting the package binding when the original package is now 
gone)




----------------------------------------------------------------
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:
[email protected]


Reply via email to