Skip to content

Commit 047855f

Browse files
generated: client to staging
1 parent 35a6bfb commit 047855f

File tree

241 files changed

+5763
-3558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+5763
-3558
lines changed

staging/src/k8s.io/client-go/Godeps/Godeps.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/_vendor/cloud.google.com/go/AUTHORS

-15
This file was deleted.

staging/src/k8s.io/client-go/_vendor/cloud.google.com/go/CONTRIBUTORS

-34
This file was deleted.

staging/src/k8s.io/client-go/_vendor/github.com/docker/distribution/AUTHORS

-128
This file was deleted.

staging/src/k8s.io/client-go/_vendor/github.com/gogo/protobuf/CONTRIBUTORS

-15
This file was deleted.

staging/src/k8s.io/client-go/_vendor/github.com/golang/protobuf/AUTHORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/github.com/golang/protobuf/CONTRIBUTORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/crypto/AUTHORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/crypto/CONTRIBUTORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/net/AUTHORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/net/CONTRIBUTORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/sys/AUTHORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/sys/CONTRIBUTORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/text/AUTHORS

-3
This file was deleted.

staging/src/k8s.io/client-go/_vendor/golang.org/x/text/CONTRIBUTORS

-3
This file was deleted.

staging/src/k8s.io/client-go/discovery/discovery_client.go

+46-28
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"k8s.io/client-go/pkg/api/unversioned"
3131
"k8s.io/client-go/pkg/api/v1"
3232
"k8s.io/client-go/pkg/runtime"
33+
"k8s.io/client-go/pkg/runtime/schema"
3334
"k8s.io/client-go/pkg/runtime/serializer"
3435
"k8s.io/client-go/pkg/version"
3536
"k8s.io/client-go/rest"
@@ -69,10 +70,10 @@ type ServerResourcesInterface interface {
6970
ServerResources() (map[string]*unversioned.APIResourceList, error)
7071
// ServerPreferredResources returns the supported resources with the version preferred by the
7172
// server.
72-
ServerPreferredResources() ([]unversioned.GroupVersionResource, error)
73+
ServerPreferredResources() ([]schema.GroupVersionResource, error)
7374
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
7475
// version preferred by the server.
75-
ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error)
76+
ServerPreferredNamespacedResources() ([]schema.GroupVersionResource, error)
7677
}
7778

7879
// ServerVersionInterface has a method for retrieving the server's version.
@@ -84,7 +85,7 @@ type ServerVersionInterface interface {
8485
// SwaggerSchemaInterface has a method to retrieve the swagger schema.
8586
type SwaggerSchemaInterface interface {
8687
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
87-
SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error)
88+
SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error)
8889
}
8990

9091
// DiscoveryClient implements the functions that discover server-supported API groups,
@@ -186,7 +187,7 @@ func (d *DiscoveryClient) ServerResources() (map[string]*unversioned.APIResource
186187
// ErrGroupDiscoveryFailed is returned if one or more API groups fail to load.
187188
type ErrGroupDiscoveryFailed struct {
188189
// Groups is a list of the groups that failed to load and the error cause
189-
Groups map[unversioned.GroupVersion]error
190+
Groups map[schema.GroupVersion]error
190191
}
191192

192193
// Error implements the error interface
@@ -208,40 +209,57 @@ func IsGroupDiscoveryFailedError(err error) bool {
208209

209210
// serverPreferredResources returns the supported resources with the version preferred by the
210211
// server. If namespaced is true, only namespaced resources will be returned.
211-
func (d *DiscoveryClient) serverPreferredResources(namespaced bool) ([]unversioned.GroupVersionResource, error) {
212+
func (d *DiscoveryClient) serverPreferredResources(namespaced bool) ([]schema.GroupVersionResource, error) {
212213
// retry in case the groups supported by the server change after ServerGroup() returns.
213214
const maxRetries = 2
214-
var failedGroups map[unversioned.GroupVersion]error
215-
var results []unversioned.GroupVersionResource
215+
var failedGroups map[schema.GroupVersion]error
216+
var results []schema.GroupVersionResource
217+
var resources map[schema.GroupResource]string
216218
RetrieveGroups:
217219
for i := 0; i < maxRetries; i++ {
218-
results = []unversioned.GroupVersionResource{}
219-
failedGroups = make(map[unversioned.GroupVersion]error)
220+
results = []schema.GroupVersionResource{}
221+
resources = map[schema.GroupResource]string{}
222+
failedGroups = make(map[schema.GroupVersion]error)
220223
serverGroupList, err := d.ServerGroups()
221224
if err != nil {
222225
return results, err
223226
}
224227

225228
for _, apiGroup := range serverGroupList.Groups {
226-
preferredVersion := apiGroup.PreferredVersion
227-
groupVersion := unversioned.GroupVersion{Group: apiGroup.Name, Version: preferredVersion.Version}
228-
apiResourceList, err := d.ServerResourcesForGroupVersion(preferredVersion.GroupVersion)
229-
if err != nil {
230-
if i < maxRetries-1 {
231-
continue RetrieveGroups
232-
}
233-
failedGroups[groupVersion] = err
234-
continue
235-
}
236-
for _, apiResource := range apiResourceList.APIResources {
237-
// ignore the root scoped resources if "namespaced" is true.
238-
if namespaced && !apiResource.Namespaced {
229+
versions := apiGroup.Versions
230+
for _, version := range versions {
231+
groupVersion := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}
232+
apiResourceList, err := d.ServerResourcesForGroupVersion(version.GroupVersion)
233+
if err != nil {
234+
if i < maxRetries-1 {
235+
continue RetrieveGroups
236+
}
237+
failedGroups[groupVersion] = err
239238
continue
240239
}
241-
if strings.Contains(apiResource.Name, "/") {
242-
continue
240+
for _, apiResource := range apiResourceList.APIResources {
241+
// ignore the root scoped resources if "namespaced" is true.
242+
if namespaced && !apiResource.Namespaced {
243+
continue
244+
}
245+
if strings.Contains(apiResource.Name, "/") {
246+
continue
247+
}
248+
gvr := groupVersion.WithResource(apiResource.Name)
249+
if _, ok := resources[gvr.GroupResource()]; ok {
250+
if gvr.Version != apiGroup.PreferredVersion.Version {
251+
continue
252+
}
253+
// remove previous entry, because it will be replaced with a preferred one
254+
for i := range results {
255+
if results[i].GroupResource() == gvr.GroupResource() {
256+
results = append(results[:i], results[i+1:]...)
257+
}
258+
}
259+
}
260+
resources[gvr.GroupResource()] = gvr.Version
261+
results = append(results, gvr)
243262
}
244-
results = append(results, groupVersion.WithResource(apiResource.Name))
245263
}
246264
}
247265
if len(failedGroups) == 0 {
@@ -253,13 +271,13 @@ RetrieveGroups:
253271

254272
// ServerPreferredResources returns the supported resources with the version preferred by the
255273
// server.
256-
func (d *DiscoveryClient) ServerPreferredResources() ([]unversioned.GroupVersionResource, error) {
274+
func (d *DiscoveryClient) ServerPreferredResources() ([]schema.GroupVersionResource, error) {
257275
return d.serverPreferredResources(false)
258276
}
259277

260278
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
261279
// version preferred by the server.
262-
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error) {
280+
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]schema.GroupVersionResource, error) {
263281
return d.serverPreferredResources(true)
264282
}
265283

@@ -278,7 +296,7 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
278296
}
279297

280298
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
281-
func (d *DiscoveryClient) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) {
299+
func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
282300
if version.Empty() {
283301
return nil, fmt.Errorf("groupVersion cannot be empty")
284302
}

0 commit comments

Comments
 (0)