@@ -11,7 +11,6 @@ import (
11
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
12
"k8s.io/apimachinery/pkg/labels"
13
13
"k8s.io/apimachinery/pkg/runtime"
14
- "k8s.io/client-go/dynamic"
15
14
restclient "k8s.io/client-go/rest"
16
15
kapi "k8s.io/kubernetes/pkg/apis/core"
17
16
"k8s.io/kubernetes/pkg/controller"
@@ -23,7 +22,6 @@ import (
23
22
"k8s.io/kubernetes/pkg/kubectl/validation"
24
23
kprinters "k8s.io/kubernetes/pkg/printers"
25
24
26
- "github.com/openshift/origin/pkg/api/latest"
27
25
appsapi "github.com/openshift/origin/pkg/apps/apis/apps"
28
26
appsmanualclient "github.com/openshift/origin/pkg/apps/client/internalversion"
29
27
appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset"
@@ -33,18 +31,16 @@ import (
33
31
buildmanualclient "github.com/openshift/origin/pkg/build/client/internalversion"
34
32
buildclientinternal "github.com/openshift/origin/pkg/build/generated/internalclientset"
35
33
buildutil "github.com/openshift/origin/pkg/build/util"
36
- configcmd "github.com/openshift/origin/pkg/bulk"
37
34
imageapi "github.com/openshift/origin/pkg/image/apis/image"
38
35
deploymentcmd "github.com/openshift/origin/pkg/oc/cli/deploymentconfigs"
39
- "github.com/openshift/origin/pkg/oc/cli/describe"
40
36
)
41
37
42
38
type ring1Factory struct {
43
- clientAccessFactory ClientAccessFactory
39
+ clientAccessFactory kcmdutil. ClientAccessFactory
44
40
kubeObjectMappingFactory kcmdutil.ObjectMappingFactory
45
41
}
46
42
47
- func NewObjectMappingFactory (clientAccessFactory ClientAccessFactory ) kcmdutil.ObjectMappingFactory {
43
+ func NewObjectMappingFactory (clientAccessFactory kcmdutil. ClientAccessFactory ) kcmdutil.ObjectMappingFactory {
48
44
return & ring1Factory {
49
45
clientAccessFactory : clientAccessFactory ,
50
46
kubeObjectMappingFactory : kcmdutil .NewObjectMappingFactory (clientAccessFactory ),
@@ -60,69 +56,14 @@ func (f *ring1Factory) CategoryExpander() categories.CategoryExpander {
60
56
}
61
57
62
58
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
- }
80
59
return f .kubeObjectMappingFactory .ClientForMapping (mapping )
81
60
}
82
61
83
62
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
- }
102
63
return f .kubeObjectMappingFactory .UnstructuredClientForMapping (mapping )
103
64
}
104
65
105
66
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
- }
126
67
return f .kubeObjectMappingFactory .Describer (mapping )
127
68
}
128
69
0 commit comments