From 411b1696ea12afe5cbd574bd4f83554839ba6a0e Mon Sep 17 00:00:00 2001 From: Erik Godding Boye Date: Fri, 24 May 2024 12:12:18 +0200 Subject: [PATCH] chore: add unserved v2 API based on v2alpha1 --- api/accurate/v2/doc.go | 3 + api/accurate/v2/groupversion_info.go | 18 ++ api/accurate/v2/subnamespace_types.go | 68 ++++++ api/accurate/v2/zz_generated.deepcopy.go | 120 +++++++++++ charts/accurate/templates/generated/crds.yaml | 109 ++++++++++ .../accurate.cybozu.com_subnamespaces.yaml | 112 ++++++++++ .../accurate/v2/subnamespace.go | 203 ++++++++++++++++++ .../accurate/v2/subnamespacespec.go | 44 ++++ .../accurate/v2/subnamespacestatus.go | 41 ++++ internal/applyconfigurations/utils.go | 12 +- 10 files changed, 729 insertions(+), 1 deletion(-) create mode 100644 api/accurate/v2/doc.go create mode 100644 api/accurate/v2/groupversion_info.go create mode 100644 api/accurate/v2/subnamespace_types.go create mode 100644 api/accurate/v2/zz_generated.deepcopy.go create mode 100644 internal/applyconfigurations/accurate/v2/subnamespace.go create mode 100644 internal/applyconfigurations/accurate/v2/subnamespacespec.go create mode 100644 internal/applyconfigurations/accurate/v2/subnamespacestatus.go diff --git a/api/accurate/v2/doc.go b/api/accurate/v2/doc.go new file mode 100644 index 0000000..9d677ac --- /dev/null +++ b/api/accurate/v2/doc.go @@ -0,0 +1,3 @@ +// +kubebuilder:object:generate=true +// +groupName=accurate.cybozu.com +package v2 diff --git a/api/accurate/v2/groupversion_info.go b/api/accurate/v2/groupversion_info.go new file mode 100644 index 0000000..2214c30 --- /dev/null +++ b/api/accurate/v2/groupversion_info.go @@ -0,0 +1,18 @@ +// Package v2 contains API Schema definitions for the accurate v2 API group +package v2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "accurate.cybozu.com", Version: "v2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/api/accurate/v2/subnamespace_types.go b/api/accurate/v2/subnamespace_types.go new file mode 100644 index 0000000..cc6390c --- /dev/null +++ b/api/accurate/v2/subnamespace_types.go @@ -0,0 +1,68 @@ +package v2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// SubNamespaceStatus defines the observed state of SubNamespace +type SubNamespaceStatus struct { + // The generation observed by the object controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions represent the latest available observations of an object's state + // +listType=map + // +listMapKey=type + // +optional + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// SubNamespaceSpec defines the desired state of SubNamespace +type SubNamespaceSpec struct { + // Labels are the labels to be propagated to the sub-namespace + // +optional + Labels map[string]string `json:"labels,omitempty"` + + // Annotations are the annotations to be propagated to the sub-namespace. + // +optional + Annotations map[string]string `json:"annotations,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:unservedversion +//+kubebuilder:subresource:status +//+genclient + +// SubNamespace is the Schema for the subnamespaces API +type SubNamespace struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the spec of SubNamespace. + // +optional + Spec SubNamespaceSpec `json:"spec,omitempty"` + + // Status is the status of SubNamespace. + // +optional + Status SubNamespaceStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// SubNamespaceList contains a list of SubNamespace +type SubNamespaceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SubNamespace `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SubNamespace{}, &SubNamespaceList{}) +} + +const ( + SubNamespaceConflict string = "Conflict" +) diff --git a/api/accurate/v2/zz_generated.deepcopy.go b/api/accurate/v2/zz_generated.deepcopy.go new file mode 100644 index 0000000..944dfc3 --- /dev/null +++ b/api/accurate/v2/zz_generated.deepcopy.go @@ -0,0 +1,120 @@ +//go:build !ignore_autogenerated + +// Code generated by controller-gen. DO NOT EDIT. + +package v2 + +import ( + "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubNamespace) DeepCopyInto(out *SubNamespace) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubNamespace. +func (in *SubNamespace) DeepCopy() *SubNamespace { + if in == nil { + return nil + } + out := new(SubNamespace) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubNamespace) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubNamespaceList) DeepCopyInto(out *SubNamespaceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SubNamespace, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubNamespaceList. +func (in *SubNamespaceList) DeepCopy() *SubNamespaceList { + if in == nil { + return nil + } + out := new(SubNamespaceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubNamespaceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubNamespaceSpec) DeepCopyInto(out *SubNamespaceSpec) { + *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubNamespaceSpec. +func (in *SubNamespaceSpec) DeepCopy() *SubNamespaceSpec { + if in == nil { + return nil + } + out := new(SubNamespaceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubNamespaceStatus) DeepCopyInto(out *SubNamespaceStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubNamespaceStatus. +func (in *SubNamespaceStatus) DeepCopy() *SubNamespaceStatus { + if in == nil { + return nil + } + out := new(SubNamespaceStatus) + in.DeepCopyInto(out) + return out +} diff --git a/charts/accurate/templates/generated/crds.yaml b/charts/accurate/templates/generated/crds.yaml index 928364f..72e379f 100644 --- a/charts/accurate/templates/generated/crds.yaml +++ b/charts/accurate/templates/generated/crds.yaml @@ -75,6 +75,115 @@ spec: type: object served: true storage: false + - name: v2 + schema: + openAPIV3Schema: + description: SubNamespace is the Schema for the subnamespaces API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s. + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s. + type: string + metadata: + type: object + spec: + description: Spec is the spec of SubNamespace. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be propagated to the sub-namespace. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels to be propagated to the sub-namespace + type: object + type: object + status: + description: Status is the status of SubNamespace. + properties: + conditions: + description: Conditions represent the latest available observations of an object's state + items: + description: |- + Condition contains details for one aspect of the current state of this API Resource. + --- + This struct is intended for direct use as an array at the field path .status.conditions. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x]. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + --- + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be + useful (see .node.status. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: The generation observed by the object controller. + format: int64 + type: integer + type: object + type: object + served: false + storage: false + subresources: + status: {} - name: v2alpha1 schema: openAPIV3Schema: diff --git a/config/crd/bases/accurate.cybozu.com_subnamespaces.yaml b/config/crd/bases/accurate.cybozu.com_subnamespaces.yaml index 547de05..75a7fdf 100644 --- a/config/crd/bases/accurate.cybozu.com_subnamespaces.yaml +++ b/config/crd/bases/accurate.cybozu.com_subnamespaces.yaml @@ -60,6 +60,118 @@ spec: type: object served: true storage: false + - name: v2 + schema: + openAPIV3Schema: + description: SubNamespace is the Schema for the subnamespaces API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s. + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s. + type: string + metadata: + type: object + spec: + description: Spec is the spec of SubNamespace. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be propagated to the + sub-namespace. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels to be propagated to the sub-namespace + type: object + type: object + status: + description: Status is the status of SubNamespace. + properties: + conditions: + description: Conditions represent the latest available observations + of an object's state + items: + description: |- + Condition contains details for one aspect of the current state of this API Resource. + --- + This struct is intended for direct use as an array at the field path .status.conditions. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x]. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + --- + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be + useful (see .node.status. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: The generation observed by the object controller. + format: int64 + type: integer + type: object + type: object + served: false + storage: false + subresources: + status: {} - name: v2alpha1 schema: openAPIV3Schema: diff --git a/internal/applyconfigurations/accurate/v2/subnamespace.go b/internal/applyconfigurations/accurate/v2/subnamespace.go new file mode 100644 index 0000000..094d9e0 --- /dev/null +++ b/internal/applyconfigurations/accurate/v2/subnamespace.go @@ -0,0 +1,203 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// SubNamespaceApplyConfiguration represents an declarative configuration of the SubNamespace type for use +// with apply. +type SubNamespaceApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *SubNamespaceSpecApplyConfiguration `json:"spec,omitempty"` + Status *SubNamespaceStatusApplyConfiguration `json:"status,omitempty"` +} + +// SubNamespace constructs an declarative configuration of the SubNamespace type for use with +// apply. +func SubNamespace(name, namespace string) *SubNamespaceApplyConfiguration { + b := &SubNamespaceApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("SubNamespace") + b.WithAPIVersion("accurate.cybozu.com/v2") + return b +} + +// 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 *SubNamespaceApplyConfiguration) WithKind(value string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithAPIVersion(value string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithName(value string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithGenerateName(value string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithNamespace(value string) *SubNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &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 *SubNamespaceApplyConfiguration) WithUID(value types.UID) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithResourceVersion(value string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithGeneration(value int64) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithLabels(entries map[string]string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithAnnotations(entries map[string]string) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithFinalizers(values ...string) *SubNamespaceApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *SubNamespaceApplyConfiguration) 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 *SubNamespaceApplyConfiguration) WithSpec(value *SubNamespaceSpecApplyConfiguration) *SubNamespaceApplyConfiguration { + 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 *SubNamespaceApplyConfiguration) WithStatus(value *SubNamespaceStatusApplyConfiguration) *SubNamespaceApplyConfiguration { + b.Status = value + return b +} diff --git a/internal/applyconfigurations/accurate/v2/subnamespacespec.go b/internal/applyconfigurations/accurate/v2/subnamespacespec.go new file mode 100644 index 0000000..866db61 --- /dev/null +++ b/internal/applyconfigurations/accurate/v2/subnamespacespec.go @@ -0,0 +1,44 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v2 + +// SubNamespaceSpecApplyConfiguration represents an declarative configuration of the SubNamespaceSpec type for use +// with apply. +type SubNamespaceSpecApplyConfiguration struct { + Labels map[string]string `json:"labels,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` +} + +// SubNamespaceSpecApplyConfiguration constructs an declarative configuration of the SubNamespaceSpec type for use with +// apply. +func SubNamespaceSpec() *SubNamespaceSpecApplyConfiguration { + return &SubNamespaceSpecApplyConfiguration{} +} + +// 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 *SubNamespaceSpecApplyConfiguration) WithLabels(entries map[string]string) *SubNamespaceSpecApplyConfiguration { + 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 *SubNamespaceSpecApplyConfiguration) WithAnnotations(entries map[string]string) *SubNamespaceSpecApplyConfiguration { + 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 +} diff --git a/internal/applyconfigurations/accurate/v2/subnamespacestatus.go b/internal/applyconfigurations/accurate/v2/subnamespacestatus.go new file mode 100644 index 0000000..708d140 --- /dev/null +++ b/internal/applyconfigurations/accurate/v2/subnamespacestatus.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v2 + +import ( + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// SubNamespaceStatusApplyConfiguration represents an declarative configuration of the SubNamespaceStatus type for use +// with apply. +type SubNamespaceStatusApplyConfiguration struct { + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"` +} + +// SubNamespaceStatusApplyConfiguration constructs an declarative configuration of the SubNamespaceStatus type for use with +// apply. +func SubNamespaceStatus() *SubNamespaceStatusApplyConfiguration { + return &SubNamespaceStatusApplyConfiguration{} +} + +// WithObservedGeneration sets the ObservedGeneration 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 ObservedGeneration field is set to the value of the last call. +func (b *SubNamespaceStatusApplyConfiguration) WithObservedGeneration(value int64) *SubNamespaceStatusApplyConfiguration { + b.ObservedGeneration = &value + return b +} + +// WithConditions adds the given value to the Conditions 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 Conditions field. +func (b *SubNamespaceStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *SubNamespaceStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} diff --git a/internal/applyconfigurations/utils.go b/internal/applyconfigurations/utils.go index 12c4ea3..16e7a27 100644 --- a/internal/applyconfigurations/utils.go +++ b/internal/applyconfigurations/utils.go @@ -3,7 +3,9 @@ package applyconfigurations import ( + v2 "github.com/cybozu-go/accurate/api/accurate/v2" v2alpha1 "github.com/cybozu-go/accurate/api/accurate/v2alpha1" + accuratev2 "github.com/cybozu-go/accurate/internal/applyconfigurations/accurate/v2" accuratev2alpha1 "github.com/cybozu-go/accurate/internal/applyconfigurations/accurate/v2alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -12,7 +14,15 @@ import ( // apply configuration type exists for the given GroupVersionKind. func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { - // Group=accurate.cybozu.com, Version=v2alpha1 + // Group=accurate.cybozu.com, Version=v2 + case v2.SchemeGroupVersion.WithKind("SubNamespace"): + return &accuratev2.SubNamespaceApplyConfiguration{} + case v2.SchemeGroupVersion.WithKind("SubNamespaceSpec"): + return &accuratev2.SubNamespaceSpecApplyConfiguration{} + case v2.SchemeGroupVersion.WithKind("SubNamespaceStatus"): + return &accuratev2.SubNamespaceStatusApplyConfiguration{} + + // Group=accurate.cybozu.com, Version=v2alpha1 case v2alpha1.SchemeGroupVersion.WithKind("SubNamespace"): return &accuratev2alpha1.SubNamespaceApplyConfiguration{} case v2alpha1.SchemeGroupVersion.WithKind("SubNamespaceSpec"):