Skip to content

Commit bcfcefd

Browse files
committed
remove last traces of oapi
1 parent 0e768b6 commit bcfcefd

File tree

2 files changed

+4
-63
lines changed

2 files changed

+4
-63
lines changed

pkg/oc/cli/util/clientcmd/factory_builder.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525
)
2626

2727
type ring2Factory struct {
28-
clientAccessFactory ClientAccessFactory
28+
clientAccessFactory kcmdutil.ClientAccessFactory
2929
objectMappingFactory kcmdutil.ObjectMappingFactory
3030
kubeBuilderFactory kcmdutil.BuilderFactory
3131
}
3232

33-
func NewBuilderFactory(clientAccessFactory ClientAccessFactory, objectMappingFactory kcmdutil.ObjectMappingFactory) kcmdutil.BuilderFactory {
33+
func NewBuilderFactory(clientAccessFactory kcmdutil.ClientAccessFactory, objectMappingFactory kcmdutil.ObjectMappingFactory) kcmdutil.BuilderFactory {
3434
return &ring2Factory{
3535
clientAccessFactory: clientAccessFactory,
3636
objectMappingFactory: objectMappingFactory,

pkg/oc/cli/util/clientcmd/factory_object_mapping.go

+2-61
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
"k8s.io/apimachinery/pkg/labels"
1313
"k8s.io/apimachinery/pkg/runtime"
14-
"k8s.io/client-go/dynamic"
1514
restclient "k8s.io/client-go/rest"
1615
kapi "k8s.io/kubernetes/pkg/apis/core"
1716
"k8s.io/kubernetes/pkg/controller"
@@ -23,7 +22,6 @@ import (
2322
"k8s.io/kubernetes/pkg/kubectl/validation"
2423
kprinters "k8s.io/kubernetes/pkg/printers"
2524

26-
"github.com/openshift/origin/pkg/api/latest"
2725
appsapi "github.com/openshift/origin/pkg/apps/apis/apps"
2826
appsmanualclient "github.com/openshift/origin/pkg/apps/client/internalversion"
2927
appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset"
@@ -33,18 +31,16 @@ import (
3331
buildmanualclient "github.com/openshift/origin/pkg/build/client/internalversion"
3432
buildclientinternal "github.com/openshift/origin/pkg/build/generated/internalclientset"
3533
buildutil "github.com/openshift/origin/pkg/build/util"
36-
configcmd "github.com/openshift/origin/pkg/bulk"
3734
imageapi "github.com/openshift/origin/pkg/image/apis/image"
3835
deploymentcmd "github.com/openshift/origin/pkg/oc/cli/deploymentconfigs"
39-
"github.com/openshift/origin/pkg/oc/cli/describe"
4036
)
4137

4238
type ring1Factory struct {
43-
clientAccessFactory ClientAccessFactory
39+
clientAccessFactory kcmdutil.ClientAccessFactory
4440
kubeObjectMappingFactory kcmdutil.ObjectMappingFactory
4541
}
4642

47-
func NewObjectMappingFactory(clientAccessFactory ClientAccessFactory) kcmdutil.ObjectMappingFactory {
43+
func NewObjectMappingFactory(clientAccessFactory kcmdutil.ClientAccessFactory) kcmdutil.ObjectMappingFactory {
4844
return &ring1Factory{
4945
clientAccessFactory: clientAccessFactory,
5046
kubeObjectMappingFactory: kcmdutil.NewObjectMappingFactory(clientAccessFactory),
@@ -60,69 +56,14 @@ func (f *ring1Factory) CategoryExpander() categories.CategoryExpander {
6056
}
6157

6258
func (f *ring1Factory) ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) {
63-
// TODO only do this for legacy kinds
64-
if latest.OriginKind(mapping.GroupVersionKind) {
65-
cfg, err := f.clientAccessFactory.ClientConfig()
66-
if err != nil {
67-
return nil, err
68-
}
69-
if err := configcmd.SetLegacyOpenShiftDefaults(cfg); err != nil {
70-
return nil, err
71-
}
72-
cfg.APIPath = "/apis"
73-
if mapping.GroupVersionKind.Group == kapi.GroupName {
74-
cfg.APIPath = "/oapi"
75-
}
76-
gv := mapping.GroupVersionKind.GroupVersion()
77-
cfg.GroupVersion = &gv
78-
return restclient.RESTClientFor(cfg)
79-
}
8059
return f.kubeObjectMappingFactory.ClientForMapping(mapping)
8160
}
8261

8362
func (f *ring1Factory) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) {
84-
// TODO only do this for legacy kinds
85-
if latest.OriginKind(mapping.GroupVersionKind) {
86-
cfg, err := f.clientAccessFactory.ClientConfig()
87-
if err != nil {
88-
return nil, err
89-
}
90-
if err := configcmd.SetLegacyOpenShiftDefaults(cfg); err != nil {
91-
return nil, err
92-
}
93-
cfg.APIPath = "/apis"
94-
if mapping.GroupVersionKind.Group == kapi.GroupName {
95-
cfg.APIPath = "/oapi"
96-
}
97-
gv := mapping.GroupVersionKind.GroupVersion()
98-
cfg.ContentConfig = dynamic.ContentConfig()
99-
cfg.GroupVersion = &gv
100-
return restclient.RESTClientFor(cfg)
101-
}
10263
return f.kubeObjectMappingFactory.UnstructuredClientForMapping(mapping)
10364
}
10465

10566
func (f *ring1Factory) Describer(mapping *meta.RESTMapping) (kprinters.Describer, error) {
106-
// TODO we need to refactor the describer logic to handle misses or run serverside.
107-
// for now we can special case our "sometimes origin, sometimes kube" resource
108-
// I think it is correct for more code if this is NOT considered an origin type since
109-
// it wasn't an origin type pre 3.6.
110-
isSCC := mapping.GroupVersionKind.Kind == "SecurityContextConstraints"
111-
if latest.OriginKind(mapping.GroupVersionKind) || isSCC {
112-
kClient, err := f.clientAccessFactory.ClientSet()
113-
if err != nil {
114-
return nil, fmt.Errorf("unable to create client %s: %v", mapping.GroupVersionKind.Kind, err)
115-
}
116-
clientConfig, err := f.clientAccessFactory.ClientConfig()
117-
if err != nil {
118-
return nil, fmt.Errorf("unable to create client config %s: %v", mapping.GroupVersionKind.Kind, err)
119-
}
120-
describer, ok := describe.DescriberFor(mapping.GroupVersionKind.GroupKind(), clientConfig, kClient, clientConfig.Host)
121-
if !ok {
122-
return nil, fmt.Errorf("no description has been implemented for %q", mapping.GroupVersionKind.Kind)
123-
}
124-
return describer, nil
125-
}
12667
return f.kubeObjectMappingFactory.Describer(mapping)
12768
}
12869

0 commit comments

Comments
 (0)