Skip to content

Commit 8a4e7b0

Browse files
committed
cleanup some legacy client usage
1 parent 02d694e commit 8a4e7b0

File tree

3 files changed

+131
-90
lines changed

3 files changed

+131
-90
lines changed

pkg/cmd/util/clientcmd/factory_object_mapping.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,18 @@ func (f *ring1Factory) Describer(mapping *meta.RESTMapping) (kprinters.Describer
145145
if err != nil {
146146
return nil, fmt.Errorf("unable to create client %s: %v", mapping.GroupVersionKind.Kind, err)
147147
}
148+
clientConfig, err := f.clientAccessFactory.ClientConfig()
149+
if err != nil {
150+
return nil, fmt.Errorf("unable to create client config %s: %v", mapping.GroupVersionKind.Kind, err)
151+
}
148152

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

155-
describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), oClient, kClient, cfg.Host)
159+
describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), clientConfig, oClient, kClient, cfg.Host)
156160
if !ok {
157161
return nil, fmt.Errorf("no description has been implemented for %q", mapping.GroupVersionKind.Kind)
158162
}

pkg/oc/cli/cmd/importimage.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
2222
imageapi "github.com/openshift/origin/pkg/image/apis/image"
2323
imageapiv1 "github.com/openshift/origin/pkg/image/apis/image/v1"
24+
imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion"
2425
"github.com/openshift/origin/pkg/oc/cli/describe"
2526
)
2627

@@ -90,10 +91,11 @@ type ImportImageOptions struct {
9091
CommandName string
9192

9293
// helpers
93-
out io.Writer
94-
errout io.Writer
95-
osClient client.Interface
96-
isClient client.ImageStreamInterface
94+
out io.Writer
95+
errout io.Writer
96+
osClient client.Interface
97+
isClient client.ImageStreamInterface
98+
imageClient imageclient.ImageInterface
9799
}
98100

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

132+
clientConfig, err := f.ClientConfig()
133+
if err != nil {
134+
return err
135+
}
136+
imageClient, err := imageclient.NewForConfig(clientConfig)
137+
if err != nil {
138+
return err
139+
}
140+
o.imageClient = imageClient
141+
130142
return nil
131143
}
132144

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

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

261-
d := describe.ImageStreamDescriber{Interface: o.osClient}
273+
d := describe.ImageStreamDescriber{ImageClient: o.imageClient}
262274
info, err := d.Describe(updatedStream.Namespace, updatedStream.Name, kprinters.DescriberSettings{})
263275
if err != nil {
264276
return err

0 commit comments

Comments
 (0)