@@ -13,10 +13,10 @@ import (
13
13
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
14
14
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
15
15
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
16
+ "k8s.io/kubernetes/pkg/kubectl/scheme"
16
17
kterm "k8s.io/kubernetes/pkg/kubectl/util/term"
17
18
18
19
"github.com/openshift/origin/pkg/cmd/util/term"
19
- "github.com/openshift/origin/pkg/oc/util/ocscheme"
20
20
)
21
21
22
22
// CreateBasicAuthSecretRecommendedCommandName represents name of subcommand for `oc secrets` command
@@ -64,7 +64,7 @@ type CreateBasicAuthSecretOptions struct {
64
64
65
65
func NewCreateBasicAuthSecretOptions (streams genericclioptions.IOStreams ) * CreateBasicAuthSecretOptions {
66
66
return & CreateBasicAuthSecretOptions {
67
- PrintFlags : genericclioptions .NewPrintFlags ("created" ).WithTypeSetter (ocscheme . PrintingInternalScheme ),
67
+ PrintFlags : genericclioptions .NewPrintFlags ("created" ).WithTypeSetter (scheme . Scheme ),
68
68
IOStreams : streams ,
69
69
}
70
70
}
@@ -105,7 +105,6 @@ func (o *CreateBasicAuthSecretOptions) Run() error {
105
105
if err != nil {
106
106
return err
107
107
}
108
-
109
108
if _ , err := o .SecretsInterface .Create (secret ); err != nil {
110
109
return err
111
110
}
@@ -154,10 +153,12 @@ func (o *CreateBasicAuthSecretOptions) Complete(f kcmdutil.Factory, args []strin
154
153
if len (args ) != 1 {
155
154
return errors .New ("must have exactly one argument: secret name" )
156
155
}
157
-
158
156
o .SecretName = args [0 ]
159
157
160
158
if o .PromptForPassword {
159
+ if len (o .Password ) > 0 {
160
+ return errors .New ("must provide either --prompt or --password flag" )
161
+ }
161
162
if ! kterm .IsTerminal (o .In ) {
162
163
return errors .New ("provided reader is not a terminal" )
163
164
}
@@ -168,16 +169,15 @@ func (o *CreateBasicAuthSecretOptions) Complete(f kcmdutil.Factory, args []strin
168
169
}
169
170
}
170
171
171
- config , err := f .ToRESTConfig ()
172
+ namespace , _ , err := f .ToRawKubeConfigLoader (). Namespace ()
172
173
if err != nil {
173
174
return err
174
175
}
175
-
176
- clientset , err := corev1client .NewForConfig (config )
176
+ config , err := f .ToRESTConfig ()
177
177
if err != nil {
178
178
return err
179
179
}
180
- namespace , _ , err := f . ToRawKubeConfigLoader (). Namespace ( )
180
+ clientset , err := corev1client . NewForConfig ( config )
181
181
if err != nil {
182
182
return err
183
183
}
@@ -196,14 +196,9 @@ func (o CreateBasicAuthSecretOptions) Validate() error {
196
196
if len (o .SecretName ) == 0 {
197
197
return errors .New ("basic authentication secret name must be present" )
198
198
}
199
-
200
199
if len (o .Username ) == 0 && len (o .Password ) == 0 {
201
200
return errors .New ("must provide basic authentication credentials" )
202
201
}
203
202
204
- if o .PromptForPassword && len (o .Password ) > 0 {
205
- return errors .New ("must provide either --prompt or --password flag" )
206
- }
207
-
208
203
return nil
209
204
}
0 commit comments