mirror of
https://github.com/rancher/rke.git
synced 2025-09-18 08:06:20 +00:00
K8s Vendor update to 1.10.5
This commit is contained in:
3
vendor/k8s.io/client-go/dynamic/BUILD
generated
vendored
3
vendor/k8s.io/client-go/dynamic/BUILD
generated
vendored
@@ -12,7 +12,7 @@ go_test(
|
||||
"client_test.go",
|
||||
"dynamic_util_test.go",
|
||||
],
|
||||
library = ":go_default_library",
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
@@ -33,6 +33,7 @@ go_library(
|
||||
"client_pool.go",
|
||||
"dynamic_util.go",
|
||||
],
|
||||
importpath = "k8s.io/client-go/dynamic",
|
||||
deps = [
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
|
55
vendor/k8s.io/client-go/dynamic/client.go
generated
vendored
55
vendor/k8s.io/client-go/dynamic/client.go
generated
vendored
@@ -47,7 +47,7 @@ type Interface interface {
|
||||
GetRateLimiter() flowcontrol.RateLimiter
|
||||
// Resource returns an API interface to the specified resource for this client's
|
||||
// group and version. If resource is not a namespaced resource, then namespace
|
||||
// is ignored. The ResourceInterface inherits the paramater codec of this client.
|
||||
// is ignored. The ResourceInterface inherits the parameter codec of this client.
|
||||
Resource(resource *metav1.APIResource, namespace string) ResourceInterface
|
||||
// ParameterCodec returns a client with the provided parameter codec.
|
||||
ParameterCodec(parameterCodec runtime.ParameterCodec) Interface
|
||||
@@ -145,6 +145,19 @@ type ResourceClient struct {
|
||||
parameterCodec runtime.ParameterCodec
|
||||
}
|
||||
|
||||
func (rc *ResourceClient) parseResourceSubresourceName() (string, []string) {
|
||||
var resourceName string
|
||||
var subresourceName []string
|
||||
if strings.Contains(rc.resource.Name, "/") {
|
||||
resourceName = strings.Split(rc.resource.Name, "/")[0]
|
||||
subresourceName = strings.Split(rc.resource.Name, "/")[1:]
|
||||
} else {
|
||||
resourceName = rc.resource.Name
|
||||
}
|
||||
|
||||
return resourceName, subresourceName
|
||||
}
|
||||
|
||||
// List returns a list of objects for this resource.
|
||||
func (rc *ResourceClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
||||
parameterEncoder := rc.parameterCodec
|
||||
@@ -166,9 +179,11 @@ func (rc *ResourceClient) Get(name string, opts metav1.GetOptions) (*unstructure
|
||||
parameterEncoder = defaultParameterEncoder
|
||||
}
|
||||
result := new(unstructured.Unstructured)
|
||||
resourceName, subresourceName := rc.parseResourceSubresourceName()
|
||||
err := rc.cl.Get().
|
||||
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
||||
Resource(rc.resource.Name).
|
||||
Resource(resourceName).
|
||||
SubResource(subresourceName...).
|
||||
VersionedParams(&opts, parameterEncoder).
|
||||
Name(name).
|
||||
Do().
|
||||
@@ -205,11 +220,26 @@ func (rc *ResourceClient) DeleteCollection(deleteOptions *metav1.DeleteOptions,
|
||||
// Create creates the provided resource.
|
||||
func (rc *ResourceClient) Create(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
|
||||
result := new(unstructured.Unstructured)
|
||||
err := rc.cl.Post().
|
||||
resourceName, subresourceName := rc.parseResourceSubresourceName()
|
||||
req := rc.cl.Post().
|
||||
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
||||
Resource(rc.resource.Name).
|
||||
Body(obj).
|
||||
Do().
|
||||
Resource(resourceName).
|
||||
Body(obj)
|
||||
if len(subresourceName) > 0 {
|
||||
// If the provided resource is a subresource, the POST request should contain
|
||||
// object name. Examples of subresources that support Create operation:
|
||||
// core/v1/pods/{name}/binding
|
||||
// core/v1/pods/{name}/eviction
|
||||
// extensions/v1beta1/deployments/{name}/rollback
|
||||
// apps/v1beta1/deployments/{name}/rollback
|
||||
// NOTE: Currently our system assumes every subresource object has the same
|
||||
// name as the parent resource object. E.g. a pods/binding object having
|
||||
// metadada.name "foo" means pod "foo" is being bound. We may need to
|
||||
// change this if we break the assumption in the future.
|
||||
req = req.SubResource(subresourceName...).
|
||||
Name(obj.GetName())
|
||||
}
|
||||
err := req.Do().
|
||||
Into(result)
|
||||
return result, err
|
||||
}
|
||||
@@ -220,9 +250,15 @@ func (rc *ResourceClient) Update(obj *unstructured.Unstructured) (*unstructured.
|
||||
if len(obj.GetName()) == 0 {
|
||||
return result, errors.New("object missing name")
|
||||
}
|
||||
resourceName, subresourceName := rc.parseResourceSubresourceName()
|
||||
err := rc.cl.Put().
|
||||
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
||||
Resource(rc.resource.Name).
|
||||
Resource(resourceName).
|
||||
SubResource(subresourceName...).
|
||||
// NOTE: Currently our system assumes every subresource object has the same
|
||||
// name as the parent resource object. E.g. a pods/binding object having
|
||||
// metadada.name "foo" means pod "foo" is being bound. We may need to
|
||||
// change this if we break the assumption in the future.
|
||||
Name(obj.GetName()).
|
||||
Body(obj).
|
||||
Do().
|
||||
@@ -244,11 +280,14 @@ func (rc *ResourceClient) Watch(opts metav1.ListOptions) (watch.Interface, error
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched resource.
|
||||
func (rc *ResourceClient) Patch(name string, pt types.PatchType, data []byte) (*unstructured.Unstructured, error) {
|
||||
result := new(unstructured.Unstructured)
|
||||
resourceName, subresourceName := rc.parseResourceSubresourceName()
|
||||
err := rc.cl.Patch(pt).
|
||||
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
||||
Resource(rc.resource.Name).
|
||||
Resource(resourceName).
|
||||
SubResource(subresourceName...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
|
4
vendor/k8s.io/client-go/dynamic/client_pool.go
generated
vendored
4
vendor/k8s.io/client-go/dynamic/client_pool.go
generated
vendored
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
// ClientPool manages a pool of dynamic clients.
|
||||
type ClientPool interface {
|
||||
// ClientForGroupVersionKind returns a client configured for the specified groupVersionResource.
|
||||
// ClientForGroupVersionResource returns a client configured for the specified groupVersionResource.
|
||||
// Resource may be empty.
|
||||
ClientForGroupVersionResource(resource schema.GroupVersionResource) (Interface, error)
|
||||
// ClientForGroupVersionKind returns a client configured for the specified groupVersionKind.
|
||||
@@ -56,7 +56,7 @@ type clientPoolImpl struct {
|
||||
mapper meta.RESTMapper
|
||||
}
|
||||
|
||||
// NewClientPool returns a ClientPool from the specified config. It reuses clients for the the same
|
||||
// NewClientPool returns a ClientPool from the specified config. It reuses clients for the same
|
||||
// group version. It is expected this type may be wrapped by specific logic that special cases certain
|
||||
// resources or groups.
|
||||
func NewClientPool(config *restclient.Config, mapper meta.RESTMapper, apiPathResolverFunc APIPathResolverFunc) ClientPool {
|
||||
|
2
vendor/k8s.io/client-go/dynamic/dynamic_util.go
generated
vendored
2
vendor/k8s.io/client-go/dynamic/dynamic_util.go
generated
vendored
@@ -84,7 +84,7 @@ func NewObjectTyper(resources []*metav1.APIResourceList) (runtime.ObjectTyper, e
|
||||
// information.
|
||||
func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]schema.GroupVersionKind, bool, error) {
|
||||
if _, ok := obj.(*unstructured.Unstructured); !ok {
|
||||
return nil, false, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
|
||||
return nil, false, fmt.Errorf("type %T is invalid for determining dynamic object types", obj)
|
||||
}
|
||||
return []schema.GroupVersionKind{obj.GetObjectKind().GroupVersionKind()}, false, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user