@@ -27,8 +27,8 @@ import (
27
27
28
28
"k8s.io/client-go/pkg/api"
29
29
"k8s.io/client-go/pkg/api/errors"
30
- "k8s.io/client-go/pkg/api/unversioned"
31
30
"k8s.io/client-go/pkg/api/v1"
31
+ metav1 "k8s.io/client-go/pkg/apis/meta/v1"
32
32
"k8s.io/client-go/pkg/runtime"
33
33
"k8s.io/client-go/pkg/runtime/schema"
34
34
"k8s.io/client-go/pkg/runtime/serializer"
@@ -59,15 +59,15 @@ type CachedDiscoveryInterface interface {
59
59
type ServerGroupsInterface interface {
60
60
// ServerGroups returns the supported groups, with information like supported versions and the
61
61
// preferred version.
62
- ServerGroups () (* unversioned .APIGroupList , error )
62
+ ServerGroups () (* metav1 .APIGroupList , error )
63
63
}
64
64
65
65
// ServerResourcesInterface has methods for obtaining supported resources on the API server
66
66
type ServerResourcesInterface interface {
67
67
// ServerResourcesForGroupVersion returns the supported resources for a group and version.
68
- ServerResourcesForGroupVersion (groupVersion string ) (* unversioned .APIResourceList , error )
68
+ ServerResourcesForGroupVersion (groupVersion string ) (* metav1 .APIResourceList , error )
69
69
// ServerResources returns the supported resources for all groups and versions.
70
- ServerResources () (map [string ]* unversioned .APIResourceList , error )
70
+ ServerResources () (map [string ]* metav1 .APIResourceList , error )
71
71
// ServerPreferredResources returns the supported resources with the version preferred by the
72
72
// server.
73
73
ServerPreferredResources () ([]schema.GroupVersionResource , error )
@@ -96,12 +96,12 @@ type DiscoveryClient struct {
96
96
LegacyPrefix string
97
97
}
98
98
99
- // Convert unversioned .APIVersions to unversioned .APIGroup. APIVersions is used by legacy v1, so
99
+ // Convert metav1 .APIVersions to metav1 .APIGroup. APIVersions is used by legacy v1, so
100
100
// group would be "".
101
- func apiVersionsToAPIGroup (apiVersions * unversioned .APIVersions ) (apiGroup unversioned .APIGroup ) {
102
- groupVersions := []unversioned .GroupVersionForDiscovery {}
101
+ func apiVersionsToAPIGroup (apiVersions * metav1 .APIVersions ) (apiGroup metav1 .APIGroup ) {
102
+ groupVersions := []metav1 .GroupVersionForDiscovery {}
103
103
for _ , version := range apiVersions .Versions {
104
- groupVersion := unversioned .GroupVersionForDiscovery {
104
+ groupVersion := metav1 .GroupVersionForDiscovery {
105
105
GroupVersion : version ,
106
106
Version : version ,
107
107
}
@@ -115,11 +115,11 @@ func apiVersionsToAPIGroup(apiVersions *unversioned.APIVersions) (apiGroup unver
115
115
116
116
// ServerGroups returns the supported groups, with information like supported versions and the
117
117
// preferred version.
118
- func (d * DiscoveryClient ) ServerGroups () (apiGroupList * unversioned .APIGroupList , err error ) {
118
+ func (d * DiscoveryClient ) ServerGroups () (apiGroupList * metav1 .APIGroupList , err error ) {
119
119
// Get the groupVersions exposed at /api
120
- v := & unversioned .APIVersions {}
120
+ v := & metav1 .APIVersions {}
121
121
err = d .restClient .Get ().AbsPath (d .LegacyPrefix ).Do ().Into (v )
122
- apiGroup := unversioned .APIGroup {}
122
+ apiGroup := metav1 .APIGroup {}
123
123
if err == nil {
124
124
apiGroup = apiVersionsToAPIGroup (v )
125
125
}
@@ -128,14 +128,14 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *unversioned.APIGroupList
128
128
}
129
129
130
130
// Get the groupVersions exposed at /apis
131
- apiGroupList = & unversioned .APIGroupList {}
131
+ apiGroupList = & metav1 .APIGroupList {}
132
132
err = d .restClient .Get ().AbsPath ("/apis" ).Do ().Into (apiGroupList )
133
133
if err != nil && ! errors .IsNotFound (err ) && ! errors .IsForbidden (err ) {
134
134
return nil , err
135
135
}
136
136
// to be compatible with a v1.0 server, if it's a 403 or 404, ignore and return whatever we got from /api
137
137
if err != nil && (errors .IsNotFound (err ) || errors .IsForbidden (err )) {
138
- apiGroupList = & unversioned .APIGroupList {}
138
+ apiGroupList = & metav1 .APIGroupList {}
139
139
}
140
140
141
141
// append the group retrieved from /api to the list
@@ -144,7 +144,7 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *unversioned.APIGroupList
144
144
}
145
145
146
146
// ServerResourcesForGroupVersion returns the supported resources for a group and version.
147
- func (d * DiscoveryClient ) ServerResourcesForGroupVersion (groupVersion string ) (resources * unversioned .APIResourceList , err error ) {
147
+ func (d * DiscoveryClient ) ServerResourcesForGroupVersion (groupVersion string ) (resources * metav1 .APIResourceList , err error ) {
148
148
url := url.URL {}
149
149
if len (groupVersion ) == 0 {
150
150
return nil , fmt .Errorf ("groupVersion shouldn't be empty" )
@@ -154,7 +154,7 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
154
154
} else {
155
155
url .Path = "/apis/" + groupVersion
156
156
}
157
- resources = & unversioned .APIResourceList {}
157
+ resources = & metav1 .APIResourceList {}
158
158
err = d .restClient .Get ().AbsPath (url .String ()).Do ().Into (resources )
159
159
if err != nil {
160
160
// ignore 403 or 404 error to be compatible with an v1.0 server.
@@ -167,13 +167,13 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
167
167
}
168
168
169
169
// ServerResources returns the supported resources for all groups and versions.
170
- func (d * DiscoveryClient ) ServerResources () (map [string ]* unversioned .APIResourceList , error ) {
170
+ func (d * DiscoveryClient ) ServerResources () (map [string ]* metav1 .APIResourceList , error ) {
171
171
apiGroups , err := d .ServerGroups ()
172
172
if err != nil {
173
173
return nil , err
174
174
}
175
- groupVersions := unversioned .ExtractGroupVersions (apiGroups )
176
- result := map [string ]* unversioned .APIResourceList {}
175
+ groupVersions := metav1 .ExtractGroupVersions (apiGroups )
176
+ result := map [string ]* metav1 .APIResourceList {}
177
177
for _ , groupVersion := range groupVersions {
178
178
resources , err := d .ServerResourcesForGroupVersion (groupVersion )
179
179
if err != nil {
@@ -305,7 +305,7 @@ func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.A
305
305
if err != nil {
306
306
return nil , err
307
307
}
308
- groupVersions := unversioned .ExtractGroupVersions (groupList )
308
+ groupVersions := metav1 .ExtractGroupVersions (groupList )
309
309
// This check also takes care the case that kubectl is newer than the running endpoint
310
310
if stringDoesntExistIn (version .String (), groupVersions ) {
311
311
return nil , fmt .Errorf ("API version: %v is not supported by the server. Use one of: %v" , version , groupVersions )
0 commit comments