Regenerate clients to support application/apply-patch+cbor.

This commit is contained in:
Ben Luddy
2024-10-29 13:38:12 -04:00
parent 37ed906a33
commit 41f55d7117
7 changed files with 26 additions and 34 deletions

View File

@@ -20,7 +20,6 @@ package v1
import (
context "context"
json "encoding/json"
fmt "fmt"
appsv1 "k8s.io/api/apps/v1"
@@ -32,6 +31,7 @@ import (
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
apply "k8s.io/client-go/util/apply"
)
// DeploymentsGetter has a method to return a DeploymentInterface.
@@ -120,20 +120,19 @@ func (c *deployments) ApplyScale(ctx context.Context, deploymentName string, sca
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(scale)
request, err := apply.NewRequest(c.GetClient(), scale)
if err != nil {
return nil, err
}
result = &autoscalingv1.Scale{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
UseProtobufAsDefault().
Namespace(c.GetNamespace()).
Resource("deployments").
Name(deploymentName).
SubResource("scale").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return

View File

@@ -20,7 +20,6 @@ package v1
import (
context "context"
json "encoding/json"
fmt "fmt"
appsv1 "k8s.io/api/apps/v1"
@@ -32,6 +31,7 @@ import (
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
apply "k8s.io/client-go/util/apply"
)
// ReplicaSetsGetter has a method to return a ReplicaSetInterface.
@@ -120,20 +120,19 @@ func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, sca
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(scale)
request, err := apply.NewRequest(c.GetClient(), scale)
if err != nil {
return nil, err
}
result = &autoscalingv1.Scale{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
UseProtobufAsDefault().
Namespace(c.GetNamespace()).
Resource("replicasets").
Name(replicaSetName).
SubResource("scale").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return

View File

@@ -20,7 +20,6 @@ package v1
import (
context "context"
json "encoding/json"
fmt "fmt"
appsv1 "k8s.io/api/apps/v1"
@@ -32,6 +31,7 @@ import (
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
apply "k8s.io/client-go/util/apply"
)
// StatefulSetsGetter has a method to return a StatefulSetInterface.
@@ -120,20 +120,19 @@ func (c *statefulSets) ApplyScale(ctx context.Context, statefulSetName string, s
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(scale)
request, err := apply.NewRequest(c.GetClient(), scale)
if err != nil {
return nil, err
}
result = &autoscalingv1.Scale{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
UseProtobufAsDefault().
Namespace(c.GetNamespace()).
Resource("statefulsets").
Name(statefulSetName).
SubResource("scale").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return

View File

@@ -20,7 +20,6 @@ package v1beta2
import (
context "context"
json "encoding/json"
fmt "fmt"
appsv1beta2 "k8s.io/api/apps/v1beta2"
@@ -30,6 +29,7 @@ import (
applyconfigurationsappsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
apply "k8s.io/client-go/util/apply"
)
// StatefulSetsGetter has a method to return a StatefulSetInterface.
@@ -118,20 +118,19 @@ func (c *statefulSets) ApplyScale(ctx context.Context, statefulSetName string, s
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(scale)
request, err := apply.NewRequest(c.GetClient(), scale)
if err != nil {
return nil, err
}
result = &appsv1beta2.Scale{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
UseProtobufAsDefault().
Namespace(c.GetNamespace()).
Resource("statefulsets").
Name(statefulSetName).
SubResource("scale").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return

View File

@@ -20,7 +20,6 @@ package v1beta1
import (
context "context"
json "encoding/json"
fmt "fmt"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
@@ -30,6 +29,7 @@ import (
applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
apply "k8s.io/client-go/util/apply"
)
// DeploymentsGetter has a method to return a DeploymentInterface.
@@ -118,20 +118,19 @@ func (c *deployments) ApplyScale(ctx context.Context, deploymentName string, sca
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(scale)
request, err := apply.NewRequest(c.GetClient(), scale)
if err != nil {
return nil, err
}
result = &extensionsv1beta1.Scale{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
UseProtobufAsDefault().
Namespace(c.GetNamespace()).
Resource("deployments").
Name(deploymentName).
SubResource("scale").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return

View File

@@ -20,7 +20,6 @@ package v1beta1
import (
context "context"
json "encoding/json"
fmt "fmt"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
@@ -30,6 +29,7 @@ import (
applyconfigurationsextensionsv1beta1 "k8s.io/client-go/applyconfigurations/extensions/v1beta1"
gentype "k8s.io/client-go/gentype"
scheme "k8s.io/client-go/kubernetes/scheme"
apply "k8s.io/client-go/util/apply"
)
// ReplicaSetsGetter has a method to return a ReplicaSetInterface.
@@ -118,20 +118,19 @@ func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, sca
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(scale)
request, err := apply.NewRequest(c.GetClient(), scale)
if err != nil {
return nil, err
}
result = &extensionsv1beta1.Scale{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
UseProtobufAsDefault().
Namespace(c.GetNamespace()).
Resource("replicasets").
Name(replicaSetName).
SubResource("scale").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return

View File

@@ -20,7 +20,6 @@ package v1
import (
context "context"
json "encoding/json"
fmt "fmt"
time "time"
@@ -28,6 +27,7 @@ import (
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
gentype "k8s.io/client-go/gentype"
apply "k8s.io/client-go/util/apply"
consistencydetector "k8s.io/client-go/util/consistencydetector"
watchlist "k8s.io/client-go/util/watchlist"
extensionsv1 "k8s.io/code-generator/examples/crd/apis/extensions/v1"
@@ -204,21 +204,20 @@ func (c *testTypes) ApplyExtended(ctx context.Context, testType *applyconfigurat
return nil, fmt.Errorf("testType provided to ApplyExtended must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(testType)
if err != nil {
return nil, err
}
name := testType.Name
if name == nil {
return nil, fmt.Errorf("testType.Name must be provided to ApplyExtended")
}
request, err := apply.NewRequest(c.GetClient(), testType)
if err != nil {
return nil, err
}
result = &extensionsv1.TestType{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
Namespace(c.GetNamespace()).
Resource("testtypes").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
@@ -275,19 +274,18 @@ func (c *testTypes) ApplySubresource(ctx context.Context, testTypeName string, t
return nil, fmt.Errorf("testSubresource provided to ApplySubresource must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(testSubresource)
request, err := apply.NewRequest(c.GetClient(), testSubresource)
if err != nil {
return nil, err
}
result = &extensionsv1.TestSubresource{}
err = c.GetClient().Patch(types.ApplyPatchType).
err = request.
Namespace(c.GetNamespace()).
Resource("testtypes").
Name(testTypeName).
SubResource("subresource").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return