mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-03 08:04:45 +00:00
Generate typed clients with Apply support
Kubernetes-commit: 08d5565b9b3892032ae98fe1592413e1703c2e3e
This commit is contained in:
committed by
Kubernetes Publisher
parent
b4932b529f
commit
a793842303
@@ -20,6 +20,8 @@ package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
|
||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -27,6 +29,7 @@ import (
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
applyconfigurationsschedulingv1 "k8s.io/client-go/applyconfigurations/scheduling/v1"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
@@ -120,3 +123,24 @@ func (c *FakePriorityClasses) Patch(ctx context.Context, name string, pt types.P
|
||||
}
|
||||
return obj.(*schedulingv1.PriorityClass), err
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied priorityClass.
|
||||
func (c *FakePriorityClasses) Apply(ctx context.Context, priorityClass *applyconfigurationsschedulingv1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *schedulingv1.PriorityClass, err error) {
|
||||
if priorityClass == nil {
|
||||
return nil, fmt.Errorf("priorityClass provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(priorityClass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := priorityClass.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("priorityClass.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, *name, types.ApplyPatchType, data), &schedulingv1.PriorityClass{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*schedulingv1.PriorityClass), err
|
||||
}
|
||||
|
@@ -20,12 +20,15 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/scheduling/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
schedulingv1 "k8s.io/client-go/applyconfigurations/scheduling/v1"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -46,6 +49,7 @@ type PriorityClassInterface interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*v1.PriorityClassList, error)
|
||||
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
|
||||
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.PriorityClass, err error)
|
||||
Apply(ctx context.Context, priorityClass *schedulingv1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (result *v1.PriorityClass, err error)
|
||||
PriorityClassExpansion
|
||||
}
|
||||
|
||||
@@ -166,3 +170,28 @@ func (c *priorityClasses) Patch(ctx context.Context, name string, pt types.Patch
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied priorityClass.
|
||||
func (c *priorityClasses) Apply(ctx context.Context, priorityClass *schedulingv1.PriorityClassApplyConfiguration, opts metav1.ApplyOptions) (result *v1.PriorityClass, err error) {
|
||||
if priorityClass == nil {
|
||||
return nil, fmt.Errorf("priorityClass provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(priorityClass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := priorityClass.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("priorityClass.Name must be provided to Apply")
|
||||
}
|
||||
result = &v1.PriorityClass{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Resource("priorityclasses").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
|
||||
v1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -27,6 +29,7 @@ import (
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
schedulingv1alpha1 "k8s.io/client-go/applyconfigurations/scheduling/v1alpha1"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
@@ -120,3 +123,24 @@ func (c *FakePriorityClasses) Patch(ctx context.Context, name string, pt types.P
|
||||
}
|
||||
return obj.(*v1alpha1.PriorityClass), err
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied priorityClass.
|
||||
func (c *FakePriorityClasses) Apply(ctx context.Context, priorityClass *schedulingv1alpha1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PriorityClass, err error) {
|
||||
if priorityClass == nil {
|
||||
return nil, fmt.Errorf("priorityClass provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(priorityClass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := priorityClass.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("priorityClass.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, *name, types.ApplyPatchType, data), &v1alpha1.PriorityClass{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.PriorityClass), err
|
||||
}
|
||||
|
@@ -20,12 +20,15 @@ package v1alpha1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
schedulingv1alpha1 "k8s.io/client-go/applyconfigurations/scheduling/v1alpha1"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -46,6 +49,7 @@ type PriorityClassInterface interface {
|
||||
List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PriorityClassList, error)
|
||||
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PriorityClass, err error)
|
||||
Apply(ctx context.Context, priorityClass *schedulingv1alpha1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PriorityClass, err error)
|
||||
PriorityClassExpansion
|
||||
}
|
||||
|
||||
@@ -166,3 +170,28 @@ func (c *priorityClasses) Patch(ctx context.Context, name string, pt types.Patch
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied priorityClass.
|
||||
func (c *priorityClasses) Apply(ctx context.Context, priorityClass *schedulingv1alpha1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.PriorityClass, err error) {
|
||||
if priorityClass == nil {
|
||||
return nil, fmt.Errorf("priorityClass provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(priorityClass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := priorityClass.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("priorityClass.Name must be provided to Apply")
|
||||
}
|
||||
result = &v1alpha1.PriorityClass{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Resource("priorityclasses").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
|
||||
v1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -27,6 +29,7 @@ import (
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
schedulingv1beta1 "k8s.io/client-go/applyconfigurations/scheduling/v1beta1"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
@@ -120,3 +123,24 @@ func (c *FakePriorityClasses) Patch(ctx context.Context, name string, pt types.P
|
||||
}
|
||||
return obj.(*v1beta1.PriorityClass), err
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied priorityClass.
|
||||
func (c *FakePriorityClasses) Apply(ctx context.Context, priorityClass *schedulingv1beta1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PriorityClass, err error) {
|
||||
if priorityClass == nil {
|
||||
return nil, fmt.Errorf("priorityClass provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(priorityClass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := priorityClass.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("priorityClass.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, *name, types.ApplyPatchType, data), &v1beta1.PriorityClass{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.PriorityClass), err
|
||||
}
|
||||
|
@@ -20,12 +20,15 @@ package v1beta1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
schedulingv1beta1 "k8s.io/client-go/applyconfigurations/scheduling/v1beta1"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -46,6 +49,7 @@ type PriorityClassInterface interface {
|
||||
List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PriorityClassList, error)
|
||||
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.PriorityClass, err error)
|
||||
Apply(ctx context.Context, priorityClass *schedulingv1beta1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PriorityClass, err error)
|
||||
PriorityClassExpansion
|
||||
}
|
||||
|
||||
@@ -166,3 +170,28 @@ func (c *priorityClasses) Patch(ctx context.Context, name string, pt types.Patch
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied priorityClass.
|
||||
func (c *priorityClasses) Apply(ctx context.Context, priorityClass *schedulingv1beta1.PriorityClassApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PriorityClass, err error) {
|
||||
if priorityClass == nil {
|
||||
return nil, fmt.Errorf("priorityClass provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(priorityClass)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := priorityClass.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("priorityClass.Name must be provided to Apply")
|
||||
}
|
||||
result = &v1beta1.PriorityClass{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Resource("priorityclasses").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user