Changes to accommodate client-go changes and kube vendor update

to v1.18.0

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2020-04-14 12:34:33 +05:30
committed by mergify[bot]
parent 4c96ad3c85
commit 34fc1d847e
1083 changed files with 50505 additions and 155846 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package metadata
import (
"context"
"encoding/json"
"fmt"
"time"
@ -119,14 +120,11 @@ func (c *client) Namespace(ns string) ResourceInterface {
}
// Delete removes the provided resource from the server.
func (c *client) Delete(name string, opts *metav1.DeleteOptions, subresources ...string) error {
func (c *client) Delete(ctx context.Context, name string, opts metav1.DeleteOptions, subresources ...string) error {
if len(name) == 0 {
return fmt.Errorf("name is required")
}
if opts == nil {
opts = &metav1.DeleteOptions{}
}
deleteOptionsByte, err := runtime.Encode(deleteOptionsCodec.LegacyCodec(schema.GroupVersion{Version: "v1"}), opts)
deleteOptionsByte, err := runtime.Encode(deleteOptionsCodec.LegacyCodec(schema.GroupVersion{Version: "v1"}), &opts)
if err != nil {
return err
}
@ -135,16 +133,13 @@ func (c *client) Delete(name string, opts *metav1.DeleteOptions, subresources ..
Delete().
AbsPath(append(c.makeURLSegments(name), subresources...)...).
Body(deleteOptionsByte).
Do()
Do(ctx)
return result.Error()
}
// DeleteCollection triggers deletion of all resources in the specified scope (namespace or cluster).
func (c *client) DeleteCollection(opts *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
if opts == nil {
opts = &metav1.DeleteOptions{}
}
deleteOptionsByte, err := runtime.Encode(deleteOptionsCodec.LegacyCodec(schema.GroupVersion{Version: "v1"}), opts)
func (c *client) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOptions metav1.ListOptions) error {
deleteOptionsByte, err := runtime.Encode(deleteOptionsCodec.LegacyCodec(schema.GroupVersion{Version: "v1"}), &opts)
if err != nil {
return err
}
@ -154,19 +149,19 @@ func (c *client) DeleteCollection(opts *metav1.DeleteOptions, listOptions metav1
AbsPath(c.makeURLSegments("")...).
Body(deleteOptionsByte).
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
Do()
Do(ctx)
return result.Error()
}
// Get returns the resource with name from the specified scope (namespace or cluster).
func (c *client) Get(name string, opts metav1.GetOptions, subresources ...string) (*metav1.PartialObjectMetadata, error) {
func (c *client) Get(ctx context.Context, name string, opts metav1.GetOptions, subresources ...string) (*metav1.PartialObjectMetadata, error) {
if len(name) == 0 {
return nil, fmt.Errorf("name is required")
}
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").
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
Do(ctx)
if err := result.Error(); err != nil {
return nil, err
}
@ -198,11 +193,11 @@ func (c *client) Get(name string, opts metav1.GetOptions, subresources ...string
}
// List returns all resources within the specified scope (namespace or cluster).
func (c *client) List(opts metav1.ListOptions) (*metav1.PartialObjectMetadataList, error) {
func (c *client) List(ctx context.Context, opts metav1.ListOptions) (*metav1.PartialObjectMetadataList, error) {
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").
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
Do(ctx)
if err := result.Error(); err != nil {
return nil, err
}
@ -231,7 +226,7 @@ func (c *client) List(opts metav1.ListOptions) (*metav1.PartialObjectMetadataLis
}
// Watch finds all changes to the resources in the specified scope (namespace or cluster).
func (c *client) Watch(opts metav1.ListOptions) (watch.Interface, error) {
func (c *client) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
@ -242,11 +237,11 @@ 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").
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Timeout(timeout).
Watch()
Watch(ctx)
}
// Patch modifies the named resource in the specified scope (namespace or cluster).
func (c *client) Patch(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*metav1.PartialObjectMetadata, error) {
func (c *client) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*metav1.PartialObjectMetadata, error) {
if len(name) == 0 {
return nil, fmt.Errorf("name is required")
}
@ -256,7 +251,7 @@ func (c *client) Patch(name string, pt types.PatchType, data []byte, opts metav1
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").
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
Do(ctx)
if err := result.Error(); err != nil {
return nil, err
}