From d27d3929f7a2b446de234851bd9be7110ff6cfca Mon Sep 17 00:00:00 2001 From: Fabian Wiesel Date: Fri, 5 Dec 2025 12:27:37 +0100 Subject: [PATCH] WIP --- api/v1/hypervisor_config_override_types.go | 72 +++++ api/v1/hypervisor_config_set_types.go | 120 +++++++ api/v1/zz_generated.deepcopy.go | 293 ++++++++++++++++++ .../api/v1/hypervisorconfigoverride.go | 226 ++++++++++++++ .../api/v1/hypervisorconfigoverridespec.go | 32 ++ .../api/v1/hypervisorconfigoverridestatus.go | 41 +++ .../api/v1/hypervisorconfigset.go | 226 ++++++++++++++ .../api/v1/hypervisorconfigsetspec.go | 36 +++ .../api/v1/hypervisorconfigsetstatus.go | 41 +++ .../api/v1/hypervisorconfigsettemplate.go | 23 ++ .../api/v1/hypervisorconfigspec.go | 113 +++++++ applyconfigurations/utils.go | 16 + .../templates/manager-rbac.yaml | 8 + ...m.cloud.sap_hypervisorconfigoverrides.yaml | 194 ++++++++++++ .../kvm.cloud.sap_hypervisorconfigsets.yaml | 235 ++++++++++++++ config/rbac/role.yaml | 8 + internal/controller/hypervisor_controller.go | 79 ++++- 17 files changed, 1757 insertions(+), 6 deletions(-) create mode 100644 api/v1/hypervisor_config_override_types.go create mode 100644 api/v1/hypervisor_config_set_types.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigoverride.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigoverridespec.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigoverridestatus.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigset.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigsetspec.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigsetstatus.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigsettemplate.go create mode 100644 applyconfigurations/api/v1/hypervisorconfigspec.go create mode 100644 config/crd/bases/kvm.cloud.sap_hypervisorconfigoverrides.yaml create mode 100644 config/crd/bases/kvm.cloud.sap_hypervisorconfigsets.yaml diff --git a/api/v1/hypervisor_config_override_types.go b/api/v1/hypervisor_config_override_types.go new file mode 100644 index 0000000..29a4ae4 --- /dev/null +++ b/api/v1/hypervisor_config_override_types.go @@ -0,0 +1,72 @@ +/* +SPDX-FileCopyrightText: Copyright 2024 SAP SE or an SAP affiliate company and cobaltcore-dev contributors +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, LibVirtVersion 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. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster +// Important: Run "make" to regenerate code after modifying this file + +// HypervisorConfigOverrideSpec overrides the desired state of Hypervisor +type HypervisorConfigOverrideSpec struct { + // Reason describes the reason for the override + Reason string `json:"reason"` + Override HypervisorConfigSpec `json:"override"` +} + +// HypervisorConfigOverrideStatus defines the observed state of HypervisorConfigOverride +type HypervisorConfigOverrideStatus struct { + // Represents the Hypervisor node conditions. + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` + + SpecHash string `json:"specHash,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,shortName=hvco +// +kubebuilder:printcolumn:JSONPath=".spec.reason",name="Reason",type="string" +// +kubebuilder:printcolumn:JSONPath=".spec.override.lifecycleEnabled",name="Lifecycle",type="boolean" +// +kubebuilder:printcolumn:JSONPath=".spec.override.highAvailability",name="High Availability",type="boolean" +// +kubebuilder:printcolumn:JSONPath=".spec.override.skipTests",name="Skip Tests",type="boolean" +// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date" + +// HypervisorConfigOverride is the Schema for overriding the config of one hypervisor crd API +type HypervisorConfigOverride struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec HypervisorConfigOverrideSpec `json:"spec,omitempty"` + Status HypervisorConfigOverrideStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// HypervisorConfigOverrideList contains a list of HypervisorConfigOverride +type HypervisorConfigOverrideList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []HypervisorConfigOverride `json:"items"` +} + +func init() { + SchemeBuilder.Register(&HypervisorConfigOverride{}, &HypervisorConfigOverrideList{}) +} diff --git a/api/v1/hypervisor_config_set_types.go b/api/v1/hypervisor_config_set_types.go new file mode 100644 index 0000000..a6adba8 --- /dev/null +++ b/api/v1/hypervisor_config_set_types.go @@ -0,0 +1,120 @@ +/* +SPDX-FileCopyrightText: Copyright 2024 SAP SE or an SAP affiliate company and cobaltcore-dev contributors +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, LibVirtVersion 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. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster +// Important: Run "make" to regenerate code after modifying this file + +// HypervisorConfigOverrideSpec overrides the desired state of Hypervisor +type HypervisorConfigSetSpec struct { + Selector *metav1.LabelSelector `json:"selector"` + Template HypervisorConfigSetTemplate `json:"template"` +} + +// HypervisorConfigSpec defines (in parts) the desired state of Hypervisor +type HypervisorConfigSpec struct { + // +kubebuilder:validation:Optional + // OperatingSystemVersion represents the desired operating system version. + OperatingSystemVersion *string `json:"version,omitempty"` + + // +kubebuilder:validation:Optional + // Reboot request an reboot after successful installation of an upgrade. + Reboot *bool `json:"reboot,omitempty"` + + // +kubebuilder:validation:Optional + // EvacuateOnReboot request an evacuation of all instances before reboot. + EvacuateOnReboot *bool `json:"evacuateOnReboot,omitempty"` + + // +kubebuilder:optional + // LifecycleEnabled enables the lifecycle management of the hypervisor via hypervisor-operator. + LifecycleEnabled *bool `json:"lifecycleEnabled,omitempty"` + + // +kubebuilder:validation:Optional + // SkipTests skips the tests during the onboarding process. + SkipTests *bool `json:"skipTests,omitempty"` + + // +kubebuilder:optional + // CustomTraits are used to apply custom traits to the hypervisor. + CustomTraits *[]string `json:"customTraits,omitempty"` + + // +kubebuilder:optional + // Aggregates are used to apply aggregates to the hypervisor. + Aggregates *[]string `json:"aggregates,omitempty"` + + // +kubebuilder:optional + // HighAvailability is used to enable the high availability handling of the hypervisor. + HighAvailability *bool `json:"highAvailability,omitempty"` + + // +kubebuilder:optional + // Require to issue a certificate from cert-manager for the hypervisor, to be used for + // secure communication with the libvirt API. + CreateCertManagerCertificate *bool `json:"createCertManagerCertificate,omitempty"` + + // +kubebuilder:optional + // InstallCertificate is used to enable the installations of the certificates via kvm-node-agent. + InstallCertificate *bool `json:"installCertificate,omitempty"` + + // +kubebuilder:optional + // +kubebuilder:validation:Enum:="";manual;auto;ha + // Maintenance indicates whether the hypervisor is in maintenance mode. + Maintenance *string `json:"maintenance,omitempty"` +} + +// A template for the hypervisor defining the values for a whole set +type HypervisorConfigSetTemplate struct { + Spec HypervisorConfigSpec `json:"spec"` +} + +// HypervisorConfigSetStatus defines the observed state of HypervisorConfigSet +type HypervisorConfigSetStatus struct { + // Represents the Hypervisor node conditions. + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` + + SpecHash string `json:"specHash,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,shortName=hvcs +// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date" + +// HypervisorConfigSet is the Schema for a set of hypervisor configs +type HypervisorConfigSet struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec HypervisorConfigSetSpec `json:"spec,omitempty"` + Status HypervisorConfigSetStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true +// HypervisorConfigSetList contains a list of HypervisorConfigSet +type HypervisorConfigSetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []HypervisorConfigSet `json:"items"` +} + +func init() { + SchemeBuilder.Register(&HypervisorConfigSet{}, &HypervisorConfigSetList{}) +} diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 999f7e7..d7bc9dd 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -186,6 +186,299 @@ func (in *Hypervisor) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HypervisorConfigOverride) DeepCopyInto(out *HypervisorConfigOverride) { + *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 HypervisorConfigOverride. +func (in *HypervisorConfigOverride) DeepCopy() *HypervisorConfigOverride { + if in == nil { + return nil + } + out := new(HypervisorConfigOverride) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HypervisorConfigOverride) 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 *HypervisorConfigOverrideList) DeepCopyInto(out *HypervisorConfigOverrideList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]HypervisorConfigOverride, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigOverrideList. +func (in *HypervisorConfigOverrideList) DeepCopy() *HypervisorConfigOverrideList { + if in == nil { + return nil + } + out := new(HypervisorConfigOverrideList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HypervisorConfigOverrideList) 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 *HypervisorConfigOverrideSpec) DeepCopyInto(out *HypervisorConfigOverrideSpec) { + *out = *in + in.Override.DeepCopyInto(&out.Override) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigOverrideSpec. +func (in *HypervisorConfigOverrideSpec) DeepCopy() *HypervisorConfigOverrideSpec { + if in == nil { + return nil + } + out := new(HypervisorConfigOverrideSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HypervisorConfigOverrideStatus) DeepCopyInto(out *HypervisorConfigOverrideStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigOverrideStatus. +func (in *HypervisorConfigOverrideStatus) DeepCopy() *HypervisorConfigOverrideStatus { + if in == nil { + return nil + } + out := new(HypervisorConfigOverrideStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HypervisorConfigSet) DeepCopyInto(out *HypervisorConfigSet) { + *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 HypervisorConfigSet. +func (in *HypervisorConfigSet) DeepCopy() *HypervisorConfigSet { + if in == nil { + return nil + } + out := new(HypervisorConfigSet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HypervisorConfigSet) 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 *HypervisorConfigSetList) DeepCopyInto(out *HypervisorConfigSetList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]HypervisorConfigSet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigSetList. +func (in *HypervisorConfigSetList) DeepCopy() *HypervisorConfigSetList { + if in == nil { + return nil + } + out := new(HypervisorConfigSetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HypervisorConfigSetList) 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 *HypervisorConfigSetSpec) DeepCopyInto(out *HypervisorConfigSetSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigSetSpec. +func (in *HypervisorConfigSetSpec) DeepCopy() *HypervisorConfigSetSpec { + if in == nil { + return nil + } + out := new(HypervisorConfigSetSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HypervisorConfigSetStatus) DeepCopyInto(out *HypervisorConfigSetStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigSetStatus. +func (in *HypervisorConfigSetStatus) DeepCopy() *HypervisorConfigSetStatus { + if in == nil { + return nil + } + out := new(HypervisorConfigSetStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HypervisorConfigSetTemplate) DeepCopyInto(out *HypervisorConfigSetTemplate) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigSetTemplate. +func (in *HypervisorConfigSetTemplate) DeepCopy() *HypervisorConfigSetTemplate { + if in == nil { + return nil + } + out := new(HypervisorConfigSetTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HypervisorConfigSpec) DeepCopyInto(out *HypervisorConfigSpec) { + *out = *in + if in.OperatingSystemVersion != nil { + in, out := &in.OperatingSystemVersion, &out.OperatingSystemVersion + *out = new(string) + **out = **in + } + if in.Reboot != nil { + in, out := &in.Reboot, &out.Reboot + *out = new(bool) + **out = **in + } + if in.EvacuateOnReboot != nil { + in, out := &in.EvacuateOnReboot, &out.EvacuateOnReboot + *out = new(bool) + **out = **in + } + if in.LifecycleEnabled != nil { + in, out := &in.LifecycleEnabled, &out.LifecycleEnabled + *out = new(bool) + **out = **in + } + if in.SkipTests != nil { + in, out := &in.SkipTests, &out.SkipTests + *out = new(bool) + **out = **in + } + if in.CustomTraits != nil { + in, out := &in.CustomTraits, &out.CustomTraits + *out = new([]string) + if **in != nil { + in, out := *in, *out + *out = make([]string, len(*in)) + copy(*out, *in) + } + } + if in.Aggregates != nil { + in, out := &in.Aggregates, &out.Aggregates + *out = new([]string) + if **in != nil { + in, out := *in, *out + *out = make([]string, len(*in)) + copy(*out, *in) + } + } + if in.HighAvailability != nil { + in, out := &in.HighAvailability, &out.HighAvailability + *out = new(bool) + **out = **in + } + if in.CreateCertManagerCertificate != nil { + in, out := &in.CreateCertManagerCertificate, &out.CreateCertManagerCertificate + *out = new(bool) + **out = **in + } + if in.InstallCertificate != nil { + in, out := &in.InstallCertificate, &out.InstallCertificate + *out = new(bool) + **out = **in + } + if in.Maintenance != nil { + in, out := &in.Maintenance, &out.Maintenance + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HypervisorConfigSpec. +func (in *HypervisorConfigSpec) DeepCopy() *HypervisorConfigSpec { + if in == nil { + return nil + } + out := new(HypervisorConfigSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HypervisorList) DeepCopyInto(out *HypervisorList) { *out = *in diff --git a/applyconfigurations/api/v1/hypervisorconfigoverride.go b/applyconfigurations/api/v1/hypervisorconfigoverride.go new file mode 100644 index 0000000..a876f27 --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigoverride.go @@ -0,0 +1,226 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// HypervisorConfigOverrideApplyConfiguration represents a declarative configuration of the HypervisorConfigOverride type for use +// with apply. +type HypervisorConfigOverrideApplyConfiguration struct { + metav1.TypeMetaApplyConfiguration `json:",inline"` + *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *HypervisorConfigOverrideSpecApplyConfiguration `json:"spec,omitempty"` + Status *HypervisorConfigOverrideStatusApplyConfiguration `json:"status,omitempty"` +} + +// HypervisorConfigOverride constructs a declarative configuration of the HypervisorConfigOverride type for use with +// apply. +func HypervisorConfigOverride(name, namespace string) *HypervisorConfigOverrideApplyConfiguration { + b := &HypervisorConfigOverrideApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("HypervisorConfigOverride") + b.WithAPIVersion("kvm.cloud.sap/v1") + return b +} +func (b HypervisorConfigOverrideApplyConfiguration) IsApplyConfiguration() {} + +// 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 *HypervisorConfigOverrideApplyConfiguration) WithKind(value string) *HypervisorConfigOverrideApplyConfiguration { + b.TypeMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithAPIVersion(value string) *HypervisorConfigOverrideApplyConfiguration { + b.TypeMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithName(value string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithGenerateName(value string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithNamespace(value string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithUID(value types.UID) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithResourceVersion(value string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithGeneration(value int64) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithLabels(entries map[string]string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithAnnotations(entries map[string]string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.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 *HypervisorConfigOverrideApplyConfiguration) WithFinalizers(values ...string) *HypervisorConfigOverrideApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *HypervisorConfigOverrideApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &metav1.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 *HypervisorConfigOverrideApplyConfiguration) WithSpec(value *HypervisorConfigOverrideSpecApplyConfiguration) *HypervisorConfigOverrideApplyConfiguration { + 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 *HypervisorConfigOverrideApplyConfiguration) WithStatus(value *HypervisorConfigOverrideStatusApplyConfiguration) *HypervisorConfigOverrideApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *HypervisorConfigOverrideApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *HypervisorConfigOverrideApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *HypervisorConfigOverrideApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *HypervisorConfigOverrideApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/applyconfigurations/api/v1/hypervisorconfigoverridespec.go b/applyconfigurations/api/v1/hypervisorconfigoverridespec.go new file mode 100644 index 0000000..ab288ce --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigoverridespec.go @@ -0,0 +1,32 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +// HypervisorConfigOverrideSpecApplyConfiguration represents a declarative configuration of the HypervisorConfigOverrideSpec type for use +// with apply. +type HypervisorConfigOverrideSpecApplyConfiguration struct { + Reason *string `json:"reason,omitempty"` + Override *HypervisorConfigSpecApplyConfiguration `json:"override,omitempty"` +} + +// HypervisorConfigOverrideSpecApplyConfiguration constructs a declarative configuration of the HypervisorConfigOverrideSpec type for use with +// apply. +func HypervisorConfigOverrideSpec() *HypervisorConfigOverrideSpecApplyConfiguration { + return &HypervisorConfigOverrideSpecApplyConfiguration{} +} + +// WithReason sets the Reason 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 Reason field is set to the value of the last call. +func (b *HypervisorConfigOverrideSpecApplyConfiguration) WithReason(value string) *HypervisorConfigOverrideSpecApplyConfiguration { + b.Reason = &value + return b +} + +// WithOverride sets the Override 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 Override field is set to the value of the last call. +func (b *HypervisorConfigOverrideSpecApplyConfiguration) WithOverride(value *HypervisorConfigSpecApplyConfiguration) *HypervisorConfigOverrideSpecApplyConfiguration { + b.Override = value + return b +} diff --git a/applyconfigurations/api/v1/hypervisorconfigoverridestatus.go b/applyconfigurations/api/v1/hypervisorconfigoverridestatus.go new file mode 100644 index 0000000..93039dd --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigoverridestatus.go @@ -0,0 +1,41 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// HypervisorConfigOverrideStatusApplyConfiguration represents a declarative configuration of the HypervisorConfigOverrideStatus type for use +// with apply. +type HypervisorConfigOverrideStatusApplyConfiguration struct { + Conditions []metav1.ConditionApplyConfiguration `json:"conditions,omitempty"` + SpecHash *string `json:"specHash,omitempty"` +} + +// HypervisorConfigOverrideStatusApplyConfiguration constructs a declarative configuration of the HypervisorConfigOverrideStatus type for use with +// apply. +func HypervisorConfigOverrideStatus() *HypervisorConfigOverrideStatusApplyConfiguration { + return &HypervisorConfigOverrideStatusApplyConfiguration{} +} + +// 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 *HypervisorConfigOverrideStatusApplyConfiguration) WithConditions(values ...*metav1.ConditionApplyConfiguration) *HypervisorConfigOverrideStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} + +// WithSpecHash sets the SpecHash 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 SpecHash field is set to the value of the last call. +func (b *HypervisorConfigOverrideStatusApplyConfiguration) WithSpecHash(value string) *HypervisorConfigOverrideStatusApplyConfiguration { + b.SpecHash = &value + return b +} diff --git a/applyconfigurations/api/v1/hypervisorconfigset.go b/applyconfigurations/api/v1/hypervisorconfigset.go new file mode 100644 index 0000000..e077ddf --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigset.go @@ -0,0 +1,226 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// HypervisorConfigSetApplyConfiguration represents a declarative configuration of the HypervisorConfigSet type for use +// with apply. +type HypervisorConfigSetApplyConfiguration struct { + metav1.TypeMetaApplyConfiguration `json:",inline"` + *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *HypervisorConfigSetSpecApplyConfiguration `json:"spec,omitempty"` + Status *HypervisorConfigSetStatusApplyConfiguration `json:"status,omitempty"` +} + +// HypervisorConfigSet constructs a declarative configuration of the HypervisorConfigSet type for use with +// apply. +func HypervisorConfigSet(name, namespace string) *HypervisorConfigSetApplyConfiguration { + b := &HypervisorConfigSetApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("HypervisorConfigSet") + b.WithAPIVersion("kvm.cloud.sap/v1") + return b +} +func (b HypervisorConfigSetApplyConfiguration) IsApplyConfiguration() {} + +// 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 *HypervisorConfigSetApplyConfiguration) WithKind(value string) *HypervisorConfigSetApplyConfiguration { + b.TypeMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithAPIVersion(value string) *HypervisorConfigSetApplyConfiguration { + b.TypeMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithName(value string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithGenerateName(value string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithNamespace(value string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithUID(value types.UID) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithResourceVersion(value string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithGeneration(value int64) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithLabels(entries map[string]string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithAnnotations(entries map[string]string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { + b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.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 *HypervisorConfigSetApplyConfiguration) WithFinalizers(values ...string) *HypervisorConfigSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *HypervisorConfigSetApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &metav1.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 *HypervisorConfigSetApplyConfiguration) WithSpec(value *HypervisorConfigSetSpecApplyConfiguration) *HypervisorConfigSetApplyConfiguration { + 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 *HypervisorConfigSetApplyConfiguration) WithStatus(value *HypervisorConfigSetStatusApplyConfiguration) *HypervisorConfigSetApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *HypervisorConfigSetApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *HypervisorConfigSetApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *HypervisorConfigSetApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *HypervisorConfigSetApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/applyconfigurations/api/v1/hypervisorconfigsetspec.go b/applyconfigurations/api/v1/hypervisorconfigsetspec.go new file mode 100644 index 0000000..8c5a177 --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigsetspec.go @@ -0,0 +1,36 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// HypervisorConfigSetSpecApplyConfiguration represents a declarative configuration of the HypervisorConfigSetSpec type for use +// with apply. +type HypervisorConfigSetSpecApplyConfiguration struct { + Selector *metav1.LabelSelectorApplyConfiguration `json:"selector,omitempty"` + Template *HypervisorConfigSetTemplateApplyConfiguration `json:"template,omitempty"` +} + +// HypervisorConfigSetSpecApplyConfiguration constructs a declarative configuration of the HypervisorConfigSetSpec type for use with +// apply. +func HypervisorConfigSetSpec() *HypervisorConfigSetSpecApplyConfiguration { + return &HypervisorConfigSetSpecApplyConfiguration{} +} + +// 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 *HypervisorConfigSetSpecApplyConfiguration) WithSelector(value *metav1.LabelSelectorApplyConfiguration) *HypervisorConfigSetSpecApplyConfiguration { + b.Selector = value + return b +} + +// WithTemplate sets the Template 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 Template field is set to the value of the last call. +func (b *HypervisorConfigSetSpecApplyConfiguration) WithTemplate(value *HypervisorConfigSetTemplateApplyConfiguration) *HypervisorConfigSetSpecApplyConfiguration { + b.Template = value + return b +} diff --git a/applyconfigurations/api/v1/hypervisorconfigsetstatus.go b/applyconfigurations/api/v1/hypervisorconfigsetstatus.go new file mode 100644 index 0000000..259f71f --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigsetstatus.go @@ -0,0 +1,41 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// HypervisorConfigSetStatusApplyConfiguration represents a declarative configuration of the HypervisorConfigSetStatus type for use +// with apply. +type HypervisorConfigSetStatusApplyConfiguration struct { + Conditions []metav1.ConditionApplyConfiguration `json:"conditions,omitempty"` + SpecHash *string `json:"specHash,omitempty"` +} + +// HypervisorConfigSetStatusApplyConfiguration constructs a declarative configuration of the HypervisorConfigSetStatus type for use with +// apply. +func HypervisorConfigSetStatus() *HypervisorConfigSetStatusApplyConfiguration { + return &HypervisorConfigSetStatusApplyConfiguration{} +} + +// 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 *HypervisorConfigSetStatusApplyConfiguration) WithConditions(values ...*metav1.ConditionApplyConfiguration) *HypervisorConfigSetStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} + +// WithSpecHash sets the SpecHash 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 SpecHash field is set to the value of the last call. +func (b *HypervisorConfigSetStatusApplyConfiguration) WithSpecHash(value string) *HypervisorConfigSetStatusApplyConfiguration { + b.SpecHash = &value + return b +} diff --git a/applyconfigurations/api/v1/hypervisorconfigsettemplate.go b/applyconfigurations/api/v1/hypervisorconfigsettemplate.go new file mode 100644 index 0000000..0b0e325 --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigsettemplate.go @@ -0,0 +1,23 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +// HypervisorConfigSetTemplateApplyConfiguration represents a declarative configuration of the HypervisorConfigSetTemplate type for use +// with apply. +type HypervisorConfigSetTemplateApplyConfiguration struct { + Spec *HypervisorConfigSpecApplyConfiguration `json:"spec,omitempty"` +} + +// HypervisorConfigSetTemplateApplyConfiguration constructs a declarative configuration of the HypervisorConfigSetTemplate type for use with +// apply. +func HypervisorConfigSetTemplate() *HypervisorConfigSetTemplateApplyConfiguration { + return &HypervisorConfigSetTemplateApplyConfiguration{} +} + +// 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 *HypervisorConfigSetTemplateApplyConfiguration) WithSpec(value *HypervisorConfigSpecApplyConfiguration) *HypervisorConfigSetTemplateApplyConfiguration { + b.Spec = value + return b +} diff --git a/applyconfigurations/api/v1/hypervisorconfigspec.go b/applyconfigurations/api/v1/hypervisorconfigspec.go new file mode 100644 index 0000000..66a801a --- /dev/null +++ b/applyconfigurations/api/v1/hypervisorconfigspec.go @@ -0,0 +1,113 @@ +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +// HypervisorConfigSpecApplyConfiguration represents a declarative configuration of the HypervisorConfigSpec type for use +// with apply. +type HypervisorConfigSpecApplyConfiguration struct { + OperatingSystemVersion *string `json:"version,omitempty"` + Reboot *bool `json:"reboot,omitempty"` + EvacuateOnReboot *bool `json:"evacuateOnReboot,omitempty"` + LifecycleEnabled *bool `json:"lifecycleEnabled,omitempty"` + SkipTests *bool `json:"skipTests,omitempty"` + CustomTraits *[]string `json:"customTraits,omitempty"` + Aggregates *[]string `json:"aggregates,omitempty"` + HighAvailability *bool `json:"highAvailability,omitempty"` + CreateCertManagerCertificate *bool `json:"createCertManagerCertificate,omitempty"` + InstallCertificate *bool `json:"installCertificate,omitempty"` + Maintenance *string `json:"maintenance,omitempty"` +} + +// HypervisorConfigSpecApplyConfiguration constructs a declarative configuration of the HypervisorConfigSpec type for use with +// apply. +func HypervisorConfigSpec() *HypervisorConfigSpecApplyConfiguration { + return &HypervisorConfigSpecApplyConfiguration{} +} + +// WithOperatingSystemVersion sets the OperatingSystemVersion 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 OperatingSystemVersion field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithOperatingSystemVersion(value string) *HypervisorConfigSpecApplyConfiguration { + b.OperatingSystemVersion = &value + return b +} + +// WithReboot sets the Reboot 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 Reboot field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithReboot(value bool) *HypervisorConfigSpecApplyConfiguration { + b.Reboot = &value + return b +} + +// WithEvacuateOnReboot sets the EvacuateOnReboot 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 EvacuateOnReboot field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithEvacuateOnReboot(value bool) *HypervisorConfigSpecApplyConfiguration { + b.EvacuateOnReboot = &value + return b +} + +// WithLifecycleEnabled sets the LifecycleEnabled 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 LifecycleEnabled field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithLifecycleEnabled(value bool) *HypervisorConfigSpecApplyConfiguration { + b.LifecycleEnabled = &value + return b +} + +// WithSkipTests sets the SkipTests 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 SkipTests field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithSkipTests(value bool) *HypervisorConfigSpecApplyConfiguration { + b.SkipTests = &value + return b +} + +// WithCustomTraits sets the CustomTraits 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 CustomTraits field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithCustomTraits(value []string) *HypervisorConfigSpecApplyConfiguration { + b.CustomTraits = &value + return b +} + +// WithAggregates sets the Aggregates 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 Aggregates field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithAggregates(value []string) *HypervisorConfigSpecApplyConfiguration { + b.Aggregates = &value + return b +} + +// WithHighAvailability sets the HighAvailability 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 HighAvailability field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithHighAvailability(value bool) *HypervisorConfigSpecApplyConfiguration { + b.HighAvailability = &value + return b +} + +// WithCreateCertManagerCertificate sets the CreateCertManagerCertificate 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 CreateCertManagerCertificate field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithCreateCertManagerCertificate(value bool) *HypervisorConfigSpecApplyConfiguration { + b.CreateCertManagerCertificate = &value + return b +} + +// WithInstallCertificate sets the InstallCertificate 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 InstallCertificate field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithInstallCertificate(value bool) *HypervisorConfigSpecApplyConfiguration { + b.InstallCertificate = &value + return b +} + +// WithMaintenance sets the Maintenance 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 Maintenance field is set to the value of the last call. +func (b *HypervisorConfigSpecApplyConfiguration) WithMaintenance(value string) *HypervisorConfigSpecApplyConfiguration { + b.Maintenance = &value + return b +} diff --git a/applyconfigurations/utils.go b/applyconfigurations/utils.go index 3ecf8f6..5167811 100644 --- a/applyconfigurations/utils.go +++ b/applyconfigurations/utils.go @@ -26,6 +26,22 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1.EvictionStatusApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("Hypervisor"): return &apiv1.HypervisorApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigOverride"): + return &apiv1.HypervisorConfigOverrideApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigOverrideSpec"): + return &apiv1.HypervisorConfigOverrideSpecApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigOverrideStatus"): + return &apiv1.HypervisorConfigOverrideStatusApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigSet"): + return &apiv1.HypervisorConfigSetApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigSetSpec"): + return &apiv1.HypervisorConfigSetSpecApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigSetStatus"): + return &apiv1.HypervisorConfigSetStatusApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigSetTemplate"): + return &apiv1.HypervisorConfigSetTemplateApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("HypervisorConfigSpec"): + return &apiv1.HypervisorConfigSpecApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("HypervisorSpec"): return &apiv1.HypervisorSpecApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("HypervisorStatus"): diff --git a/charts/openstack-hypervisor-operator/templates/manager-rbac.yaml b/charts/openstack-hypervisor-operator/templates/manager-rbac.yaml index 53af34e..284a472 100644 --- a/charts/openstack-hypervisor-operator/templates/manager-rbac.yaml +++ b/charts/openstack-hypervisor-operator/templates/manager-rbac.yaml @@ -72,6 +72,14 @@ rules: - get - patch - update +- apiGroups: + - kvm.cloud.sap + resources: + - hypervisorconfigoverrides + verbs: + - get + - list + - watch - apiGroups: - policy resources: diff --git a/config/crd/bases/kvm.cloud.sap_hypervisorconfigoverrides.yaml b/config/crd/bases/kvm.cloud.sap_hypervisorconfigoverrides.yaml new file mode 100644 index 0000000..466cdb1 --- /dev/null +++ b/config/crd/bases/kvm.cloud.sap_hypervisorconfigoverrides.yaml @@ -0,0 +1,194 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.19.0 + name: hypervisorconfigoverrides.kvm.cloud.sap +spec: + group: kvm.cloud.sap + names: + kind: HypervisorConfigOverride + listKind: HypervisorConfigOverrideList + plural: hypervisorconfigoverrides + shortNames: + - hvco + singular: hypervisorconfigoverride + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .spec.reason + name: Reason + type: string + - jsonPath: .spec.override.lifecycleEnabled + name: Lifecycle + type: boolean + - jsonPath: .spec.override.highAvailability + name: High Availability + type: boolean + - jsonPath: .spec.override.skipTests + name: Skip Tests + type: boolean + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + description: HypervisorConfigOverride is the Schema for overriding the config + of one hypervisor crd 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.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + 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.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: HypervisorConfigOverrideSpec overrides the desired state + of Hypervisor + properties: + override: + description: HypervisorConfigSpec defines (in parts) the desired state + of Hypervisor + properties: + aggregates: + description: Aggregates are used to apply aggregates to the hypervisor. + items: + type: string + type: array + createCertManagerCertificate: + description: |- + Require to issue a certificate from cert-manager for the hypervisor, to be used for + secure communication with the libvirt API. + type: boolean + customTraits: + description: CustomTraits are used to apply custom traits to the + hypervisor. + items: + type: string + type: array + evacuateOnReboot: + description: EvacuateOnReboot request an evacuation of all instances + before reboot. + type: boolean + highAvailability: + description: HighAvailability is used to enable the high availability + handling of the hypervisor. + type: boolean + installCertificate: + description: InstallCertificate is used to enable the installations + of the certificates via kvm-node-agent. + type: boolean + lifecycleEnabled: + description: LifecycleEnabled enables the lifecycle management + of the hypervisor via hypervisor-operator. + type: boolean + maintenance: + description: Maintenance indicates whether the hypervisor is in + maintenance mode. + enum: + - "" + - manual + - auto + - ha + type: string + reboot: + description: Reboot request an reboot after successful installation + of an upgrade. + type: boolean + skipTests: + description: SkipTests skips the tests during the onboarding process. + type: boolean + version: + description: OperatingSystemVersion represents the desired operating + system version. + type: string + type: object + reason: + description: Reason describes the reason for the override + type: string + required: + - override + - reason + type: object + status: + description: HypervisorConfigOverrideStatus defines the observed state + of HypervisorConfigOverride + properties: + conditions: + description: Represents the Hypervisor node conditions. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + 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].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + 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. + 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 + specHash: + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/bases/kvm.cloud.sap_hypervisorconfigsets.yaml b/config/crd/bases/kvm.cloud.sap_hypervisorconfigsets.yaml new file mode 100644 index 0000000..86ca81a --- /dev/null +++ b/config/crd/bases/kvm.cloud.sap_hypervisorconfigsets.yaml @@ -0,0 +1,235 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.19.0 + name: hypervisorconfigsets.kvm.cloud.sap +spec: + group: kvm.cloud.sap + names: + kind: HypervisorConfigSet + listKind: HypervisorConfigSetList + plural: hypervisorconfigsets + shortNames: + - hvcs + singular: hypervisorconfigset + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + description: HypervisorConfigSet is the Schema for a set of hypervisor configs + 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.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + 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.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: HypervisorConfigOverrideSpec overrides the desired state + of Hypervisor + properties: + selector: + description: |- + A label selector is a label query over a set of resources. The result of matchLabels and + matchExpressions are ANDed. An empty label selector matches all objects. A null + label selector matches no objects. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + template: + description: A template for the hypervisor defining the values for + a whole set + properties: + spec: + description: HypervisorConfigSpec defines (in parts) the desired + state of Hypervisor + properties: + aggregates: + description: Aggregates are used to apply aggregates to the + hypervisor. + items: + type: string + type: array + createCertManagerCertificate: + description: |- + Require to issue a certificate from cert-manager for the hypervisor, to be used for + secure communication with the libvirt API. + type: boolean + customTraits: + description: CustomTraits are used to apply custom traits + to the hypervisor. + items: + type: string + type: array + evacuateOnReboot: + description: EvacuateOnReboot request an evacuation of all + instances before reboot. + type: boolean + highAvailability: + description: HighAvailability is used to enable the high availability + handling of the hypervisor. + type: boolean + installCertificate: + description: InstallCertificate is used to enable the installations + of the certificates via kvm-node-agent. + type: boolean + lifecycleEnabled: + description: LifecycleEnabled enables the lifecycle management + of the hypervisor via hypervisor-operator. + type: boolean + maintenance: + description: Maintenance indicates whether the hypervisor + is in maintenance mode. + enum: + - "" + - manual + - auto + - ha + type: string + reboot: + description: Reboot request an reboot after successful installation + of an upgrade. + type: boolean + skipTests: + description: SkipTests skips the tests during the onboarding + process. + type: boolean + version: + description: OperatingSystemVersion represents the desired + operating system version. + type: string + type: object + required: + - spec + type: object + required: + - selector + - template + type: object + status: + description: HypervisorConfigSetStatus defines the observed state of HypervisorConfigSet + properties: + conditions: + description: Represents the Hypervisor node conditions. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + 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].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + 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. + 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 + specHash: + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 528d2cb..c15468f 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -71,6 +71,14 @@ rules: - get - patch - update +- apiGroups: + - kvm.cloud.sap + resources: + - hypervisorconfigoverrides + verbs: + - get + - list + - watch - apiGroups: - policy resources: diff --git a/internal/controller/hypervisor_controller.go b/internal/controller/hypervisor_controller.go index f83d3bf..4ba94e0 100644 --- a/internal/controller/hypervisor_controller.go +++ b/internal/controller/hypervisor_controller.go @@ -68,6 +68,7 @@ type HypervisorController struct { // +kubebuilder:rbac:groups="",resources=nodes/status,verbs=get // +kubebuilder:rbac:groups=kvm.cloud.sap,resources=hypervisors,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=kvm.cloud.sap,resources=hypervisors/status,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=kvm.cloud.sap,resources=hypervisorconfigoverrides,verbs=get;list;watch func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := logger.FromContext(ctx).WithName(req.Name) @@ -78,7 +79,6 @@ func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, k8sclient.IgnoreNotFound(err) } - nodeLabels := labels.Set(node.Labels) hypervisor := &kvmv1.Hypervisor{ ObjectMeta: metav1.ObjectMeta{ Name: node.Name, @@ -132,7 +132,11 @@ func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request) } before := hypervisor.DeepCopy() - syncLabelsAndAnnotations(nodeLabels, hypervisor, node) + + if err := hv.reconcileHypervisor(ctx, hypervisor, node); err != nil { + return ctrl.Result{}, err + } + if equality.Semantic.DeepEqual(hypervisor, before) { return ctrl.Result{}, nil } @@ -140,7 +144,9 @@ func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, hv.Patch(ctx, hypervisor, k8sclient.MergeFromWithOptions(before, k8sclient.MergeFromWithOptimisticLock{})) } - syncLabelsAndAnnotations(nodeLabels, hypervisor, node) + if err := hv.reconcileHypervisor(ctx, hypervisor, node); err != nil { + return ctrl.Result{}, err + } if err := controllerutil.SetOwnerReference(node, hypervisor, hv.Scheme, controllerutil.WithBlockOwnerDeletion(true)); err != nil { return ctrl.Result{}, fmt.Errorf("failed setting controller reference: %w", err) @@ -154,17 +160,77 @@ func (hv *HypervisorController) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, nil } -func syncLabelsAndAnnotations(nodeLabels labels.Set, hypervisor *kvmv1.Hypervisor, node *corev1.Node) { +func (hv *HypervisorController) reconcileHypervisor(ctx context.Context, hypervisor *kvmv1.Hypervisor, node *corev1.Node) error { + nodeLabels := labels.Set(node.Labels) + + spec := &hypervisor.Spec + // transport lifecycle label to hypervisor spec if nodeLabels.Has(labelLifecycleMode) { - hypervisor.Spec.LifecycleEnabled = true - hypervisor.Spec.SkipTests = nodeLabels.Get(labelLifecycleMode) == "skip-tests" + spec.LifecycleEnabled = true + spec.SkipTests = nodeLabels.Get(labelLifecycleMode) == "skip-tests" } // transport relevant labels transportLabels(&node.ObjectMeta, hypervisor) // transport relevant annotations transportAggregatesAndTraits(&node.ObjectMeta, hypervisor) + + overrides := &kvmv1.HypervisorConfigOverride{} + if err := hv.Get(ctx, k8sclient.ObjectKeyFromObject(hypervisor), overrides); k8sclient.IgnoreNotFound(err) != nil { + return fmt.Errorf("failed to get hypervisor-overrides: %w", err) + } + override := &overrides.Spec.Override + + if override.Aggregates != nil { + spec.Aggregates = *override.Aggregates + } + + if override.CreateCertManagerCertificate != nil { + spec.CreateCertManagerCertificate = *override.CreateCertManagerCertificate + } + + if override.CreateCertManagerCertificate != nil { + spec.CreateCertManagerCertificate = *override.CreateCertManagerCertificate + } + + if override.CustomTraits != nil { + spec.CustomTraits = *override.CustomTraits + } + + if override.EvacuateOnReboot != nil { + spec.EvacuateOnReboot = *override.EvacuateOnReboot + } + + if override.HighAvailability != nil { + spec.HighAvailability = *override.HighAvailability + } + + if override.InstallCertificate != nil { + spec.InstallCertificate = *override.InstallCertificate + } + + if override.LifecycleEnabled != nil { + spec.LifecycleEnabled = *override.LifecycleEnabled + } + + if override.Maintenance != nil { + spec.Maintenance = *override.Maintenance + } + + if override.OperatingSystemVersion != nil { + spec.OperatingSystemVersion = *override.OperatingSystemVersion + } + + if override.Reboot != nil { + spec.Reboot = *override.Reboot + } + + if override.SkipTests != nil { + spec.SkipTests = *override.SkipTests + } + + return nil } func (hv *HypervisorController) SetupWithManager(mgr ctrl.Manager) error { @@ -188,6 +254,7 @@ func (hv *HypervisorController) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). Named(HypervisorControllerName). For(&corev1.Node{}). + For(&kvmv1.HypervisorConfigOverride{}). WithEventFilter(novaVirtLabeledPredicate). Complete(hv) }