Skip to content

Commit

Permalink
cleanup some legacy client usage
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Aug 29, 2017
1 parent 02d694e commit 2f31964
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 141 deletions.
6 changes: 5 additions & 1 deletion pkg/cmd/util/clientcmd/factory_object_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,18 @@ func (f *ring1Factory) Describer(mapping *meta.RESTMapping) (kprinters.Describer
if err != nil {
return nil, fmt.Errorf("unable to create client %s: %v", mapping.GroupVersionKind.Kind, err)
}
clientConfig, err := f.clientAccessFactory.ClientConfig()
if err != nil {
return nil, fmt.Errorf("unable to create client config %s: %v", mapping.GroupVersionKind.Kind, err)
}

mappingVersion := mapping.GroupVersionKind.GroupVersion()
cfg, err := f.clientAccessFactory.ClientConfigForVersion(&mappingVersion)
if err != nil {
return nil, fmt.Errorf("unable to load a client %s: %v", mapping.GroupVersionKind.Kind, err)
}

describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), oClient, kClient, cfg.Host)
describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), clientConfig, oClient, kClient, cfg.Host)
if !ok {
return nil, fmt.Errorf("no description has been implemented for %q", mapping.GroupVersionKind.Kind)
}
Expand Down
22 changes: 17 additions & 5 deletions pkg/oc/cli/cmd/importimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
imageapi "github.com/openshift/origin/pkg/image/apis/image"
imageapiv1 "github.com/openshift/origin/pkg/image/apis/image/v1"
imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion"
"github.com/openshift/origin/pkg/oc/cli/describe"
)

Expand Down Expand Up @@ -90,10 +91,11 @@ type ImportImageOptions struct {
CommandName string

// helpers
out io.Writer
errout io.Writer
osClient client.Interface
isClient client.ImageStreamInterface
out io.Writer
errout io.Writer
osClient client.Interface
isClient client.ImageStreamInterface
imageClient imageclient.ImageInterface
}

// Complete turns a partially defined ImportImageOptions into a solvent structure
Expand Down Expand Up @@ -127,6 +129,16 @@ func (o *ImportImageOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
o.out = out
o.errout = errout

clientConfig, err := f.ClientConfig()
if err != nil {
return err
}
imageClient, err := imageclient.NewForConfig(clientConfig)
if err != nil {
return err
}
o.imageClient = imageClient

return nil
}

Expand Down Expand Up @@ -258,7 +270,7 @@ func (o *ImportImageOptions) Run() error {

fmt.Fprint(o.out, "The import completed successfully.\n\n")

d := describe.ImageStreamDescriber{Interface: o.osClient}
d := describe.ImageStreamDescriber{ImageClient: o.imageClient}
info, err := d.Describe(updatedStream.Namespace, updatedStream.Name, kprinters.DescriberSettings{})
if err != nil {
return err
Expand Down
Loading

0 comments on commit 2f31964

Please sign in to comment.