Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove usage of legacy client in oc describers #16041

Merged
merged 1 commit into from
Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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