Skip to content

Commit 6563891

Browse files
author
Matthew Fisher
committed
ref(cmd): clarify deis registry usage
1 parent 848b3a6 commit 6563891

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

cmd/registry.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ func parseInfo(item string) (string, string, error) {
124124
parts := strings.SplitN(item, "=", 2)
125125

126126
if len(parts) != 2 {
127-
return "", "", fmt.Errorf(`%s is invalid, Must be in format key=value
127+
return "", "", fmt.Errorf(`%s is invalid. Must be in format key=value
128128
Examples: username=bob password=s3cur3pw1`, item)
129129
}
130130

131+
if parts[0] != "username" && parts[0] != "password" {
132+
return "", "", fmt.Errorf(`%s is invalid. Valid keys are "username" or "password".`, parts[0])
133+
}
134+
131135
return parts[0], parts[1], nil
132136
}

cmd/registry_test.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,22 @@ import "testing"
55
func TestParseInfo(t *testing.T) {
66
t.Parallel()
77

8-
// Regression test for passwords with equals signs, such as a gcr.io token
9-
key := `password=ihaveanequalssign=`
10-
if _, _, err := parseInfo(key); err != nil {
11-
t.Errorf("failed to parse valid token with equals sign: got (%s)", err)
8+
// keys can only be username or password
9+
goodKeys := []string{
10+
"username=bob",
11+
"password=isyouruncle",
12+
// regression test for passwords with equals signs, such as a gcr.io token
13+
"password=ihaveanequalssign=",
14+
}
15+
16+
for _, key := range goodKeys {
17+
if _, _, err := parseInfo(key); err != nil {
18+
t.Errorf("failed parsing valid keys, got (%s)", err)
19+
}
20+
}
21+
22+
badKey := "usrname=bob"
23+
if _, _, err := parseInfo(badKey); err == nil {
24+
t.Errorf("failed erroring on bad key '%s'", badKey)
1225
}
1326
}

parser/registry.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ Options:
6161

6262
func registrySet(argv []string) error {
6363
usage := `
64-
Sets registry information for an application.
65-
66-
key/value pairs used to configure / authenticate against external registries
64+
Sets registry information for an application. These credentials are the same as those used for
65+
'docker login' to the private registry.
6766
6867
Usage: deis registry:set [options] <key>=<value>...
6968
7069
Arguments:
71-
<key> the registry key, for example: "username" or "password"
72-
<value> the registry value, for example: "bob" or "s3cur3pw1"
70+
<key>
71+
the uniquely identifiable name for logging into the registry. Valid keys are "username" or
72+
"password"
73+
<value>
74+
the value of said environment variable. For example, "bob" or "mysecretpassword"
7375
7476
Options:
7577
-a --app=<app>

0 commit comments

Comments
 (0)