Skip to content

Commit 83f2f15

Browse files
committed
Change scheme to kubectl and fix test-cmd
1 parent 6459805 commit 83f2f15

8 files changed

+17
-40
lines changed

pkg/oc/cli/debug/debug.go

-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ func (o *DebugOptions) transformPodForDebug(annotations map[string]string) (*cor
589589

590590
// identify the command to be run
591591
originalCommand, _ := o.getContainerImageCommand(pod, container)
592-
//originalCommand := []string{"<image entrypoint>"}
593592
if len(container.Command) > 0 {
594593
originalCommand = container.Command
595594
originalCommand = append(originalCommand, container.Args...)

pkg/oc/cli/secrets/basicauth.go

+8-13
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1414
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
1515
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
16+
"k8s.io/kubernetes/pkg/kubectl/scheme"
1617
kterm "k8s.io/kubernetes/pkg/kubectl/util/term"
1718

1819
"github.com/openshift/origin/pkg/cmd/util/term"
19-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
2020
)
2121

2222
// CreateBasicAuthSecretRecommendedCommandName represents name of subcommand for `oc secrets` command
@@ -64,7 +64,7 @@ type CreateBasicAuthSecretOptions struct {
6464

6565
func NewCreateBasicAuthSecretOptions(streams genericclioptions.IOStreams) *CreateBasicAuthSecretOptions {
6666
return &CreateBasicAuthSecretOptions{
67-
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(ocscheme.PrintingInternalScheme),
67+
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
6868
IOStreams: streams,
6969
}
7070
}
@@ -105,7 +105,6 @@ func (o *CreateBasicAuthSecretOptions) Run() error {
105105
if err != nil {
106106
return err
107107
}
108-
109108
if _, err := o.SecretsInterface.Create(secret); err != nil {
110109
return err
111110
}
@@ -154,10 +153,12 @@ func (o *CreateBasicAuthSecretOptions) Complete(f kcmdutil.Factory, args []strin
154153
if len(args) != 1 {
155154
return errors.New("must have exactly one argument: secret name")
156155
}
157-
158156
o.SecretName = args[0]
159157

160158
if o.PromptForPassword {
159+
if len(o.Password) > 0 {
160+
return errors.New("must provide either --prompt or --password flag")
161+
}
161162
if !kterm.IsTerminal(o.In) {
162163
return errors.New("provided reader is not a terminal")
163164
}
@@ -168,16 +169,15 @@ func (o *CreateBasicAuthSecretOptions) Complete(f kcmdutil.Factory, args []strin
168169
}
169170
}
170171

171-
config, err := f.ToRESTConfig()
172+
namespace, _, err := f.ToRawKubeConfigLoader().Namespace()
172173
if err != nil {
173174
return err
174175
}
175-
176-
clientset, err := corev1client.NewForConfig(config)
176+
config, err := f.ToRESTConfig()
177177
if err != nil {
178178
return err
179179
}
180-
namespace, _, err := f.ToRawKubeConfigLoader().Namespace()
180+
clientset, err := corev1client.NewForConfig(config)
181181
if err != nil {
182182
return err
183183
}
@@ -196,14 +196,9 @@ func (o CreateBasicAuthSecretOptions) Validate() error {
196196
if len(o.SecretName) == 0 {
197197
return errors.New("basic authentication secret name must be present")
198198
}
199-
200199
if len(o.Username) == 0 && len(o.Password) == 0 {
201200
return errors.New("must provide basic authentication credentials")
202201
}
203202

204-
if o.PromptForPassword && len(o.Password) > 0 {
205-
return errors.New("must provide either --prompt or --password flag")
206-
}
207-
208203
return nil
209204
}

pkg/oc/cli/secrets/basicauth_test.go

-12
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ func TestValidateBasicAuth(t *testing.T) {
6767
},
6868
expErr: true, //"Must provide basic authentication credentials"
6969
},
70-
{
71-
testName: "passwordAndPrompt",
72-
options: func(streams genericclioptions.IOStreams) *CreateBasicAuthSecretOptions {
73-
o := NewCreateBasicAuthSecretOptions(streams)
74-
o.Username = "testUser"
75-
o.Password = "testPassword"
76-
o.SecretName = "testSecret"
77-
o.PromptForPassword = true
78-
return o
79-
},
80-
expErr: true, //"Must provide either --prompt or --password flag"
81-
},
8270
}
8371

8472
for _, test := range tests {

pkg/oc/cli/secrets/dockercfg.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88

99
"github.com/spf13/cobra"
1010

11-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
1211
corev1 "k8s.io/api/core/v1"
1312
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
1413
"k8s.io/kubernetes/pkg/credentialprovider"
1514
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
1615
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1716
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
1817
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
18+
"k8s.io/kubernetes/pkg/kubectl/scheme"
1919
)
2020

2121
const CreateDockerConfigSecretRecommendedName = "new-dockercfg"
@@ -67,7 +67,7 @@ type CreateDockerConfigOptions struct {
6767

6868
func NewCreateDockerConfigOptions(streams genericclioptions.IOStreams) *CreateDockerConfigOptions {
6969
return &CreateDockerConfigOptions{
70-
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(ocscheme.PrintingInternalScheme),
70+
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
7171
IOStreams: streams,
7272
}
7373
}

pkg/oc/cli/secrets/new.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import (
1818
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1919
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
2020
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
21-
22-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
21+
"k8s.io/kubernetes/pkg/kubectl/scheme"
2322
)
2423

2524
const NewSecretRecommendedCommandName = "new"
@@ -76,7 +75,7 @@ type CreateSecretOptions struct {
7675

7776
func NewCreateSecretOptions(streams genericclioptions.IOStreams) *CreateSecretOptions {
7877
return &CreateSecretOptions{
79-
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(ocscheme.PrintingInternalScheme),
78+
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
8079
IOStreams: streams,
8180
}
8281
}

pkg/oc/cli/secrets/options.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1515
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"
1616
"k8s.io/kubernetes/pkg/kubectl/scheme"
17-
18-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
1917
)
2018

2119
// SecretOptions Structure holding state for processing secret linking and
@@ -155,7 +153,7 @@ func (o SecretOptions) GetSecrets(allowNonExisting bool) ([]*corev1.Secret, bool
155153

156154
for _, secretName := range o.SecretNames {
157155
r := o.BuilderFunc().
158-
WithScheme(ocscheme.ReadingInternalScheme, ocscheme.ReadingInternalScheme.PrioritizedVersionsAllGroups()...).
156+
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
159157
NamespaceParam(o.Namespace).
160158
ResourceNames("secrets", secretName).
161159
SingleResourceType().

pkg/oc/cli/secrets/sshauth.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import (
1313
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1414
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
1515
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
16-
17-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
16+
"k8s.io/kubernetes/pkg/kubectl/scheme"
1817
)
1918

2019
// CreateSSHAuthSecretRecommendedCommandName represents name of subcommand for `oc secrets` command
@@ -61,7 +60,7 @@ type CreateSSHAuthSecretOptions struct {
6160

6261
func NewCreateSSHAuthSecretOptions(streams genericclioptions.IOStreams) *CreateSSHAuthSecretOptions {
6362
return &CreateSSHAuthSecretOptions{
64-
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(ocscheme.PrintingInternalScheme),
63+
PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
6564
IOStreams: streams,
6665
}
6766
}

pkg/oc/cli/secrets/unlink_secret_from_object.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import (
1111
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
1212
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
1313
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers"
14-
15-
"github.com/openshift/origin/pkg/oc/util/ocscheme"
14+
"k8s.io/kubernetes/pkg/kubectl/scheme"
1615
)
1716

1817
const UnlinkSecretRecommendedName = "unlink"
@@ -39,7 +38,7 @@ type UnlinkSecretOptions struct {
3938

4039
func NewUnlinkSecretOptions(streams genericclioptions.IOStreams) *UnlinkSecretOptions {
4140
return &UnlinkSecretOptions{
42-
PrintFlags: genericclioptions.NewPrintFlags("updated").WithTypeSetter(ocscheme.PrintingInternalScheme),
41+
PrintFlags: genericclioptions.NewPrintFlags("updated").WithTypeSetter(scheme.Scheme),
4342
SecretOptions: SecretOptions{},
4443
IOStreams: streams,
4544
}

0 commit comments

Comments
 (0)