Skip to content

Commit

Permalink
Allow FQN with 3 parts (namespace/package/action) to be input with/wi…
Browse files Browse the repository at this point in the history
…thout leading slash '/'
  • Loading branch information
underwoodb-sd-ibm committed Jun 26, 2017
1 parent fb274f7 commit 7085175
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/cli/go-whisk-cli/commands/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ Examples:
func parseQualifiedName(name string) (QualifiedName, error) {
var qualifiedName QualifiedName

// If name has a preceding delimiter (/), it contains a namespace. Otherwise the name does not specify a namespace,
// so default the namespace to the namespace value set in the properties file; if that is not set, use "_"
// If name has a preceding delimiter (/), or if it has two delimiters with a leading non-empty string, then
// it contains a namespace. Otherwise the name does not specify a namespace, so default the namespace to the
// namespace value set in the properties file; if that is not set, use "_"
parts := strings.Split(name, "/")
if len(parts) == 3 && parts[0] != "" {
name = "/" + name
}
if strings.HasPrefix(name, "/") {
parts := strings.Split(name, "/")
parts = strings.Split(name, "/")
qualifiedName.namespace = parts[1]

if len(parts) < 2 || len(parts) > 4 {
Expand Down Expand Up @@ -112,7 +117,7 @@ func parseQualifiedName(name string) (QualifiedName, error) {
return qualifiedName, err
}

parts := strings.Split(name, "/")
parts = strings.Split(name, "/")
qualifiedName.entity = parts[len(parts)-1]
if len(parts) == 2 {
qualifiedName.packageName = parts[0]
Expand Down

0 comments on commit 7085175

Please sign in to comment.