You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/19 09:24:55 UTC

[GitHub] markusthoemmes commented on a change in pull request #3298: Attempt to resolve action name from conductor to a fully qualified name for added convenience.

markusthoemmes commented on a change in pull request #3298: Attempt to resolve action name from conductor to a fully qualified name for added convenience.
URL: https://github.com/apache/incubator-openwhisk/pull/3298#discussion_r169020141
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/core/entity/FullyQualifiedEntityName.scala
 ##########
 @@ -96,4 +96,36 @@ protected[core] object FullyQualifiedEntityName extends DefaultJsonProtocol {
         case Failure(t)                           => deserializationError("fully qualified name malformed")
       }
   }
+
+  /**
+   * Converts the name to a fully qualified name.
+   * There are 3 cases:
+   * - name is not a valid EntityPath => error
+   * - name is a valid single segment with a leading slash => error
+   * - name is a valid single segment without a leading slash => map it to user namespace, default package
+   * - name is a valid multi segment with a leading slash => treat it as fully qualified name (max segments allowed: 3)
+   * - name is a valid multi segment without a leading slash => treat it as package name and resolve it to the user namespace (max segments allowed: 3)
+   *
+   * The last case is ambiguous as '/namespace/action' and 'package/action' will be the same EntityPath value.
+   * The action should use a fully qualified result to avoid the ambiguity.
+   *
+   * @param name name of the action to fully qualify
+   * @param namespace the user namespace for the simple resolution
+   * @return Some(FullyQualifiedName) if the name is valid otherwise None
+   */
+  protected[core] def resolveName(name: JsValue, namespace: EntityName): Option[FullyQualifiedEntityName] = {
+    name match {
+      case v @ JsString(s) =>
+        Try(v.convertTo[EntityPath]).toOption
 
 Review comment:
   Is the nested matching needed? Why not directly go with `Try(name.convertTo[EntityPath])`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services