Skip to content

Commit

Permalink
update secret cmd to externals
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Jul 23, 2018
1 parent 559e365 commit ceb15f9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pkg/oc/cli/secrets/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -29,7 +29,7 @@ type SecretOptions struct {
Namespace string

BuilderFunc func() *resource.Builder
KubeCoreClient kcoreclient.CoreInterface
KubeCoreClient kcoreclientv1.CoreV1Interface

Out io.Writer
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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().
Expand All @@ -104,15 +104,15 @@ 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)
}
}

// 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))
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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,
},
Expand All @@ -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)
Expand Down

0 comments on commit ceb15f9

Please sign in to comment.