Browse code

Merge pull request #4805 from jhadvig/bugs

Merged by openshift-bot

OpenShift Bot authored on 2015/09/30 00:53:30
Showing 3 changed files
... ...
@@ -22,7 +22,7 @@ const (
22 22
 	createBasicAuthSecretLong = `
23 23
 Create a new basic authentication secret
24 24
 
25
-Basic authenticate secrets are used to authenticate against SCM servers.
25
+Basic authentication secrets are used to authenticate against SCM servers.
26 26
 
27 27
 When creating applications, you may have a SCM server that requires basic authentication - username, password.
28 28
 In order for the nodes to clone source code on your behalf, they have to have the credentials. You can provide 
... ...
@@ -62,7 +62,7 @@ func NewCmdCreateBasicAuthSecret(name, fullName string, f *kcmdutil.Factory, rea
62 62
 	}
63 63
 
64 64
 	cmd := &cobra.Command{
65
-		Use:     fmt.Sprintf("%s SECRET_NAME --username=USERNAME --password=PASSWORD [--ca-cert=FILENAME --gitconfig=FILENAME]", name),
65
+		Use:     fmt.Sprintf("%s SECRET --username=USERNAME --password=PASSWORD [--ca-cert=FILENAME] [--gitconfig=FILENAME]", name),
66 66
 		Short:   "Create a new secret for basic authentication",
67 67
 		Long:    createBasicAuthSecretLong,
68 68
 		Example: fmt.Sprintf(createBasicAuthSecretExample, fullName, newSecretFullName, ocEditFullName),
... ...
@@ -162,6 +162,20 @@ func (o *CreateBasicAuthSecretOptions) Complete(f *kcmdutil.Factory, args []stri
162 162
 	}
163 163
 	o.SecretName = args[0]
164 164
 
165
+	if o.PromptForPassword {
166
+		if len(o.Password) != 0 {
167
+			return errors.New("must provide either --prompt or --password flag")
168
+		}
169
+		if !cmdutil.IsTerminal(o.Reader) {
170
+			return errors.New("provided reader is not a terminal")
171
+		}
172
+
173
+		o.Password = cmdutil.PromptForPasswordString(o.Reader, o.Out, "Password: ")
174
+		if len(o.Password) == 0 {
175
+			return errors.New("password must be provided")
176
+		}
177
+	}
178
+
165 179
 	if f != nil {
166 180
 		client, err := f.Client()
167 181
 		if err != nil {
... ...
@@ -183,22 +197,8 @@ func (o CreateBasicAuthSecretOptions) Validate() error {
183 183
 		return errors.New("basic authentication secret name must be present")
184 184
 	}
185 185
 
186
-	if o.PromptForPassword {
187
-		if len(o.Password) != 0 {
188
-			return errors.New("must provide either --prompt or --password flag")
189
-		}
190
-		if cmdutil.IsTerminal(o.Reader) {
191
-			o.Password = cmdutil.PromptForPasswordString(o.Reader, o.Out, "Password: ")
192
-			if len(o.Password) == 0 {
193
-				return errors.New("password must be provided")
194
-			}
195
-		} else {
196
-			return errors.New("provided reader is not a terminal")
197
-		}
198
-	} else {
199
-		if len(o.Username) == 0 && len(o.Password) == 0 && len(o.CertificatePath) == 0 {
200
-			return errors.New("must provide basic authentication credentials")
201
-		}
186
+	if len(o.Username) == 0 && len(o.Password) == 0 {
187
+		return errors.New("must provide basic authentication credentials")
202 188
 	}
203 189
 
204 190
 	return nil
... ...
@@ -60,7 +60,7 @@ func NewCmdCreateDockerConfigSecret(name, fullName string, f *cmdutil.Factory, o
60 60
 	o := &CreateDockerConfigOptions{Out: out}
61 61
 
62 62
 	cmd := &cobra.Command{
63
-		Use:     fmt.Sprintf("%s SECRET_NAME --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL", name),
63
+		Use:     fmt.Sprintf("%s SECRET --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL", name),
64 64
 		Short:   "Create a new dockercfg secret",
65 65
 		Long:    createDockercfgLong,
66 66
 		Example: fmt.Sprintf(createDockercfgExample, fullName, newSecretFullName, ocEditFullName),
... ...
@@ -57,7 +57,7 @@ func NewCmdCreateSSHAuthSecret(name, fullName string, f *kcmdutil.Factory, out i
57 57
 	}
58 58
 
59 59
 	cmd := &cobra.Command{
60
-		Use:     fmt.Sprintf("%s SECRET_NAME --ssh-privatekey=FILENAME [--ca-cert=FILENAME] [--gitconfig=FILENAME]", name),
60
+		Use:     fmt.Sprintf("%s SECRET --ssh-privatekey=FILENAME [--ca-cert=FILENAME] [--gitconfig=FILENAME]", name),
61 61
 		Short:   "Create a new secret for SSH authentication",
62 62
 		Long:    createSSHAuthSecretLong,
63 63
 		Example: fmt.Sprintf(createSSHAuthSecretExample, fullName, newSecretFullName, ocEditFullName),