mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
Update to kube v1.17
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
327fcd1b1b
commit
3af1e26d7c
104
vendor/k8s.io/client-go/scale/client.go
generated
vendored
104
vendor/k8s.io/client-go/scale/client.go
generated
vendored
@ -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/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/dynamic"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
)
|
||||
@ -75,6 +76,19 @@ func New(baseClient restclient.Interface, mapper PreferredResourceMapper, resolv
|
||||
}
|
||||
}
|
||||
|
||||
// apiPathFor returns the absolute api path for the given GroupVersion
|
||||
func (c *scaleClient) apiPathFor(groupVer schema.GroupVersion) string {
|
||||
// we need to set the API path based on GroupVersion (defaulting to the legacy path if none is set)
|
||||
// TODO: we "cheat" here since the API path really only depends on group ATM, but this should
|
||||
// *probably* take GroupVersionResource and not GroupVersionKind.
|
||||
apiPath := c.apiPathResolverFunc(groupVer.WithKind(""))
|
||||
if apiPath == "" {
|
||||
apiPath = "/api"
|
||||
}
|
||||
|
||||
return restclient.DefaultVersionedAPIPath(apiPath, groupVer)
|
||||
}
|
||||
|
||||
// pathAndVersionFor returns the appropriate base path and the associated full GroupVersionResource
|
||||
// for the given GroupResource
|
||||
func (c *scaleClient) pathAndVersionFor(resource schema.GroupResource) (string, schema.GroupVersionResource, error) {
|
||||
@ -85,17 +99,7 @@ func (c *scaleClient) pathAndVersionFor(resource schema.GroupResource) (string,
|
||||
|
||||
groupVer := gvr.GroupVersion()
|
||||
|
||||
// we need to set the API path based on GroupVersion (defaulting to the legacy path if none is set)
|
||||
// TODO: we "cheat" here since the API path really only depends on group ATM, but this should
|
||||
// *probably* take GroupVersionResource and not GroupVersionKind.
|
||||
apiPath := c.apiPathResolverFunc(groupVer.WithKind(""))
|
||||
if apiPath == "" {
|
||||
apiPath = "/api"
|
||||
}
|
||||
|
||||
path := restclient.DefaultVersionedAPIPath(apiPath, groupVer)
|
||||
|
||||
return path, gvr, nil
|
||||
return c.apiPathFor(groupVer), gvr, nil
|
||||
}
|
||||
|
||||
// namespacedScaleClient is an ScaleInterface for fetching
|
||||
@ -105,6 +109,27 @@ type namespacedScaleClient struct {
|
||||
namespace string
|
||||
}
|
||||
|
||||
// convertToScale converts the response body to autoscaling/v1.Scale
|
||||
func convertToScale(result *restclient.Result) (*autoscaling.Scale, error) {
|
||||
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(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)
|
||||
}
|
||||
|
||||
return scaleObj.(*autoscaling.Scale), nil
|
||||
}
|
||||
|
||||
func (c *scaleClient) Scales(namespace string) ScaleInterface {
|
||||
return &namespacedScaleClient{
|
||||
client: c,
|
||||
@ -125,7 +150,7 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string)
|
||||
|
||||
result := c.client.clientBase.Get().
|
||||
AbsPath(path).
|
||||
Namespace(c.namespace).
|
||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||
Resource(gvr.Resource).
|
||||
Name(name).
|
||||
SubResource("scale").
|
||||
@ -134,23 +159,7 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string)
|
||||
return nil, 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(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)
|
||||
}
|
||||
|
||||
return scaleObj.(*autoscaling.Scale), nil
|
||||
return convertToScale(&result)
|
||||
}
|
||||
|
||||
func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *autoscaling.Scale) (*autoscaling.Scale, error) {
|
||||
@ -182,7 +191,7 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
|
||||
|
||||
result := c.client.clientBase.Put().
|
||||
AbsPath(path).
|
||||
Namespace(c.namespace).
|
||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||
Resource(gvr.Resource).
|
||||
Name(scale.Name).
|
||||
SubResource("scale").
|
||||
@ -195,21 +204,22 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
|
||||
return nil, 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 back to autoscaling/v1.Scale
|
||||
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)
|
||||
}
|
||||
|
||||
return scaleObj.(*autoscaling.Scale), err
|
||||
return convertToScale(&result)
|
||||
}
|
||||
|
||||
func (c *namespacedScaleClient) Patch(gvr schema.GroupVersionResource, name string, pt types.PatchType, data []byte) (*autoscaling.Scale, error) {
|
||||
groupVersion := gvr.GroupVersion()
|
||||
result := c.client.clientBase.Patch(pt).
|
||||
AbsPath(c.client.apiPathFor(groupVersion)).
|
||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||
Resource(gvr.Resource).
|
||||
Name(name).
|
||||
SubResource("scale").
|
||||
Body(data).
|
||||
Do()
|
||||
if err := result.Error(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return convertToScale(&result)
|
||||
}
|
||||
|
Reference in New Issue
Block a user