From ceb15f91872cbc7c68830c74a2e27d694a620e59 Mon Sep 17 00:00:00 2001 From: juanvallejo Date: Mon, 23 Jul 2018 17:43:38 -0400 Subject: [PATCH] update secret cmd to externals --- pkg/oc/cli/secrets/options.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/oc/cli/secrets/options.go b/pkg/oc/cli/secrets/options.go index ba77190b529d..94fe317c8484 100644 --- a/pkg/oc/cli/secrets/options.go +++ b/pkg/oc/cli/secrets/options.go @@ -8,11 +8,11 @@ import ( "os" "strings" + corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" - kapi "k8s.io/kubernetes/pkg/apis/core" - kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" + kcoreclientv1 "k8s.io/client-go/kubernetes/typed/core/v1" kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource" @@ -29,7 +29,7 @@ type SecretOptions struct { Namespace string BuilderFunc func() *resource.Builder - KubeCoreClient kcoreclient.CoreInterface + KubeCoreClient kcoreclientv1.CoreV1Interface Out io.Writer } @@ -49,7 +49,7 @@ func (o *SecretOptions) Complete(f kcmdutil.Factory, args []string) error { if err != nil { return err } - kubeClient, err := kcoreclient.NewForConfig(clientConfig) + kubeClient, err := kcoreclientv1.NewForConfig(clientConfig) if err != nil { return err } @@ -88,9 +88,9 @@ func (o SecretOptions) Validate() error { } // GetServiceAccount Retrieve the service account object specified by the command -func (o SecretOptions) GetServiceAccount() (*kapi.ServiceAccount, error) { +func (o SecretOptions) GetServiceAccount() (*corev1.ServiceAccount, error) { r := o.BuilderFunc(). - WithScheme(ocscheme.ReadingInternalScheme). + WithScheme(ocscheme.ReadingInternalScheme, ocscheme.ReadingInternalScheme.PrioritizedVersionsAllGroups()...). NamespaceParam(o.Namespace). ResourceNames("serviceaccounts", o.TargetName). SingleResourceType(). @@ -104,7 +104,7 @@ func (o SecretOptions) GetServiceAccount() (*kapi.ServiceAccount, error) { } switch t := obj.(type) { - case *kapi.ServiceAccount: + case *corev1.ServiceAccount: return t, nil default: return nil, fmt.Errorf("unhandled object: %#v", t) @@ -112,7 +112,7 @@ func (o SecretOptions) GetServiceAccount() (*kapi.ServiceAccount, error) { } // GetSecretNames Get a list of the names of the secrets in a set of them -func (o SecretOptions) GetSecretNames(secrets []*kapi.Secret) sets.String { +func (o SecretOptions) GetSecretNames(secrets []*corev1.Secret) sets.String { names := sets.String{} for _, secret := range secrets { names.Insert(parseSecretName(secret.Name)) @@ -133,7 +133,7 @@ func parseSecretName(name string) string { // GetMountSecretNames Get a list of the names of the mount secrets associated // with a service account -func (o SecretOptions) GetMountSecretNames(serviceaccount *kapi.ServiceAccount) sets.String { +func (o SecretOptions) GetMountSecretNames(serviceaccount *corev1.ServiceAccount) sets.String { names := sets.String{} for _, secret := range serviceaccount.Secrets { names.Insert(secret.Name) @@ -143,7 +143,7 @@ func (o SecretOptions) GetMountSecretNames(serviceaccount *kapi.ServiceAccount) // GetPullSecretNames Get a list of the names of the pull secrets associated // with a service account. -func (o SecretOptions) GetPullSecretNames(serviceaccount *kapi.ServiceAccount) sets.String { +func (o SecretOptions) GetPullSecretNames(serviceaccount *corev1.ServiceAccount) sets.String { names := sets.String{} for _, secret := range serviceaccount.ImagePullSecrets { names.Insert(secret.Name) @@ -162,8 +162,8 @@ func (o SecretOptions) GetOut() io.Writer { // GetSecrets Return a list of secret objects in the default namespace // If allowNonExisting is set to true, we will return the non-existing secrets as well. -func (o SecretOptions) GetSecrets(allowNonExisting bool) ([]*kapi.Secret, bool, error) { - secrets := []*kapi.Secret{} +func (o SecretOptions) GetSecrets(allowNonExisting bool) ([]*corev1.Secret, bool, error) { + secrets := []*corev1.Secret{} hasNotFound := false for _, secretName := range o.SecretNames { @@ -184,7 +184,7 @@ func (o SecretOptions) GetSecrets(allowNonExisting bool) ([]*kapi.Secret, bool, fmt.Fprintf(os.Stderr, "secret %q not found\n", secretName) hasNotFound = true if allowNonExisting { - obj = &kapi.Secret{ + obj = &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: secretName, }, @@ -197,7 +197,7 @@ func (o SecretOptions) GetSecrets(allowNonExisting bool) ([]*kapi.Secret, bool, } } switch t := obj.(type) { - case *kapi.Secret: + case *corev1.Secret: secrets = append(secrets, t) default: return nil, false, fmt.Errorf("unhandled object: %#v", t)