mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-07 18:11:31 +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,12 +20,15 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/batch/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
batchv1 "k8s.io/client-go/applyconfigurations/batch/v1"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -47,6 +50,8 @@ type CronJobInterface interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*v1.CronJobList, 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.CronJob, err error)
|
||||
Apply(ctx context.Context, cronJob *batchv1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.CronJob, err error)
|
||||
ApplyStatus(ctx context.Context, cronJob *batchv1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.CronJob, err error)
|
||||
CronJobExpansion
|
||||
}
|
||||
|
||||
@@ -193,3 +198,59 @@ func (c *cronJobs) Patch(ctx context.Context, name string, pt types.PatchType, d
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied cronJob.
|
||||
func (c *cronJobs) Apply(ctx context.Context, cronJob *batchv1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
result = &v1.CronJob{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("cronjobs").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
func (c *cronJobs) ApplyStatus(ctx context.Context, cronJob *batchv1.CronJobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
|
||||
result = &v1.CronJob{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("cronjobs").
|
||||
Name(*name).
|
||||
SubResource("status").
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
|
||||
batchv1 "k8s.io/api/batch/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"
|
||||
applyconfigurationsbatchv1 "k8s.io/client-go/applyconfigurations/batch/v1"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
@@ -140,3 +143,48 @@ func (c *FakeCronJobs) Patch(ctx context.Context, name string, pt types.PatchTyp
|
||||
}
|
||||
return obj.(*batchv1.CronJob), err
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied cronJob.
|
||||
func (c *FakeCronJobs) Apply(ctx context.Context, cronJob *applyconfigurationsbatchv1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *batchv1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, *name, types.ApplyPatchType, data), &batchv1.CronJob{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*batchv1.CronJob), err
|
||||
}
|
||||
|
||||
// ApplyStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
func (c *FakeCronJobs) ApplyStatus(ctx context.Context, cronJob *applyconfigurationsbatchv1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *batchv1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &batchv1.CronJob{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*batchv1.CronJob), err
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
|
||||
batchv1 "k8s.io/api/batch/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"
|
||||
applyconfigurationsbatchv1 "k8s.io/client-go/applyconfigurations/batch/v1"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
@@ -140,3 +143,48 @@ func (c *FakeJobs) Patch(ctx context.Context, name string, pt types.PatchType, d
|
||||
}
|
||||
return obj.(*batchv1.Job), err
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied job.
|
||||
func (c *FakeJobs) Apply(ctx context.Context, job *applyconfigurationsbatchv1.JobApplyConfiguration, opts v1.ApplyOptions) (result *batchv1.Job, err error) {
|
||||
if job == nil {
|
||||
return nil, fmt.Errorf("job provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := job.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("job.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(jobsResource, c.ns, *name, types.ApplyPatchType, data), &batchv1.Job{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*batchv1.Job), err
|
||||
}
|
||||
|
||||
// ApplyStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
func (c *FakeJobs) ApplyStatus(ctx context.Context, job *applyconfigurationsbatchv1.JobApplyConfiguration, opts v1.ApplyOptions) (result *batchv1.Job, err error) {
|
||||
if job == nil {
|
||||
return nil, fmt.Errorf("job provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := job.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("job.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(jobsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &batchv1.Job{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*batchv1.Job), err
|
||||
}
|
||||
|
@@ -20,12 +20,15 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/batch/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
batchv1 "k8s.io/client-go/applyconfigurations/batch/v1"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -47,6 +50,8 @@ type JobInterface interface {
|
||||
List(ctx context.Context, opts metav1.ListOptions) (*v1.JobList, 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.Job, err error)
|
||||
Apply(ctx context.Context, job *batchv1.JobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Job, err error)
|
||||
ApplyStatus(ctx context.Context, job *batchv1.JobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Job, err error)
|
||||
JobExpansion
|
||||
}
|
||||
|
||||
@@ -193,3 +198,59 @@ func (c *jobs) Patch(ctx context.Context, name string, pt types.PatchType, data
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied job.
|
||||
func (c *jobs) Apply(ctx context.Context, job *batchv1.JobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Job, err error) {
|
||||
if job == nil {
|
||||
return nil, fmt.Errorf("job provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := job.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("job.Name must be provided to Apply")
|
||||
}
|
||||
result = &v1.Job{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("jobs").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
func (c *jobs) ApplyStatus(ctx context.Context, job *batchv1.JobApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Job, err error) {
|
||||
if job == nil {
|
||||
return nil, fmt.Errorf("job provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(job)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
name := job.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("job.Name must be provided to Apply")
|
||||
}
|
||||
|
||||
result = &v1.Job{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("jobs").
|
||||
Name(*name).
|
||||
SubResource("status").
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
@@ -20,12 +20,15 @@ package v1beta1
|
||||
|
||||
import (
|
||||
"context"
|
||||
json "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
v1beta1 "k8s.io/api/batch/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
batchv1beta1 "k8s.io/client-go/applyconfigurations/batch/v1beta1"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -47,6 +50,8 @@ type CronJobInterface interface {
|
||||
List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CronJobList, 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.CronJob, err error)
|
||||
Apply(ctx context.Context, cronJob *batchv1beta1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CronJob, err error)
|
||||
ApplyStatus(ctx context.Context, cronJob *batchv1beta1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CronJob, err error)
|
||||
CronJobExpansion
|
||||
}
|
||||
|
||||
@@ -193,3 +198,59 @@ func (c *cronJobs) Patch(ctx context.Context, name string, pt types.PatchType, d
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied cronJob.
|
||||
func (c *cronJobs) Apply(ctx context.Context, cronJob *batchv1beta1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
result = &v1beta1.CronJob{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("cronjobs").
|
||||
Name(*name).
|
||||
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
func (c *cronJobs) ApplyStatus(ctx context.Context, cronJob *batchv1beta1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
patchOpts := opts.ToPatchOptions()
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
|
||||
result = &v1beta1.CronJob{}
|
||||
err = c.client.Patch(types.ApplyPatchType).
|
||||
Namespace(c.ns).
|
||||
Resource("cronjobs").
|
||||
Name(*name).
|
||||
SubResource("status").
|
||||
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/batch/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"
|
||||
batchv1beta1 "k8s.io/client-go/applyconfigurations/batch/v1beta1"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
@@ -140,3 +143,48 @@ func (c *FakeCronJobs) Patch(ctx context.Context, name string, pt types.PatchTyp
|
||||
}
|
||||
return obj.(*v1beta1.CronJob), err
|
||||
}
|
||||
|
||||
// Apply takes the given apply declarative configuration, applies it and returns the applied cronJob.
|
||||
func (c *FakeCronJobs) Apply(ctx context.Context, cronJob *batchv1beta1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, *name, types.ApplyPatchType, data), &v1beta1.CronJob{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.CronJob), err
|
||||
}
|
||||
|
||||
// ApplyStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||
func (c *FakeCronJobs) ApplyStatus(ctx context.Context, cronJob *batchv1beta1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CronJob, err error) {
|
||||
if cronJob == nil {
|
||||
return nil, fmt.Errorf("cronJob provided to Apply must not be nil")
|
||||
}
|
||||
data, err := json.Marshal(cronJob)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name := cronJob.Name
|
||||
if name == nil {
|
||||
return nil, fmt.Errorf("cronJob.Name must be provided to Apply")
|
||||
}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1beta1.CronJob{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1beta1.CronJob), err
|
||||
}
|
||||
|
Reference in New Issue
Block a user