Repository: apigee/registry (go)

Issue:
Registry tool: problem setting token-source
```
registry config set token-source 'echo mytoken'
Error: unknown property: "token-source".
Usage:
  registry config set PROPERTY VALUE [flags]

Examples:
registry config set registry.address localhost:8080
registry config set token-source 'gcloud auth print-access-token email@example.com'

Flags:
  -h, --help   help for set

Global Flags:
      --address string             the server and port of the Registry API (eg. localhost:8080)
  -c, --config string              name of a configuration profile or path to config file
      --registry.address string    the server and port of the Registry API (eg. localhost:8080)
      --registry.insecure          if specified, client connects via http (not https)
      --registry.location string   the API Registry location
      --registry.project string    the API Registry project
      --registry.token string      the token to use for authorization to the API Registry

----
Need more help?
https://github.com/apigee/registry/wiki
```

Pull request description:
fix token-source config prop
Fixes #1102

Patch:
diff --git a/pkg/config/configuration.go b/pkg/config/configuration.go
index 7646b0f..2621a0c 100644
--- a/pkg/config/configuration.go
+++ b/pkg/config/configuration.go
@@ -76,7 +76,7 @@ func (c Configuration) Validate() error {
 // ValidateProperty returns an UnknownPropertyError if not a valid property.
 func (c Configuration) ValidateProperty(k string) error {
 	kNS := k
-	if !strings.Contains(k, ".") {
+	if !strings.Contains(k, ".") && k != "token-source" {
 		kNS = default_namespace + "." + kNS
 	}
 	for _, p := range c.Properties() {
@@ -108,7 +108,7 @@ func (c *Configuration) Set(k string, v interface{}) error {
 	if err := c.ValidateProperty(k); err != nil {
 		return err
 	}
-	if !strings.Contains(k, ".") {
+	if !strings.Contains(k, ".") && k != "token-source" {
 		k = default_namespace + "." + k
 	}
 	return c.FromMap(map[string]interface{}{
@@ -121,7 +121,7 @@ func (c *Configuration) Unset(k string) error {
 	if err := c.ValidateProperty(k); err != nil {
 		return err
 	}
-	if !strings.Contains(k, ".") {
+	if !strings.Contains(k, ".") && k != "token-source" {
 		k = default_namespace + "." + k
 	}
 	return c.FromMap(map[string]interface{}{
@@ -138,7 +138,7 @@ func (c *Configuration) Get(k string) (interface{}, error) {
 	if err != nil {
 		return "", fmt.Errorf("cannot decode config: %v", err)
 	}
-	if !strings.Contains(k, ".") {
+	if !strings.Contains(k, ".") && k != "token-source" {
 		k = default_namespace + "." + k
 	}
 	return m[k], nil


Test patch:
diff --git a/pkg/config/configuration_test.go b/pkg/config/configuration_test.go
index 490b9dc..4a80680 100644
--- a/pkg/config/configuration_test.go
+++ b/pkg/config/configuration_test.go
@@ -318,6 +318,25 @@ func TestManipulations(t *testing.T) {
 	if diff := cmp.Diff(want, m); diff != "" {
 		t.Fatalf("unexpected diff: (-want +got):\n%s", diff)
 	}
+
+	if err = c.Set("token-source", "source"); err != nil {
+		t.Fatal(err)
+	}
+	if m, err = c.FlatMap(); err != nil {
+		t.Fatal(err)
+	}
+	want["token-source"] = "source"
+	if diff := cmp.Diff(want, m); diff != "" {
+		t.Fatalf("unexpected diff: (-want +got):\n%s", diff)
+	}
+
+	ts, err := c.Get("token-source")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if ts != "source" {
+		t.Errorf("want: %s, got: %s", "source", l)
+	}
 }
 
 func TestAllConfigs(t *testing.T) {