mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Merge pull request #99849 from jpbetz/apply-subresources
Add subresource apply support to client-go
This commit is contained in:
commit
7807bb03ba
@ -37,6 +37,7 @@ import (
|
|||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
appsv1apply "k8s.io/client-go/applyconfigurations/apps/v1"
|
appsv1apply "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
appsv1autoscaling "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
|
appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
|
||||||
@ -266,6 +267,10 @@ func (c conversionClient) UpdateScale(ctx context.Context, name string, scale *a
|
|||||||
return nil, errors.New("UpdateScale() is not implemented for conversionClient")
|
return nil, errors.New("UpdateScale() is not implemented for conversionClient")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c conversionClient) ApplyScale(ctx context.Context, name string, scale *appsv1autoscaling.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error) {
|
||||||
|
return nil, errors.New("ApplyScale() is not implemented for conversionClient")
|
||||||
|
}
|
||||||
|
|
||||||
func convertSlice(rcList []*v1.ReplicationController) ([]*apps.ReplicaSet, error) {
|
func convertSlice(rcList []*v1.ReplicationController) ([]*apps.ReplicaSet, error) {
|
||||||
rsList := make([]*apps.ReplicaSet, 0, len(rcList))
|
rsList := make([]*apps.ReplicaSet, 0, len(rcList))
|
||||||
for _, rc := range rcList {
|
for _, rc := range rcList {
|
||||||
|
@ -34,6 +34,7 @@ const (
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
|
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
|
// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
// StatefulSet represents a set of pods with consistent identities.
|
// StatefulSet represents a set of pods with consistent identities.
|
||||||
@ -248,6 +249,7 @@ type StatefulSetList struct {
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
|
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
|
// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
// Deployment enables declarative updates for Pods and ReplicaSets.
|
// Deployment enables declarative updates for Pods and ReplicaSets.
|
||||||
@ -682,6 +684,7 @@ type DaemonSetList struct {
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
|
// +genclient:method=GetScale,verb=get,subresource=scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
|
// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
|
// ReplicaSet ensures that a specified number of pod replicas are running at any given time.
|
||||||
|
@ -83,6 +83,7 @@ type Scale struct {
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
|
// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
|
||||||
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
|
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
|
||||||
|
// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=Scale,result=Scale
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
// +k8s:prerelease-lifecycle-gen:introduced=1.8
|
// +k8s:prerelease-lifecycle-gen:introduced=1.8
|
||||||
// +k8s:prerelease-lifecycle-gen:deprecated=1.9
|
// +k8s:prerelease-lifecycle-gen:deprecated=1.9
|
||||||
|
@ -74,6 +74,7 @@ type Scale struct {
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
|
// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
|
||||||
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
|
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
|
||||||
|
// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=Scale,result=Scale
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
// +k8s:prerelease-lifecycle-gen:introduced=1.1
|
// +k8s:prerelease-lifecycle-gen:introduced=1.1
|
||||||
// +k8s:prerelease-lifecycle-gen:deprecated=1.8
|
// +k8s:prerelease-lifecycle-gen:deprecated=1.8
|
||||||
@ -828,6 +829,7 @@ type IngressBackend struct {
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
|
// +genclient:method=GetScale,verb=get,subresource=scale,result=Scale
|
||||||
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
|
// +genclient:method=UpdateScale,verb=update,subresource=scale,input=Scale,result=Scale
|
||||||
|
// +genclient:method=ApplyScale,verb=apply,subresource=scale,input=Scale,result=Scale
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
// +k8s:prerelease-lifecycle-gen:introduced=1.2
|
// +k8s:prerelease-lifecycle-gen:introduced=1.2
|
||||||
// +k8s:prerelease-lifecycle-gen:deprecated=1.8
|
// +k8s:prerelease-lifecycle-gen:deprecated=1.8
|
||||||
|
@ -0,0 +1,233 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1beta2
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1beta2 "k8s.io/api/apps/v1beta2"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ScaleApplyConfiguration represents an declarative configuration of the Scale type for use
|
||||||
|
// with apply.
|
||||||
|
type ScaleApplyConfiguration struct {
|
||||||
|
v1.TypeMetaApplyConfiguration `json:",inline"`
|
||||||
|
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||||
|
Spec *v1beta2.ScaleSpec `json:"spec,omitempty"`
|
||||||
|
Status *v1beta2.ScaleStatus `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScaleApplyConfiguration constructs an declarative configuration of the Scale type for use with
|
||||||
|
// apply.
|
||||||
|
func Scale() *ScaleApplyConfiguration {
|
||||||
|
return &ScaleApplyConfiguration{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithKind sets the Kind field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Kind field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithKind(value string) *ScaleApplyConfiguration {
|
||||||
|
b.Kind = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the APIVersion field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithAPIVersion(value string) *ScaleApplyConfiguration {
|
||||||
|
b.APIVersion = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithName sets the Name field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Name field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Name = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithGenerateName sets the GenerateName field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the GenerateName field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithGenerateName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.GenerateName = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithNamespace sets the Namespace field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Namespace field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithNamespace(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Namespace = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSelfLink sets the SelfLink field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the SelfLink field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithSelfLink(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.SelfLink = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithUID sets the UID field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the UID field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithUID(value types.UID) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.UID = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the ResourceVersion field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithResourceVersion(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.ResourceVersion = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithGeneration sets the Generation field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Generation field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithGeneration(value int64) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Generation = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the CreationTimestamp field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.CreationTimestamp = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.DeletionTimestamp = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.DeletionGracePeriodSeconds = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLabels puts the entries into the Labels field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the entries provided by each call will be put on the Labels field,
|
||||||
|
// overwriting an existing map entries in Labels field with the same key.
|
||||||
|
func (b *ScaleApplyConfiguration) WithLabels(entries map[string]string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
if b.Labels == nil && len(entries) > 0 {
|
||||||
|
b.Labels = make(map[string]string, len(entries))
|
||||||
|
}
|
||||||
|
for k, v := range entries {
|
||||||
|
b.Labels[k] = v
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the entries provided by each call will be put on the Annotations field,
|
||||||
|
// overwriting an existing map entries in Annotations field with the same key.
|
||||||
|
func (b *ScaleApplyConfiguration) WithAnnotations(entries map[string]string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
if b.Annotations == nil && len(entries) > 0 {
|
||||||
|
b.Annotations = make(map[string]string, len(entries))
|
||||||
|
}
|
||||||
|
for k, v := range entries {
|
||||||
|
b.Annotations[k] = v
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
|
||||||
|
func (b *ScaleApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
for i := range values {
|
||||||
|
if values[i] == nil {
|
||||||
|
panic("nil value passed to WithOwnerReferences")
|
||||||
|
}
|
||||||
|
b.OwnerReferences = append(b.OwnerReferences, *values[i])
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, values provided by each call will be appended to the Finalizers field.
|
||||||
|
func (b *ScaleApplyConfiguration) WithFinalizers(values ...string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
for i := range values {
|
||||||
|
b.Finalizers = append(b.Finalizers, values[i])
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithClusterName sets the ClusterName field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the ClusterName field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithClusterName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.ClusterName = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *ScaleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||||
|
if b.ObjectMetaApplyConfiguration == nil {
|
||||||
|
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSpec sets the Spec field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Spec field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithSpec(value v1beta2.ScaleSpec) *ScaleApplyConfiguration {
|
||||||
|
b.Spec = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithStatus sets the Status field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Status field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithStatus(value v1beta2.ScaleStatus) *ScaleApplyConfiguration {
|
||||||
|
b.Status = &value
|
||||||
|
return b
|
||||||
|
}
|
@ -0,0 +1,232 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ScaleApplyConfiguration represents an declarative configuration of the Scale type for use
|
||||||
|
// with apply.
|
||||||
|
type ScaleApplyConfiguration struct {
|
||||||
|
v1.TypeMetaApplyConfiguration `json:",inline"`
|
||||||
|
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||||
|
Spec *ScaleSpecApplyConfiguration `json:"spec,omitempty"`
|
||||||
|
Status *ScaleStatusApplyConfiguration `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScaleApplyConfiguration constructs an declarative configuration of the Scale type for use with
|
||||||
|
// apply.
|
||||||
|
func Scale() *ScaleApplyConfiguration {
|
||||||
|
return &ScaleApplyConfiguration{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithKind sets the Kind field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Kind field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithKind(value string) *ScaleApplyConfiguration {
|
||||||
|
b.Kind = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the APIVersion field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithAPIVersion(value string) *ScaleApplyConfiguration {
|
||||||
|
b.APIVersion = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithName sets the Name field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Name field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Name = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithGenerateName sets the GenerateName field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the GenerateName field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithGenerateName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.GenerateName = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithNamespace sets the Namespace field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Namespace field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithNamespace(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Namespace = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSelfLink sets the SelfLink field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the SelfLink field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithSelfLink(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.SelfLink = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithUID sets the UID field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the UID field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithUID(value types.UID) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.UID = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the ResourceVersion field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithResourceVersion(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.ResourceVersion = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithGeneration sets the Generation field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Generation field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithGeneration(value int64) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Generation = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the CreationTimestamp field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.CreationTimestamp = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.DeletionTimestamp = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.DeletionGracePeriodSeconds = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLabels puts the entries into the Labels field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the entries provided by each call will be put on the Labels field,
|
||||||
|
// overwriting an existing map entries in Labels field with the same key.
|
||||||
|
func (b *ScaleApplyConfiguration) WithLabels(entries map[string]string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
if b.Labels == nil && len(entries) > 0 {
|
||||||
|
b.Labels = make(map[string]string, len(entries))
|
||||||
|
}
|
||||||
|
for k, v := range entries {
|
||||||
|
b.Labels[k] = v
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the entries provided by each call will be put on the Annotations field,
|
||||||
|
// overwriting an existing map entries in Annotations field with the same key.
|
||||||
|
func (b *ScaleApplyConfiguration) WithAnnotations(entries map[string]string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
if b.Annotations == nil && len(entries) > 0 {
|
||||||
|
b.Annotations = make(map[string]string, len(entries))
|
||||||
|
}
|
||||||
|
for k, v := range entries {
|
||||||
|
b.Annotations[k] = v
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
|
||||||
|
func (b *ScaleApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
for i := range values {
|
||||||
|
if values[i] == nil {
|
||||||
|
panic("nil value passed to WithOwnerReferences")
|
||||||
|
}
|
||||||
|
b.OwnerReferences = append(b.OwnerReferences, *values[i])
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, values provided by each call will be appended to the Finalizers field.
|
||||||
|
func (b *ScaleApplyConfiguration) WithFinalizers(values ...string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
for i := range values {
|
||||||
|
b.Finalizers = append(b.Finalizers, values[i])
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithClusterName sets the ClusterName field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the ClusterName field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithClusterName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.ClusterName = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *ScaleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||||
|
if b.ObjectMetaApplyConfiguration == nil {
|
||||||
|
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSpec sets the Spec field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Spec field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithSpec(value *ScaleSpecApplyConfiguration) *ScaleApplyConfiguration {
|
||||||
|
b.Spec = value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithStatus sets the Status field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Status field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithStatus(value *ScaleStatusApplyConfiguration) *ScaleApplyConfiguration {
|
||||||
|
b.Status = value
|
||||||
|
return b
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
// ScaleSpecApplyConfiguration represents an declarative configuration of the ScaleSpec type for use
|
||||||
|
// with apply.
|
||||||
|
type ScaleSpecApplyConfiguration struct {
|
||||||
|
Replicas *int32 `json:"replicas,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScaleSpecApplyConfiguration constructs an declarative configuration of the ScaleSpec type for use with
|
||||||
|
// apply.
|
||||||
|
func ScaleSpec() *ScaleSpecApplyConfiguration {
|
||||||
|
return &ScaleSpecApplyConfiguration{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithReplicas sets the Replicas field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Replicas field is set to the value of the last call.
|
||||||
|
func (b *ScaleSpecApplyConfiguration) WithReplicas(value int32) *ScaleSpecApplyConfiguration {
|
||||||
|
b.Replicas = &value
|
||||||
|
return b
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
// ScaleStatusApplyConfiguration represents an declarative configuration of the ScaleStatus type for use
|
||||||
|
// with apply.
|
||||||
|
type ScaleStatusApplyConfiguration struct {
|
||||||
|
Replicas *int32 `json:"replicas,omitempty"`
|
||||||
|
Selector *string `json:"selector,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScaleStatusApplyConfiguration constructs an declarative configuration of the ScaleStatus type for use with
|
||||||
|
// apply.
|
||||||
|
func ScaleStatus() *ScaleStatusApplyConfiguration {
|
||||||
|
return &ScaleStatusApplyConfiguration{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithReplicas sets the Replicas field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Replicas field is set to the value of the last call.
|
||||||
|
func (b *ScaleStatusApplyConfiguration) WithReplicas(value int32) *ScaleStatusApplyConfiguration {
|
||||||
|
b.Replicas = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSelector sets the Selector field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Selector field is set to the value of the last call.
|
||||||
|
func (b *ScaleStatusApplyConfiguration) WithSelector(value string) *ScaleStatusApplyConfiguration {
|
||||||
|
b.Selector = &value
|
||||||
|
return b
|
||||||
|
}
|
@ -0,0 +1,233 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1beta1
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1beta1 "k8s.io/api/extensions/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ScaleApplyConfiguration represents an declarative configuration of the Scale type for use
|
||||||
|
// with apply.
|
||||||
|
type ScaleApplyConfiguration struct {
|
||||||
|
v1.TypeMetaApplyConfiguration `json:",inline"`
|
||||||
|
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||||
|
Spec *v1beta1.ScaleSpec `json:"spec,omitempty"`
|
||||||
|
Status *v1beta1.ScaleStatus `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScaleApplyConfiguration constructs an declarative configuration of the Scale type for use with
|
||||||
|
// apply.
|
||||||
|
func Scale() *ScaleApplyConfiguration {
|
||||||
|
return &ScaleApplyConfiguration{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithKind sets the Kind field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Kind field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithKind(value string) *ScaleApplyConfiguration {
|
||||||
|
b.Kind = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the APIVersion field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithAPIVersion(value string) *ScaleApplyConfiguration {
|
||||||
|
b.APIVersion = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithName sets the Name field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Name field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Name = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithGenerateName sets the GenerateName field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the GenerateName field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithGenerateName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.GenerateName = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithNamespace sets the Namespace field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Namespace field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithNamespace(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Namespace = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSelfLink sets the SelfLink field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the SelfLink field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithSelfLink(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.SelfLink = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithUID sets the UID field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the UID field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithUID(value types.UID) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.UID = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the ResourceVersion field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithResourceVersion(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.ResourceVersion = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithGeneration sets the Generation field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Generation field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithGeneration(value int64) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.Generation = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the CreationTimestamp field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.CreationTimestamp = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.DeletionTimestamp = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.DeletionGracePeriodSeconds = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLabels puts the entries into the Labels field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the entries provided by each call will be put on the Labels field,
|
||||||
|
// overwriting an existing map entries in Labels field with the same key.
|
||||||
|
func (b *ScaleApplyConfiguration) WithLabels(entries map[string]string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
if b.Labels == nil && len(entries) > 0 {
|
||||||
|
b.Labels = make(map[string]string, len(entries))
|
||||||
|
}
|
||||||
|
for k, v := range entries {
|
||||||
|
b.Labels[k] = v
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the entries provided by each call will be put on the Annotations field,
|
||||||
|
// overwriting an existing map entries in Annotations field with the same key.
|
||||||
|
func (b *ScaleApplyConfiguration) WithAnnotations(entries map[string]string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
if b.Annotations == nil && len(entries) > 0 {
|
||||||
|
b.Annotations = make(map[string]string, len(entries))
|
||||||
|
}
|
||||||
|
for k, v := range entries {
|
||||||
|
b.Annotations[k] = v
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
|
||||||
|
func (b *ScaleApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
for i := range values {
|
||||||
|
if values[i] == nil {
|
||||||
|
panic("nil value passed to WithOwnerReferences")
|
||||||
|
}
|
||||||
|
b.OwnerReferences = append(b.OwnerReferences, *values[i])
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
|
||||||
|
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||||
|
// If called multiple times, values provided by each call will be appended to the Finalizers field.
|
||||||
|
func (b *ScaleApplyConfiguration) WithFinalizers(values ...string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
for i := range values {
|
||||||
|
b.Finalizers = append(b.Finalizers, values[i])
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithClusterName sets the ClusterName field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the ClusterName field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithClusterName(value string) *ScaleApplyConfiguration {
|
||||||
|
b.ensureObjectMetaApplyConfigurationExists()
|
||||||
|
b.ClusterName = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *ScaleApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||||
|
if b.ObjectMetaApplyConfiguration == nil {
|
||||||
|
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSpec sets the Spec field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Spec field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithSpec(value v1beta1.ScaleSpec) *ScaleApplyConfiguration {
|
||||||
|
b.Spec = &value
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithStatus sets the Status field in the declarative configuration to the given value
|
||||||
|
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||||
|
// If called multiple times, the Status field is set to the value of the last call.
|
||||||
|
func (b *ScaleApplyConfiguration) WithStatus(value v1beta1.ScaleStatus) *ScaleApplyConfiguration {
|
||||||
|
b.Status = &value
|
||||||
|
return b
|
||||||
|
}
|
@ -259,6 +259,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
|||||||
return &appsv1beta2.RollingUpdateDeploymentApplyConfiguration{}
|
return &appsv1beta2.RollingUpdateDeploymentApplyConfiguration{}
|
||||||
case v1beta2.SchemeGroupVersion.WithKind("RollingUpdateStatefulSetStrategy"):
|
case v1beta2.SchemeGroupVersion.WithKind("RollingUpdateStatefulSetStrategy"):
|
||||||
return &appsv1beta2.RollingUpdateStatefulSetStrategyApplyConfiguration{}
|
return &appsv1beta2.RollingUpdateStatefulSetStrategyApplyConfiguration{}
|
||||||
|
case v1beta2.SchemeGroupVersion.WithKind("Scale"):
|
||||||
|
return &appsv1beta2.ScaleApplyConfiguration{}
|
||||||
case v1beta2.SchemeGroupVersion.WithKind("StatefulSet"):
|
case v1beta2.SchemeGroupVersion.WithKind("StatefulSet"):
|
||||||
return &appsv1beta2.StatefulSetApplyConfiguration{}
|
return &appsv1beta2.StatefulSetApplyConfiguration{}
|
||||||
case v1beta2.SchemeGroupVersion.WithKind("StatefulSetCondition"):
|
case v1beta2.SchemeGroupVersion.WithKind("StatefulSetCondition"):
|
||||||
@ -279,6 +281,12 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
|||||||
return &applyconfigurationsautoscalingv1.HorizontalPodAutoscalerSpecApplyConfiguration{}
|
return &applyconfigurationsautoscalingv1.HorizontalPodAutoscalerSpecApplyConfiguration{}
|
||||||
case autoscalingv1.SchemeGroupVersion.WithKind("HorizontalPodAutoscalerStatus"):
|
case autoscalingv1.SchemeGroupVersion.WithKind("HorizontalPodAutoscalerStatus"):
|
||||||
return &applyconfigurationsautoscalingv1.HorizontalPodAutoscalerStatusApplyConfiguration{}
|
return &applyconfigurationsautoscalingv1.HorizontalPodAutoscalerStatusApplyConfiguration{}
|
||||||
|
case autoscalingv1.SchemeGroupVersion.WithKind("Scale"):
|
||||||
|
return &applyconfigurationsautoscalingv1.ScaleApplyConfiguration{}
|
||||||
|
case autoscalingv1.SchemeGroupVersion.WithKind("ScaleSpec"):
|
||||||
|
return &applyconfigurationsautoscalingv1.ScaleSpecApplyConfiguration{}
|
||||||
|
case autoscalingv1.SchemeGroupVersion.WithKind("ScaleStatus"):
|
||||||
|
return &applyconfigurationsautoscalingv1.ScaleStatusApplyConfiguration{}
|
||||||
|
|
||||||
// Group=autoscaling, Version=v2beta1
|
// Group=autoscaling, Version=v2beta1
|
||||||
case v2beta1.SchemeGroupVersion.WithKind("ContainerResourceMetricSource"):
|
case v2beta1.SchemeGroupVersion.WithKind("ContainerResourceMetricSource"):
|
||||||
@ -903,6 +911,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
|||||||
return &applyconfigurationsextensionsv1beta1.RunAsUserStrategyOptionsApplyConfiguration{}
|
return &applyconfigurationsextensionsv1beta1.RunAsUserStrategyOptionsApplyConfiguration{}
|
||||||
case extensionsv1beta1.SchemeGroupVersion.WithKind("RuntimeClassStrategyOptions"):
|
case extensionsv1beta1.SchemeGroupVersion.WithKind("RuntimeClassStrategyOptions"):
|
||||||
return &applyconfigurationsextensionsv1beta1.RuntimeClassStrategyOptionsApplyConfiguration{}
|
return &applyconfigurationsextensionsv1beta1.RuntimeClassStrategyOptionsApplyConfiguration{}
|
||||||
|
case extensionsv1beta1.SchemeGroupVersion.WithKind("Scale"):
|
||||||
|
return &applyconfigurationsextensionsv1beta1.ScaleApplyConfiguration{}
|
||||||
case extensionsv1beta1.SchemeGroupVersion.WithKind("SELinuxStrategyOptions"):
|
case extensionsv1beta1.SchemeGroupVersion.WithKind("SELinuxStrategyOptions"):
|
||||||
return &applyconfigurationsextensionsv1beta1.SELinuxStrategyOptionsApplyConfiguration{}
|
return &applyconfigurationsextensionsv1beta1.SELinuxStrategyOptionsApplyConfiguration{}
|
||||||
case extensionsv1beta1.SchemeGroupVersion.WithKind("SupplementalGroupsStrategyOptions"):
|
case extensionsv1beta1.SchemeGroupVersion.WithKind("SupplementalGroupsStrategyOptions"):
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
rest "k8s.io/client-go/rest"
|
rest "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
@ -55,6 +56,7 @@ type DeploymentInterface interface {
|
|||||||
ApplyStatus(ctx context.Context, deployment *appsv1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Deployment, err error)
|
ApplyStatus(ctx context.Context, deployment *appsv1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Deployment, err error)
|
||||||
GetScale(ctx context.Context, deploymentName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
|
GetScale(ctx context.Context, deploymentName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
|
||||||
UpdateScale(ctx context.Context, deploymentName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
|
UpdateScale(ctx context.Context, deploymentName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
|
||||||
|
ApplyScale(ctx context.Context, deploymentName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error)
|
||||||
|
|
||||||
DeploymentExpansion
|
DeploymentExpansion
|
||||||
}
|
}
|
||||||
@ -287,3 +289,28 @@ func (c *deployments) UpdateScale(ctx context.Context, deploymentName string, sc
|
|||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *deployments) ApplyScale(ctx context.Context, deploymentName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &autoscalingv1.Scale{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("deployments").
|
||||||
|
Name(deploymentName).
|
||||||
|
SubResource("scale").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
testing "k8s.io/client-go/testing"
|
testing "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -211,3 +212,22 @@ func (c *FakeDeployments) UpdateScale(ctx context.Context, deploymentName string
|
|||||||
}
|
}
|
||||||
return obj.(*autoscalingv1.Scale), err
|
return obj.(*autoscalingv1.Scale), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *FakeDeployments) ApplyScale(ctx context.Context, deploymentName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, deploymentName, types.ApplyPatchType, data, "status"), &autoscalingv1.Scale{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*autoscalingv1.Scale), err
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
testing "k8s.io/client-go/testing"
|
testing "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -211,3 +212,22 @@ func (c *FakeReplicaSets) UpdateScale(ctx context.Context, replicaSetName string
|
|||||||
}
|
}
|
||||||
return obj.(*autoscalingv1.Scale), err
|
return obj.(*autoscalingv1.Scale), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *FakeReplicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, replicaSetName, types.ApplyPatchType, data, "status"), &autoscalingv1.Scale{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*autoscalingv1.Scale), err
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
testing "k8s.io/client-go/testing"
|
testing "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -211,3 +212,22 @@ func (c *FakeStatefulSets) UpdateScale(ctx context.Context, statefulSetName stri
|
|||||||
}
|
}
|
||||||
return obj.(*autoscalingv1.Scale), err
|
return obj.(*autoscalingv1.Scale), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *FakeStatefulSets) ApplyScale(ctx context.Context, statefulSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, statefulSetName, types.ApplyPatchType, data, "status"), &autoscalingv1.Scale{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*autoscalingv1.Scale), err
|
||||||
|
}
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
rest "k8s.io/client-go/rest"
|
rest "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
@ -55,6 +56,7 @@ type ReplicaSetInterface interface {
|
|||||||
ApplyStatus(ctx context.Context, replicaSet *appsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ReplicaSet, err error)
|
ApplyStatus(ctx context.Context, replicaSet *appsv1.ReplicaSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ReplicaSet, err error)
|
||||||
GetScale(ctx context.Context, replicaSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
|
GetScale(ctx context.Context, replicaSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
|
||||||
UpdateScale(ctx context.Context, replicaSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
|
UpdateScale(ctx context.Context, replicaSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
|
||||||
|
ApplyScale(ctx context.Context, replicaSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error)
|
||||||
|
|
||||||
ReplicaSetExpansion
|
ReplicaSetExpansion
|
||||||
}
|
}
|
||||||
@ -287,3 +289,28 @@ func (c *replicaSets) UpdateScale(ctx context.Context, replicaSetName string, sc
|
|||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &autoscalingv1.Scale{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("replicasets").
|
||||||
|
Name(replicaSetName).
|
||||||
|
SubResource("scale").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
appsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
|
||||||
|
applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
|
||||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
rest "k8s.io/client-go/rest"
|
rest "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
@ -55,6 +56,7 @@ type StatefulSetInterface interface {
|
|||||||
ApplyStatus(ctx context.Context, statefulSet *appsv1.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.StatefulSet, err error)
|
ApplyStatus(ctx context.Context, statefulSet *appsv1.StatefulSetApplyConfiguration, opts metav1.ApplyOptions) (result *v1.StatefulSet, err error)
|
||||||
GetScale(ctx context.Context, statefulSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
|
GetScale(ctx context.Context, statefulSetName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
|
||||||
UpdateScale(ctx context.Context, statefulSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
|
UpdateScale(ctx context.Context, statefulSetName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
|
||||||
|
ApplyScale(ctx context.Context, statefulSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error)
|
||||||
|
|
||||||
StatefulSetExpansion
|
StatefulSetExpansion
|
||||||
}
|
}
|
||||||
@ -287,3 +289,28 @@ func (c *statefulSets) UpdateScale(ctx context.Context, statefulSetName string,
|
|||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *statefulSets) ApplyScale(ctx context.Context, statefulSetName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &autoscalingv1.Scale{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("statefulsets").
|
||||||
|
Name(statefulSetName).
|
||||||
|
SubResource("scale").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -210,3 +210,22 @@ func (c *FakeStatefulSets) UpdateScale(ctx context.Context, statefulSetName stri
|
|||||||
}
|
}
|
||||||
return obj.(*v1beta2.Scale), err
|
return obj.(*v1beta2.Scale), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *FakeStatefulSets) ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, statefulSetName, types.ApplyPatchType, data, "status"), &v1beta2.Scale{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1beta2.Scale), err
|
||||||
|
}
|
||||||
|
@ -54,6 +54,7 @@ type StatefulSetInterface interface {
|
|||||||
ApplyStatus(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error)
|
ApplyStatus(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error)
|
||||||
GetScale(ctx context.Context, statefulSetName string, options v1.GetOptions) (*v1beta2.Scale, error)
|
GetScale(ctx context.Context, statefulSetName string, options v1.GetOptions) (*v1beta2.Scale, error)
|
||||||
UpdateScale(ctx context.Context, statefulSetName string, scale *v1beta2.Scale, opts v1.UpdateOptions) (*v1beta2.Scale, error)
|
UpdateScale(ctx context.Context, statefulSetName string, scale *v1beta2.Scale, opts v1.UpdateOptions) (*v1beta2.Scale, error)
|
||||||
|
ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta2.Scale, error)
|
||||||
|
|
||||||
StatefulSetExpansion
|
StatefulSetExpansion
|
||||||
}
|
}
|
||||||
@ -286,3 +287,28 @@ func (c *statefulSets) UpdateScale(ctx context.Context, statefulSetName string,
|
|||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *statefulSets) ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &v1beta2.Scale{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("statefulsets").
|
||||||
|
Name(statefulSetName).
|
||||||
|
SubResource("scale").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -54,6 +54,7 @@ type DeploymentInterface interface {
|
|||||||
ApplyStatus(ctx context.Context, deployment *extensionsv1beta1.DeploymentApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Deployment, err error)
|
ApplyStatus(ctx context.Context, deployment *extensionsv1beta1.DeploymentApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Deployment, err error)
|
||||||
GetScale(ctx context.Context, deploymentName string, options v1.GetOptions) (*v1beta1.Scale, error)
|
GetScale(ctx context.Context, deploymentName string, options v1.GetOptions) (*v1beta1.Scale, error)
|
||||||
UpdateScale(ctx context.Context, deploymentName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
|
UpdateScale(ctx context.Context, deploymentName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
|
||||||
|
ApplyScale(ctx context.Context, deploymentName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta1.Scale, error)
|
||||||
|
|
||||||
DeploymentExpansion
|
DeploymentExpansion
|
||||||
}
|
}
|
||||||
@ -286,3 +287,28 @@ func (c *deployments) UpdateScale(ctx context.Context, deploymentName string, sc
|
|||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *deployments) ApplyScale(ctx context.Context, deploymentName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &v1beta1.Scale{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("deployments").
|
||||||
|
Name(deploymentName).
|
||||||
|
SubResource("scale").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -210,3 +210,22 @@ func (c *FakeDeployments) UpdateScale(ctx context.Context, deploymentName string
|
|||||||
}
|
}
|
||||||
return obj.(*v1beta1.Scale), err
|
return obj.(*v1beta1.Scale), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *FakeDeployments) ApplyScale(ctx context.Context, deploymentName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, deploymentName, types.ApplyPatchType, data, "status"), &v1beta1.Scale{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1beta1.Scale), err
|
||||||
|
}
|
||||||
|
@ -210,3 +210,22 @@ func (c *FakeReplicaSets) UpdateScale(ctx context.Context, replicaSetName string
|
|||||||
}
|
}
|
||||||
return obj.(*v1beta1.Scale), err
|
return obj.(*v1beta1.Scale), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *FakeReplicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, replicaSetName, types.ApplyPatchType, data, "status"), &v1beta1.Scale{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1beta1.Scale), err
|
||||||
|
}
|
||||||
|
@ -54,6 +54,7 @@ type ReplicaSetInterface interface {
|
|||||||
ApplyStatus(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error)
|
ApplyStatus(ctx context.Context, replicaSet *extensionsv1beta1.ReplicaSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.ReplicaSet, err error)
|
||||||
GetScale(ctx context.Context, replicaSetName string, options v1.GetOptions) (*v1beta1.Scale, error)
|
GetScale(ctx context.Context, replicaSetName string, options v1.GetOptions) (*v1beta1.Scale, error)
|
||||||
UpdateScale(ctx context.Context, replicaSetName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
|
UpdateScale(ctx context.Context, replicaSetName string, scale *v1beta1.Scale, opts v1.UpdateOptions) (*v1beta1.Scale, error)
|
||||||
|
ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta1.Scale, error)
|
||||||
|
|
||||||
ReplicaSetExpansion
|
ReplicaSetExpansion
|
||||||
}
|
}
|
||||||
@ -286,3 +287,28 @@ func (c *replicaSets) UpdateScale(ctx context.Context, replicaSetName string, sc
|
|||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ApplyScale takes top resource name and the apply declarative configuration for scale,
|
||||||
|
// applies it and returns the applied scale, and an error, if there is any.
|
||||||
|
func (c *replicaSets) ApplyScale(ctx context.Context, replicaSetName string, scale *extensionsv1beta1.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.Scale, err error) {
|
||||||
|
if scale == nil {
|
||||||
|
return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := json.Marshal(scale)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &v1beta1.Scale{}
|
||||||
|
err = c.client.Patch(types.ApplyPatchType).
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("replicasets").
|
||||||
|
Name(replicaSetName).
|
||||||
|
SubResource("scale").
|
||||||
|
VersionedParams(&patchOpts, scheme.ParameterCodec).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -63,11 +63,12 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
|||||||
pkgTypes := packageTypesForInputDirs(context, arguments.InputDirs, arguments.OutputPackagePath)
|
pkgTypes := packageTypesForInputDirs(context, arguments.InputDirs, arguments.OutputPackagePath)
|
||||||
customArgs := arguments.CustomArgs.(*applygenargs.CustomArgs)
|
customArgs := arguments.CustomArgs.(*applygenargs.CustomArgs)
|
||||||
initialTypes := customArgs.ExternalApplyConfigurations
|
initialTypes := customArgs.ExternalApplyConfigurations
|
||||||
refs := refGraphForReachableTypes(pkgTypes, initialTypes)
|
refs := refGraphForReachableTypes(context.Universe, pkgTypes, initialTypes)
|
||||||
typeModels, err := newTypeModels(customArgs.OpenAPISchemaFilePath, pkgTypes)
|
typeModels, err := newTypeModels(customArgs.OpenAPISchemaFilePath, pkgTypes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Fatalf("Failed build type models from typeModels %s: %v", customArgs.OpenAPISchemaFilePath, err)
|
klog.Fatalf("Failed build type models from typeModels %s: %v", customArgs.OpenAPISchemaFilePath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
groupVersions := make(map[string]clientgentypes.GroupVersions)
|
groupVersions := make(map[string]clientgentypes.GroupVersions)
|
||||||
groupGoNames := make(map[string]string)
|
groupGoNames := make(map[string]string)
|
||||||
applyConfigsForGroupVersion := make(map[clientgentypes.GroupVersion][]applyConfig)
|
applyConfigsForGroupVersion := make(map[clientgentypes.GroupVersion][]applyConfig)
|
||||||
|
@ -28,7 +28,7 @@ type refGraph map[types.Name]string
|
|||||||
|
|
||||||
// refGraphForReachableTypes returns a refGraph that contains all reachable types from
|
// refGraphForReachableTypes returns a refGraph that contains all reachable types from
|
||||||
// the root clientgen types of the provided packages.
|
// the root clientgen types of the provided packages.
|
||||||
func refGraphForReachableTypes(pkgTypes map[string]*types.Package, initialTypes map[types.Name]string) refGraph {
|
func refGraphForReachableTypes(universe types.Universe, pkgTypes map[string]*types.Package, initialTypes map[types.Name]string) refGraph {
|
||||||
var refs refGraph = initialTypes
|
var refs refGraph = initialTypes
|
||||||
|
|
||||||
// Include only types that are reachable from the root clientgen types.
|
// Include only types that are reachable from the root clientgen types.
|
||||||
@ -42,6 +42,20 @@ func refGraphForReachableTypes(pkgTypes map[string]*types.Package, initialTypes
|
|||||||
if tags.GenerateClient && hasApply {
|
if tags.GenerateClient && hasApply {
|
||||||
findReachableTypes(t, reachableTypes)
|
findReachableTypes(t, reachableTypes)
|
||||||
}
|
}
|
||||||
|
// If any apply extensions have custom inputs, add them.
|
||||||
|
for _, extension := range tags.Extensions {
|
||||||
|
if extension.HasVerb("apply") {
|
||||||
|
if len(extension.InputTypeOverride) > 0 {
|
||||||
|
inputType := *t
|
||||||
|
if name, pkg := extension.Input(); len(pkg) > 0 {
|
||||||
|
inputType = *(universe.Type(types.Name{Package: pkg, Name: name}))
|
||||||
|
} else {
|
||||||
|
inputType.Name.Name = extension.InputTypeOverride
|
||||||
|
}
|
||||||
|
findReachableTypes(&inputType, reachableTypes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for pkg, p := range pkgTypes {
|
for pkg, p := range pkgTypes {
|
||||||
|
@ -54,14 +54,14 @@ func PackageForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, cli
|
|||||||
DefaultGen: generator.DefaultGen{
|
DefaultGen: generator.DefaultGen{
|
||||||
OptionalName: "fake_" + strings.ToLower(c.Namers["private"].Name(t)),
|
OptionalName: "fake_" + strings.ToLower(c.Namers["private"].Name(t)),
|
||||||
},
|
},
|
||||||
outputPackage: outputPackage,
|
outputPackage: outputPackage,
|
||||||
inputPackage: inputPackage,
|
inputPackage: inputPackage,
|
||||||
group: gv.Group.NonEmpty(),
|
group: gv.Group.NonEmpty(),
|
||||||
version: gv.Version.String(),
|
version: gv.Version.String(),
|
||||||
groupGoName: groupGoName,
|
groupGoName: groupGoName,
|
||||||
typeToMatch: t,
|
typeToMatch: t,
|
||||||
imports: generator.NewImportTracker(),
|
imports: generator.NewImportTracker(),
|
||||||
applyBuilderPackage: applyBuilderPackage,
|
applyConfigurationPackage: applyBuilderPackage,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,14 +33,14 @@ import (
|
|||||||
// genFakeForType produces a file for each top-level type.
|
// genFakeForType produces a file for each top-level type.
|
||||||
type genFakeForType struct {
|
type genFakeForType struct {
|
||||||
generator.DefaultGen
|
generator.DefaultGen
|
||||||
outputPackage string
|
outputPackage string
|
||||||
group string
|
group string
|
||||||
version string
|
version string
|
||||||
groupGoName string
|
groupGoName string
|
||||||
inputPackage string
|
inputPackage string
|
||||||
typeToMatch *types.Type
|
typeToMatch *types.Type
|
||||||
imports namer.ImportTracker
|
imports namer.ImportTracker
|
||||||
applyBuilderPackage string
|
applyConfigurationPackage string
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ generator.Generator = &genFakeForType{}
|
var _ generator.Generator = &genFakeForType{}
|
||||||
@ -166,11 +166,11 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
|
|||||||
"ExtractFromListOptions": c.Universe.Function(types.Name{Package: pkgClientGoTesting, Name: "ExtractFromListOptions"}),
|
"ExtractFromListOptions": c.Universe.Function(types.Name{Package: pkgClientGoTesting, Name: "ExtractFromListOptions"}),
|
||||||
}
|
}
|
||||||
|
|
||||||
generateApply := len(g.applyBuilderPackage) > 0
|
generateApply := len(g.applyConfigurationPackage) > 0
|
||||||
if generateApply {
|
if generateApply {
|
||||||
// Generated apply builder type references required for generated Apply function
|
// Generated apply builder type references required for generated Apply function
|
||||||
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
|
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
|
||||||
m["applyConfig"] = types.Ref(gopath.Join(g.applyBuilderPackage, gvString), t.Name.Name+"ApplyConfiguration")
|
m["inputApplyConfig"] = types.Ref(gopath.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
|
||||||
}
|
}
|
||||||
|
|
||||||
if tags.NonNamespaced {
|
if tags.NonNamespaced {
|
||||||
@ -223,13 +223,19 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
|
|||||||
if tags.HasVerb("applyStatus") && generateApply && genStatus(t) {
|
if tags.HasVerb("applyStatus") && generateApply && genStatus(t) {
|
||||||
sw.Do(applyStatusTemplate, m)
|
sw.Do(applyStatusTemplate, m)
|
||||||
}
|
}
|
||||||
|
_, typeGVString := util.ParsePathGroupVersion(g.inputPackage)
|
||||||
|
|
||||||
// generate extended client methods
|
// generate extended client methods
|
||||||
for _, e := range tags.Extensions {
|
for _, e := range tags.Extensions {
|
||||||
|
if e.HasVerb("apply") && !generateApply {
|
||||||
|
continue
|
||||||
|
}
|
||||||
inputType := *t
|
inputType := *t
|
||||||
resultType := *t
|
resultType := *t
|
||||||
|
inputGVString := typeGVString
|
||||||
if len(e.InputTypeOverride) > 0 {
|
if len(e.InputTypeOverride) > 0 {
|
||||||
if name, pkg := e.Input(); len(pkg) > 0 {
|
if name, pkg := e.Input(); len(pkg) > 0 {
|
||||||
|
_, inputGVString = util.ParsePathGroupVersion(pkg)
|
||||||
newType := c.Universe.Type(types.Name{Package: pkg, Name: name})
|
newType := c.Universe.Type(types.Name{Package: pkg, Name: name})
|
||||||
inputType = *newType
|
inputType = *newType
|
||||||
} else {
|
} else {
|
||||||
@ -247,6 +253,9 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
|
|||||||
m["inputType"] = &inputType
|
m["inputType"] = &inputType
|
||||||
m["resultType"] = &resultType
|
m["resultType"] = &resultType
|
||||||
m["subresourcePath"] = e.SubResourcePath
|
m["subresourcePath"] = e.SubResourcePath
|
||||||
|
if e.HasVerb("apply") {
|
||||||
|
m["inputApplyConfig"] = types.Ref(gopath.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
|
||||||
|
}
|
||||||
|
|
||||||
if e.HasVerb("get") {
|
if e.HasVerb("get") {
|
||||||
if e.IsSubresource() {
|
if e.IsSubresource() {
|
||||||
@ -293,8 +302,11 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if e.HasVerb("apply") && generateApply {
|
if e.HasVerb("apply") && generateApply {
|
||||||
// TODO: Support apply on arbitrary subresource once it is supported by the api-server.
|
if e.IsSubresource() {
|
||||||
sw.Do(adjustTemplate(e.VerbName, e.VerbType, applyTemplate), m)
|
sw.Do(adjustTemplate(e.VerbName, e.VerbType, applySubresourceTemplate), m)
|
||||||
|
} else {
|
||||||
|
sw.Do(adjustTemplate(e.VerbName, e.VerbType, applyTemplate), m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +518,7 @@ func (c *Fake$.type|publicPlural$) Patch(ctx context.Context, name string, pt $.
|
|||||||
|
|
||||||
var applyTemplate = `
|
var applyTemplate = `
|
||||||
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
|
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
|
||||||
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.inputType|private$ *$.applyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
if $.inputType|private$ == nil {
|
if $.inputType|private$ == nil {
|
||||||
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
||||||
}
|
}
|
||||||
@ -531,7 +543,7 @@ func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.inputType|privat
|
|||||||
var applyStatusTemplate = `
|
var applyStatusTemplate = `
|
||||||
// ApplyStatus was generated because the type contains a Status member.
|
// ApplyStatus was generated because the type contains a Status member.
|
||||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||||
func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, $.inputType|private$ *$.applyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
if $.inputType|private$ == nil {
|
if $.inputType|private$ == nil {
|
||||||
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
||||||
}
|
}
|
||||||
@ -552,3 +564,24 @@ func (c *Fake$.type|publicPlural$) ApplyStatus(ctx context.Context, $.inputType|
|
|||||||
return obj.(*$.resultType|raw$), err
|
return obj.(*$.resultType|raw$), err
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var applySubresourceTemplate = `
|
||||||
|
// Apply takes top resource name and the apply declarative configuration for $.subresourcePath$,
|
||||||
|
// applies it and returns the applied $.resultType|private$, and an error, if there is any.
|
||||||
|
func (c *Fake$.type|publicPlural$) Apply(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
|
if $.inputType|private$ == nil {
|
||||||
|
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
||||||
|
}
|
||||||
|
data, err := $.jsonMarshal|raw$($.inputType|private$)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
obj, err := c.Fake.
|
||||||
|
$if .namespaced$Invokes($.NewPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, $.type|private$Name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})
|
||||||
|
$else$Invokes($.NewRootPatchSubresourceAction|raw$($.type|allLowercasePlural$Resource, $.type|private$Name, $.ApplyPatchType|raw$, data, "status"), &$.resultType|raw${})$end$
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*$.resultType|raw$), err
|
||||||
|
}
|
||||||
|
`
|
||||||
|
@ -90,14 +90,20 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
template string
|
template string
|
||||||
args map[string]interface{}
|
args map[string]interface{}
|
||||||
}
|
}
|
||||||
|
_, typeGVString := util.ParsePathGroupVersion(g.inputPackage)
|
||||||
extendedMethods := []extendedInterfaceMethod{}
|
extendedMethods := []extendedInterfaceMethod{}
|
||||||
for _, e := range tags.Extensions {
|
for _, e := range tags.Extensions {
|
||||||
|
if e.HasVerb("apply") && !generateApply {
|
||||||
|
continue
|
||||||
|
}
|
||||||
inputType := *t
|
inputType := *t
|
||||||
resultType := *t
|
resultType := *t
|
||||||
|
inputGVString := typeGVString
|
||||||
// TODO: Extract this to some helper method as this code is copied into
|
// TODO: Extract this to some helper method as this code is copied into
|
||||||
// 2 other places.
|
// 2 other places.
|
||||||
if len(e.InputTypeOverride) > 0 {
|
if len(e.InputTypeOverride) > 0 {
|
||||||
if name, pkg := e.Input(); len(pkg) > 0 {
|
if name, pkg := e.Input(); len(pkg) > 0 {
|
||||||
|
_, inputGVString = util.ParsePathGroupVersion(pkg)
|
||||||
newType := c.Universe.Type(types.Name{Package: pkg, Name: name})
|
newType := c.Universe.Type(types.Name{Package: pkg, Name: name})
|
||||||
inputType = *newType
|
inputType = *newType
|
||||||
} else {
|
} else {
|
||||||
@ -118,7 +124,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
} else {
|
} else {
|
||||||
updatedVerbtemplate = e.VerbName + "(" + strings.TrimPrefix(defaultVerbTemplates[e.VerbType], strings.Title(e.VerbType)+"(")
|
updatedVerbtemplate = e.VerbName + "(" + strings.TrimPrefix(defaultVerbTemplates[e.VerbType], strings.Title(e.VerbType)+"(")
|
||||||
}
|
}
|
||||||
extendedMethods = append(extendedMethods, extendedInterfaceMethod{
|
extendedMethod := extendedInterfaceMethod{
|
||||||
template: updatedVerbtemplate,
|
template: updatedVerbtemplate,
|
||||||
args: map[string]interface{}{
|
args: map[string]interface{}{
|
||||||
"type": t,
|
"type": t,
|
||||||
@ -128,9 +134,15 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
"GetOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "GetOptions"}),
|
"GetOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "GetOptions"}),
|
||||||
"ListOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ListOptions"}),
|
"ListOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ListOptions"}),
|
||||||
"UpdateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "UpdateOptions"}),
|
"UpdateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "UpdateOptions"}),
|
||||||
|
"ApplyOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ApplyOptions"}),
|
||||||
"PatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "PatchType"}),
|
"PatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "PatchType"}),
|
||||||
|
"jsonMarshal": c.Universe.Type(types.Name{Package: "encoding/json", Name: "Marshal"}),
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
if e.HasVerb("apply") {
|
||||||
|
extendedMethod.args["inputApplyConfig"] = types.Ref(path.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
|
||||||
|
}
|
||||||
|
extendedMethods = append(extendedMethods, extendedMethod)
|
||||||
}
|
}
|
||||||
m := map[string]interface{}{
|
m := map[string]interface{}{
|
||||||
"type": t,
|
"type": t,
|
||||||
@ -162,7 +174,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
if generateApply {
|
if generateApply {
|
||||||
// Generated apply configuration type references required for generated Apply function
|
// Generated apply configuration type references required for generated Apply function
|
||||||
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
|
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
|
||||||
m["applyConfig"] = types.Ref(path.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
|
m["inputApplyConfig"] = types.Ref(path.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Do(getterComment, m)
|
sw.Do(getterComment, m)
|
||||||
@ -237,14 +249,18 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
if tags.HasVerb("applyStatus") && generateApply {
|
if tags.HasVerb("applyStatus") && generateApply {
|
||||||
sw.Do(applyStatusTemplate, m)
|
sw.Do(applyStatusTemplate, m)
|
||||||
}
|
}
|
||||||
// TODO: Add subresource support once apply subresources are supported on the server side
|
|
||||||
|
|
||||||
// generate expansion methods
|
// generate expansion methods
|
||||||
for _, e := range tags.Extensions {
|
for _, e := range tags.Extensions {
|
||||||
|
if e.HasVerb("apply") && !generateApply {
|
||||||
|
continue
|
||||||
|
}
|
||||||
inputType := *t
|
inputType := *t
|
||||||
resultType := *t
|
resultType := *t
|
||||||
|
inputGVString := typeGVString
|
||||||
if len(e.InputTypeOverride) > 0 {
|
if len(e.InputTypeOverride) > 0 {
|
||||||
if name, pkg := e.Input(); len(pkg) > 0 {
|
if name, pkg := e.Input(); len(pkg) > 0 {
|
||||||
|
_, inputGVString = util.ParsePathGroupVersion(pkg)
|
||||||
newType := c.Universe.Type(types.Name{Package: pkg, Name: name})
|
newType := c.Universe.Type(types.Name{Package: pkg, Name: name})
|
||||||
inputType = *newType
|
inputType = *newType
|
||||||
} else {
|
} else {
|
||||||
@ -262,6 +278,9 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
m["inputType"] = &inputType
|
m["inputType"] = &inputType
|
||||||
m["resultType"] = &resultType
|
m["resultType"] = &resultType
|
||||||
m["subresourcePath"] = e.SubResourcePath
|
m["subresourcePath"] = e.SubResourcePath
|
||||||
|
if e.HasVerb("apply") {
|
||||||
|
m["inputApplyConfig"] = types.Ref(path.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
|
||||||
|
}
|
||||||
|
|
||||||
if e.HasVerb("get") {
|
if e.HasVerb("get") {
|
||||||
if e.IsSubresource() {
|
if e.IsSubresource() {
|
||||||
@ -310,9 +329,12 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
sw.Do(adjustTemplate(e.VerbName, e.VerbType, patchTemplate), m)
|
sw.Do(adjustTemplate(e.VerbName, e.VerbType, patchTemplate), m)
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.HasVerb("apply") && generateApply {
|
if e.HasVerb("apply") {
|
||||||
// TODO: Support apply on arbitrary subresource once it is supported by the api-server.
|
if e.IsSubresource() {
|
||||||
sw.Do(adjustTemplate(e.VerbName, e.VerbType, applyTemplate), m)
|
sw.Do(adjustTemplate(e.VerbName, e.VerbType, applySubresourceTemplate), m)
|
||||||
|
} else {
|
||||||
|
sw.Do(adjustTemplate(e.VerbName, e.VerbType, applyTemplate), m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +366,9 @@ func buildSubresourceDefaultVerbTemplates(generateApply bool) map[string]string
|
|||||||
"update": `Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`,
|
"update": `Update(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (*$.resultType|raw$, error)`,
|
||||||
"get": `Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`,
|
"get": `Get(ctx context.Context, $.type|private$Name string, options $.GetOptions|raw$) (*$.resultType|raw$, error)`,
|
||||||
}
|
}
|
||||||
// TODO: Support apply on arbitrary subresource once it is supported by the api-server.
|
if generateApply {
|
||||||
|
m["apply"] = `Apply(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (*$.resultType|raw$, error)`
|
||||||
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,8 +385,8 @@ func buildDefaultVerbTemplates(generateApply bool) map[string]string {
|
|||||||
"patch": `Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error)`,
|
"patch": `Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error)`,
|
||||||
}
|
}
|
||||||
if generateApply {
|
if generateApply {
|
||||||
m["apply"] = `Apply(ctx context.Context, $.inputType|private$ *$.applyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)`
|
m["apply"] = `Apply(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)`
|
||||||
m["applyStatus"] = `ApplyStatus(ctx context.Context, $.inputType|private$ *$.applyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)`
|
m["applyStatus"] = `ApplyStatus(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error)`
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
@ -650,7 +674,7 @@ func (c *$.type|privatePlural$) Patch(ctx context.Context, name string, pt $.Pat
|
|||||||
|
|
||||||
var applyTemplate = `
|
var applyTemplate = `
|
||||||
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
|
// Apply takes the given apply declarative configuration, applies it and returns the applied $.resultType|private$.
|
||||||
func (c *$.type|privatePlural$) Apply(ctx context.Context, $.inputType|private$ *$.applyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) Apply(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
if $.inputType|private$ == nil {
|
if $.inputType|private$ == nil {
|
||||||
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
||||||
}
|
}
|
||||||
@ -679,7 +703,7 @@ func (c *$.type|privatePlural$) Apply(ctx context.Context, $.inputType|private$
|
|||||||
var applyStatusTemplate = `
|
var applyStatusTemplate = `
|
||||||
// ApplyStatus was generated because the type contains a Status member.
|
// ApplyStatus was generated because the type contains a Status member.
|
||||||
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
|
||||||
func (c *$.type|privatePlural$) ApplyStatus(ctx context.Context, $.inputType|private$ *$.applyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) ApplyStatus(ctx context.Context, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
if $.inputType|private$ == nil {
|
if $.inputType|private$ == nil {
|
||||||
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
||||||
}
|
}
|
||||||
@ -707,3 +731,30 @@ func (c *$.type|privatePlural$) ApplyStatus(ctx context.Context, $.inputType|pri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var applySubresourceTemplate = `
|
||||||
|
// Apply takes top resource name and the apply declarative configuration for $.subresourcePath$,
|
||||||
|
// applies it and returns the applied $.resultType|private$, and an error, if there is any.
|
||||||
|
func (c *$.type|privatePlural$) Apply(ctx context.Context, $.type|private$Name string, $.inputType|private$ *$.inputApplyConfig|raw$, opts $.ApplyOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
|
if $.inputType|private$ == nil {
|
||||||
|
return nil, fmt.Errorf("$.inputType|private$ provided to Apply must not be nil")
|
||||||
|
}
|
||||||
|
patchOpts := opts.ToPatchOptions()
|
||||||
|
data, err := $.jsonMarshal|raw$($.inputType|private$)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result = &$.resultType|raw${}
|
||||||
|
err = c.client.Patch($.ApplyPatchType|raw$).
|
||||||
|
$if .namespaced$Namespace(c.ns).$end$
|
||||||
|
Resource("$.type|resource$").
|
||||||
|
Name($.type|private$Name).
|
||||||
|
SubResource("$.subresourcePath$").
|
||||||
|
VersionedParams(&patchOpts, $.schemeParameterCodec|raw$).
|
||||||
|
Body(data).
|
||||||
|
Do(ctx).
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
`
|
||||||
|
@ -74,6 +74,7 @@ var unsupportedExtensionVerbs = []string{
|
|||||||
var inputTypeSupportedVerbs = []string{
|
var inputTypeSupportedVerbs = []string{
|
||||||
"create",
|
"create",
|
||||||
"update",
|
"update",
|
||||||
|
"apply",
|
||||||
}
|
}
|
||||||
|
|
||||||
// resultTypeSupportedVerbs is a list of verb types that supports overriding the
|
// resultTypeSupportedVerbs is a list of verb types that supports overriding the
|
||||||
@ -84,6 +85,7 @@ var resultTypeSupportedVerbs = []string{
|
|||||||
"get",
|
"get",
|
||||||
"list",
|
"list",
|
||||||
"patch",
|
"patch",
|
||||||
|
"apply",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extensions allows to extend the default set of client verbs
|
// Extensions allows to extend the default set of client verbs
|
||||||
|
Loading…
Reference in New Issue
Block a user