dep ensure -update k8s.io/client-go (#197)

This commit is contained in:
Kit Ewbank
2018-05-18 19:24:19 -04:00
committed by Robbie Zhang
parent 8068f3cac8
commit b4cb809968
774 changed files with 7107 additions and 15817 deletions

View File

@@ -35,8 +35,7 @@ go_test(
"client_test.go",
"roundtrip_test.go",
],
importpath = "k8s.io/client-go/scale",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",

View File

@@ -21,6 +21,7 @@ import (
autoscaling "k8s.io/api/autoscaling/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/dynamic"
@@ -129,21 +130,29 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string)
return nil, fmt.Errorf("unable to get client for %s: %v", resource.String(), err)
}
rawObj, err := c.client.clientBase.Get().
result := c.client.clientBase.Get().
AbsPath(path).
Namespace(c.namespace).
Resource(gvr.Resource).
Name(name).
SubResource("scale").
Do().
Get()
Do()
if err := result.Error(); err != nil {
return nil, fmt.Errorf("could not fetch the scale for %s %s: %v", resource.String(), name, err)
}
scaleBytes, err := result.Raw()
if err != nil {
return nil, err
}
decoder := scaleConverter.codecs.UniversalDecoder(scaleConverter.ScaleVersions()...)
rawScaleObj, err := runtime.Decode(decoder, scaleBytes)
if err != nil {
return nil, err
}
// convert whatever this is to autoscaling/v1.Scale
scaleObj, err := scaleConverter.ConvertToVersion(rawObj, autoscaling.SchemeGroupVersion)
scaleObj, err := scaleConverter.ConvertToVersion(rawScaleObj, autoscaling.SchemeGroupVersion)
if err != nil {
return nil, fmt.Errorf("received an object from a /scale endpoint which was not convertible to autoscaling Scale: %v", err)
}
@@ -158,8 +167,8 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
}
// Currently, a /scale endpoint can receive and return different scale types.
// Until we hvae support for the alternative API representations proposal,
// we need to deal with sending and accepting differnet API versions.
// Until we have support for the alternative API representations proposal,
// we need to deal with sending and accepting different API versions.
// figure out what scale we actually need here
desiredGVK, err := c.client.scaleKindResolver.ScaleForResource(gvr)
@@ -170,25 +179,38 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
// convert this to whatever this endpoint wants
scaleUpdate, err := scaleConverter.ConvertToVersion(scale, desiredGVK.GroupVersion())
if err != nil {
return nil, fmt.Errorf("could not convert scale update to internal Scale: %v", err)
return nil, fmt.Errorf("could not convert scale update to external Scale: %v", err)
}
encoder := scaleConverter.codecs.LegacyCodec(desiredGVK.GroupVersion())
scaleUpdateBytes, err := runtime.Encode(encoder, scaleUpdate)
if err != nil {
return nil, fmt.Errorf("could not encode scale update to external Scale: %v", err)
}
rawObj, err := c.client.clientBase.Put().
result := c.client.clientBase.Put().
AbsPath(path).
Namespace(c.namespace).
Resource(gvr.Resource).
Name(scale.Name).
SubResource("scale").
Body(scaleUpdate).
Do().
Get()
Body(scaleUpdateBytes).
Do()
if err := result.Error(); err != nil {
return nil, fmt.Errorf("could not update the scale for %s %s: %v", resource.String(), scale.Name, err)
}
scaleBytes, err := result.Raw()
if err != nil {
return nil, fmt.Errorf("could not fetch the scale for %s %s: %v", resource.String(), scale.Name, err)
return nil, err
}
decoder := scaleConverter.codecs.UniversalDecoder(scaleConverter.ScaleVersions()...)
rawScaleObj, err := runtime.Decode(decoder, scaleBytes)
if err != nil {
return nil, err
}
// convert whatever this is back to autoscaling/v1.Scale
scaleObj, err := scaleConverter.ConvertToVersion(rawObj, autoscaling.SchemeGroupVersion)
scaleObj, err := scaleConverter.ConvertToVersion(rawScaleObj, autoscaling.SchemeGroupVersion)
if err != nil {
return nil, fmt.Errorf("received an object from a /scale endpoint which was not convertible to autoscaling Scale: %v", err)
}

View File

@@ -99,7 +99,7 @@ func fakeScaleClient(t *testing.T) (ScalesGetter, []schema.GroupResource) {
restMapperRes, err := discovery.GetAPIGroupResources(fakeDiscoveryClient)
if err != nil {
t.Fatalf("unexpected error while constructing resource list from fake discovery client: %v")
t.Fatalf("unexpected error while constructing resource list from fake discovery client: %v", err)
}
restMapper := discovery.NewRESTMapper(restMapperRes, apimeta.InterfacesForUnstructured)

View File

@@ -23,7 +23,7 @@ import (
)
// NB: this can't be in the scheme package, because importing'
// scheme/autoscalingv1 from scheme causes a depedency loop from
// scheme/autoscalingv1 from scheme causes a dependency loop from
// conversions
func TestRoundTrip(t *testing.T) {

View File

@@ -17,6 +17,6 @@ limitations under the License.
// Package appsint contains the necessary scaffolding of the
// internal version of extensions as required by conversion logic.
// It doesn't have any of its own types -- it's just necessary to
// get the expected behavoir out of runtime.Scheme.ConvertToVersion
// get the expected behavior out of runtime.Scheme.ConvertToVersion
// and associated methods.
package appsint

View File

@@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package appsv1beta1

View File

@@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package appsv1beta2

View File

@@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package autoscalingv1

View File

@@ -17,6 +17,6 @@ limitations under the License.
// Package extensionsint contains the necessary scaffolding of the
// internal version of extensions as required by conversion logic.
// It doesn't have any of its own types -- it's just necessary to
// get the expected behavoir out of runtime.Scheme.ConvertToVersion
// get the expected behavior out of runtime.Scheme.ConvertToVersion
// and associated methods.
package extensionsint

View File

@@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package extensionsv1beta1

View File

@@ -1,7 +1,7 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
// Code generated by deepcopy-gen. DO NOT EDIT.
package scheme
@@ -49,9 +49,8 @@ func (in *Scale) DeepCopy() *Scale {
func (in *Scale) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

View File

@@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/discovery"
scalescheme "k8s.io/client-go/scale/scheme"
scaleappsint "k8s.io/client-go/scale/scheme/appsint"
@@ -124,6 +125,7 @@ func NewDiscoveryScaleKindResolver(client discovery.ServerResourcesInterface) Sc
// ScaleConverter knows how to convert between external scale versions.
type ScaleConverter struct {
scheme *runtime.Scheme
codecs serializer.CodecFactory
internalVersioner runtime.GroupVersioner
}
@@ -141,6 +143,7 @@ func NewScaleConverter() *ScaleConverter {
return &ScaleConverter{
scheme: scheme,
codecs: serializer.NewCodecFactory(scheme),
internalVersioner: runtime.NewMultiGroupVersioner(
scalescheme.SchemeGroupVersion,
schema.GroupKind{Group: scaleext.GroupName, Kind: "Scale"},
@@ -156,6 +159,22 @@ func (c *ScaleConverter) Scheme() *runtime.Scheme {
return c.scheme
}
func (c *ScaleConverter) Codecs() serializer.CodecFactory {
return c.codecs
}
func (c *ScaleConverter) ScaleVersions() []schema.GroupVersion {
return []schema.GroupVersion{
scaleautoscaling.SchemeGroupVersion,
scalescheme.SchemeGroupVersion,
scaleext.SchemeGroupVersion,
scaleextint.SchemeGroupVersion,
scaleappsint.SchemeGroupVersion,
scaleappsv1beta1.SchemeGroupVersion,
scaleappsv1beta2.SchemeGroupVersion,
}
}
// ConvertToVersion converts the given *external* input object to the given output *external* output group-version.
func (c *ScaleConverter) ConvertToVersion(in runtime.Object, outVersion schema.GroupVersion) (runtime.Object, error) {
scaleInt, err := c.scheme.ConvertToVersion(in, c.internalVersioner)