mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-15 05:53:15 +00:00
refactor
Kubernetes-commit: d55d6175f8e2cfdab0b79aac72046a652c2eb515
This commit is contained in:
parent
1b1a1841fa
commit
b136e9eb2b
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package discovery
|
package discovery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -155,7 +156,7 @@ func apiVersionsToAPIGroup(apiVersions *metav1.APIVersions) (apiGroup metav1.API
|
|||||||
func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error) {
|
func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error) {
|
||||||
// Get the groupVersions exposed at /api
|
// Get the groupVersions exposed at /api
|
||||||
v := &metav1.APIVersions{}
|
v := &metav1.APIVersions{}
|
||||||
err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do().Into(v)
|
err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do(context.TODO()).Into(v)
|
||||||
apiGroup := metav1.APIGroup{}
|
apiGroup := metav1.APIGroup{}
|
||||||
if err == nil && len(v.Versions) != 0 {
|
if err == nil && len(v.Versions) != 0 {
|
||||||
apiGroup = apiVersionsToAPIGroup(v)
|
apiGroup = apiVersionsToAPIGroup(v)
|
||||||
@ -166,7 +167,7 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
|
|||||||
|
|
||||||
// Get the groupVersions exposed at /apis
|
// Get the groupVersions exposed at /apis
|
||||||
apiGroupList = &metav1.APIGroupList{}
|
apiGroupList = &metav1.APIGroupList{}
|
||||||
err = d.restClient.Get().AbsPath("/apis").Do().Into(apiGroupList)
|
err = d.restClient.Get().AbsPath("/apis").Do(context.TODO()).Into(apiGroupList)
|
||||||
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
|
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -196,7 +197,7 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
|
|||||||
resources = &metav1.APIResourceList{
|
resources = &metav1.APIResourceList{
|
||||||
GroupVersion: groupVersion,
|
GroupVersion: groupVersion,
|
||||||
}
|
}
|
||||||
err = d.restClient.Get().AbsPath(url.String()).Do().Into(resources)
|
err = d.restClient.Get().AbsPath(url.String()).Do(context.TODO()).Into(resources)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ignore 403 or 404 error to be compatible with an v1.0 server.
|
// ignore 403 or 404 error to be compatible with an v1.0 server.
|
||||||
if groupVersion == "v1" && (errors.IsNotFound(err) || errors.IsForbidden(err)) {
|
if groupVersion == "v1" && (errors.IsNotFound(err) || errors.IsForbidden(err)) {
|
||||||
@ -405,7 +406,7 @@ func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIReso
|
|||||||
|
|
||||||
// ServerVersion retrieves and parses the server's version (git version).
|
// ServerVersion retrieves and parses the server's version (git version).
|
||||||
func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
||||||
body, err := d.restClient.Get().AbsPath("/version").Do().Raw()
|
body, err := d.restClient.Get().AbsPath("/version").Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -419,12 +420,12 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
|||||||
|
|
||||||
// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
|
// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
|
||||||
func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
|
func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||||
data, err := d.restClient.Get().AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do().Raw()
|
data, err := d.restClient.Get().AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsForbidden(err) || errors.IsNotFound(err) || errors.IsNotAcceptable(err) {
|
if errors.IsForbidden(err) || errors.IsNotFound(err) || errors.IsNotAcceptable(err) {
|
||||||
// single endpoint not found/registered in old server, try to fetch old endpoint
|
// single endpoint not found/registered in old server, try to fetch old endpoint
|
||||||
// TODO: remove this when kubectl/client-go don't work with 1.9 server
|
// TODO: remove this when kubectl/client-go don't work with 1.9 server
|
||||||
data, err = d.restClient.Get().AbsPath("/swagger-2.0.0.pb-v1").Do().Raw()
|
data, err = d.restClient.Get().AbsPath("/swagger-2.0.0.pb-v1").Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package dynamic
|
package dynamic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
@ -111,7 +112,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts meta
|
|||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(outBytes).
|
Body(outBytes).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -146,7 +147,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts meta
|
|||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(outBytes).
|
Body(outBytes).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -182,7 +183,7 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
|
|||||||
AbsPath(append(c.makeURLSegments(name), "status")...).
|
AbsPath(append(c.makeURLSegments(name), "status")...).
|
||||||
Body(outBytes).
|
Body(outBytes).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ func (c *dynamicResourceClient) Delete(name string, opts *metav1.DeleteOptions,
|
|||||||
Delete().
|
Delete().
|
||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +233,7 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
|
|||||||
AbsPath(c.makeURLSegments("")...).
|
AbsPath(c.makeURLSegments("")...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +241,7 @@ func (c *dynamicResourceClient) Get(name string, opts metav1.GetOptions, subreso
|
|||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return nil, fmt.Errorf("name is required")
|
return nil, fmt.Errorf("name is required")
|
||||||
}
|
}
|
||||||
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do()
|
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -256,7 +257,7 @@ func (c *dynamicResourceClient) Get(name string, opts metav1.GetOptions, subreso
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *dynamicResourceClient) List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
|
func (c *dynamicResourceClient) List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
|
||||||
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do()
|
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -283,7 +284,7 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
|
|||||||
opts.Watch = true
|
opts.Watch = true
|
||||||
return c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
return c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) {
|
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) {
|
||||||
@ -295,7 +296,7 @@ func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []by
|
|||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(data).
|
Body(data).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *tokenReviews) CreateContext(ctx context.Context, tokenReview *authentic
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("tokenreviews").
|
Resource("tokenreviews").
|
||||||
Body(tokenReview).
|
Body(tokenReview).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *tokenReviews) CreateContext(ctx context.Context, tokenReview *authentic
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("tokenreviews").
|
Resource("tokenreviews").
|
||||||
Body(tokenReview).
|
Body(tokenReview).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (c *localSubjectAccessReviews) CreateContext(ctx context.Context, sar *auth
|
|||||||
Namespace(c.ns).
|
Namespace(c.ns).
|
||||||
Resource("localsubjectaccessreviews").
|
Resource("localsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *selfSubjectAccessReviews) CreateContext(ctx context.Context, sar *autho
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectaccessreviews").
|
Resource("selfsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *selfSubjectRulesReviews) CreateContext(ctx context.Context, srr *author
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectrulesreviews").
|
Resource("selfsubjectrulesreviews").
|
||||||
Body(srr).
|
Body(srr).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (c *subjectAccessReviews) CreateContext(ctx context.Context, sar *authoriza
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("subjectaccessreviews").
|
Resource("subjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (c *localSubjectAccessReviews) CreateContext(ctx context.Context, sar *auth
|
|||||||
Namespace(c.ns).
|
Namespace(c.ns).
|
||||||
Resource("localsubjectaccessreviews").
|
Resource("localsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *selfSubjectAccessReviews) CreateContext(ctx context.Context, sar *autho
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectaccessreviews").
|
Resource("selfsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *selfSubjectRulesReviews) CreateContext(ctx context.Context, srr *author
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectrulesreviews").
|
Resource("selfsubjectrulesreviews").
|
||||||
Body(srr).
|
Body(srr).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (c *subjectAccessReviews) CreateContext(ctx context.Context, sar *authoriza
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("subjectaccessreviews").
|
Resource("subjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
certificates "k8s.io/api/certificates/v1beta1"
|
certificates "k8s.io/api/certificates/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ func (c *certificateSigningRequests) UpdateApproval(certificateSigningRequest *c
|
|||||||
Name(certificateSigningRequest.Name).
|
Name(certificateSigningRequest.Name).
|
||||||
Body(certificateSigningRequest).
|
Body(certificateSigningRequest).
|
||||||
SubResource("approval").
|
SubResource("approval").
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,10 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -54,7 +55,7 @@ func (e *events) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
|||||||
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
||||||
Resource("events").
|
Resource("events").
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@ -71,7 +72,7 @@ func (e *events) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(event.Name).
|
Name(event.Name).
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@ -91,7 +92,7 @@ func (e *events) PatchWithEventNamespace(incompleteEvent *v1.Event, data []byte)
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(incompleteEvent.Name).
|
Name(incompleteEvent.Name).
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
package v1
|
package v1
|
||||||
|
|
||||||
import "k8s.io/api/core/v1"
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
|
)
|
||||||
|
|
||||||
// The NamespaceExpansion interface allows manually adding extra methods to the NamespaceInterface.
|
// The NamespaceExpansion interface allows manually adding extra methods to the NamespaceInterface.
|
||||||
type NamespaceExpansion interface {
|
type NamespaceExpansion interface {
|
||||||
@ -26,6 +30,6 @@ type NamespaceExpansion interface {
|
|||||||
// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
|
// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
|
||||||
func (c *namespaces) Finalize(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
func (c *namespaces) Finalize(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
||||||
result = &v1.Namespace{}
|
result = &v1.Namespace{}
|
||||||
err = c.client.Put().Resource("namespaces").Name(namespace.Name).SubResource("finalize").Body(namespace).Do().Into(result)
|
err = c.client.Put().Resource("namespaces").Name(namespace.Name).SubResource("finalize").Body(namespace).Do(context.TODO()).Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/core/v1"
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +39,7 @@ func (c *nodes) PatchStatus(nodeName string, data []byte) (*v1.Node, error) {
|
|||||||
Name(nodeName).
|
Name(nodeName).
|
||||||
SubResource("status").
|
SubResource("status").
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/core/v1"
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
@ -32,11 +34,11 @@ type PodExpansion interface {
|
|||||||
|
|
||||||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||||
func (c *pods) Bind(binding *v1.Binding) error {
|
func (c *pods) Bind(binding *v1.Binding) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error()
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *pods) Evict(eviction *policy.Eviction) error {
|
func (c *pods) Evict(eviction *policy.Eviction) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do().Error()
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get constructs a request for getting the logs for a pod
|
// Get constructs a request for getting the logs for a pod
|
||||||
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
authenticationv1 "k8s.io/api/authentication/v1"
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ func (c *serviceAccounts) CreateToken(name string, tr *authenticationv1.TokenReq
|
|||||||
SubResource("token").
|
SubResource("token").
|
||||||
Name(name).
|
Name(name).
|
||||||
Body(tr).
|
Body(tr).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/api/events/v1beta1"
|
"k8s.io/api/events/v1beta1"
|
||||||
@ -51,7 +52,7 @@ func (e *events) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event,
|
|||||||
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
||||||
Resource("events").
|
Resource("events").
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ func (e *events) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event,
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(event.Name).
|
Name(event.Name).
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ func (e *events) PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(event.Name).
|
Name(event.Name).
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import "k8s.io/api/extensions/v1beta1"
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"k8s.io/api/extensions/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
// The DeploymentExpansion interface allows manually adding extra methods to the DeploymentInterface.
|
// The DeploymentExpansion interface allows manually adding extra methods to the DeploymentInterface.
|
||||||
type DeploymentExpansion interface {
|
type DeploymentExpansion interface {
|
||||||
@ -25,5 +29,5 @@ type DeploymentExpansion interface {
|
|||||||
|
|
||||||
// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace.
|
// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace.
|
||||||
func (c *deployments) Rollback(deploymentRollback *v1beta1.DeploymentRollback) error {
|
func (c *deployments) Rollback(deploymentRollback *v1beta1.DeploymentRollback) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).SubResource("rollback").Body(deploymentRollback).Do().Error()
|
return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).SubResource("rollback").Body(deploymentRollback).Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,6 +35,6 @@ func (c *evictions) Evict(eviction *policy.Eviction) error {
|
|||||||
Name(eviction.Name).
|
Name(eviction.Name).
|
||||||
SubResource("eviction").
|
SubResource("eviction").
|
||||||
Body(eviction).
|
Body(eviction).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Error()
|
Error()
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
@ -135,7 +136,7 @@ func (c *client) Delete(name string, opts *metav1.DeleteOptions, subresources ..
|
|||||||
Delete().
|
Delete().
|
||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +155,7 @@ func (c *client) DeleteCollection(opts *metav1.DeleteOptions, listOptions metav1
|
|||||||
AbsPath(c.makeURLSegments("")...).
|
AbsPath(c.makeURLSegments("")...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ func (c *client) Get(name string, opts metav1.GetOptions, subresources ...string
|
|||||||
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -202,7 +203,7 @@ func (c *client) List(opts metav1.ListOptions) (*metav1.PartialObjectMetadataLis
|
|||||||
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -242,7 +243,7 @@ func (c *client) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
|||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Timeout(timeout).
|
Timeout(timeout).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch modifies the named resource in the specified scope (namespace or cluster).
|
// Patch modifies the named resource in the specified scope (namespace or cluster).
|
||||||
@ -256,7 +257,7 @@ func (c *client) Patch(name string, pt types.PatchType, data []byte, opts metav1
|
|||||||
Body(data).
|
Body(data).
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package scale
|
package scale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
autoscaling "k8s.io/api/autoscaling/v1"
|
autoscaling "k8s.io/api/autoscaling/v1"
|
||||||
@ -154,7 +155,7 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string)
|
|||||||
Resource(gvr.Resource).
|
Resource(gvr.Resource).
|
||||||
Name(name).
|
Name(name).
|
||||||
SubResource("scale").
|
SubResource("scale").
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -196,7 +197,7 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
|
|||||||
Name(scale.Name).
|
Name(scale.Name).
|
||||||
SubResource("scale").
|
SubResource("scale").
|
||||||
Body(scaleUpdateBytes).
|
Body(scaleUpdateBytes).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
// propagate "raw" error from the API
|
// propagate "raw" error from the API
|
||||||
// this allows callers to interpret underlying Reason field
|
// this allows callers to interpret underlying Reason field
|
||||||
@ -216,7 +217,7 @@ func (c *namespacedScaleClient) Patch(gvr schema.GroupVersionResource, name stri
|
|||||||
Name(name).
|
Name(name).
|
||||||
SubResource("scale").
|
SubResource("scale").
|
||||||
Body(data).
|
Body(data).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
6
tools/cache/listwatch.go
vendored
6
tools/cache/listwatch.go
vendored
@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -82,7 +84,7 @@ func NewFilteredListWatchFromClient(c Getter, resource string, namespace string,
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(&options, metav1.ParameterCodec).
|
VersionedParams(&options, metav1.ParameterCodec).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
||||||
@ -92,7 +94,7 @@ func NewFilteredListWatchFromClient(c Getter, resource string, namespace string,
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(&options, metav1.ParameterCodec).
|
VersionedParams(&options, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user