diff --git a/Makefile b/Makefile index 315c8388..f8bfd389 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ GH_REPO ?= kubernetes-sigs/cluster-api-provider-cloudstack # Binaries CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen +CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen GINKGO := $(TOOLS_BIN_DIR)/ginkgo GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize @@ -80,7 +81,7 @@ all: build ## -------------------------------------- .PHONY: binaries -binaries: $(CONTROLLER_GEN) $(GOLANGCI_LINT) $(STATIC_CHECK) $(GINKGO) $(MOCKGEN) $(KUSTOMIZE) managers # Builds and installs all binaries +binaries: $(CONTROLLER_GEN) $(CONVERSION_GEN) $(GOLANGCI_LINT) $(STATIC_CHECK) $(GINKGO) $(MOCKGEN) $(KUSTOMIZE) managers # Builds and installs all binaries .PHONY: managers managers: @@ -157,13 +158,16 @@ config/.flag.mk: $(CONTROLLER_GEN) $(MANIFEST_GEN_INPUTS) $(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role webhook paths="{./api/...,./controllers/...}" output:crd:artifacts:config=config/crd/bases @touch config/.flag.mk -CONVERSION_GEN_TARGET=$(shell find api -type d -name "v*1" -exec echo {}\/zz_generated.conversion.go \;) -CONVERSION_GEN_INPUTS=$(shell find ./api -name "*test*" -prune -o -name "*zz_generated*" -prune -o -type f -print) .PHONY: generate-conversion -generate-conversion: $(CONVERSION_GEN_TARGET) ## Generate code to convert api/v1beta1 to api/v1beta2 -api/%/zz_generated.conversion.go: bin/conversion-gen $(CONVERSION_GEN_INPUTS) - conversion-gen --go-header-file "./hack/boilerplate.go.txt" --input-dirs "./api/v1beta1" \ - --output-base "." --output-file-base="zz_generated.conversion" --skip-unsafe=true +generate-conversion: $(CONVERSION_GEN) ## Generate code to convert api/v1beta1 and api/v1beta2 to api/v1beta3 + $(CONVERSION_GEN) \ + --input-dirs=./api/v1beta1 \ + --go-header-file=./hack/boilerplate.go.txt \ + --output-base=. --output-file-base=zz_generated.conversion + $(CONVERSION_GEN) \ + --input-dirs=./api/v1beta2 \ + --go-header-file=./hack/boilerplate.go.txt \ + --output-base=. --output-file-base=zz_generated.conversion ##@ Build ## -------------------------------------- diff --git a/api/v1beta1/cloudstackmachinetemplate_conversion.go b/api/v1beta1/cloudstackmachinetemplate_conversion.go index 77f209e6..f4a3bea0 100644 --- a/api/v1beta1/cloudstackmachinetemplate_conversion.go +++ b/api/v1beta1/cloudstackmachinetemplate_conversion.go @@ -21,6 +21,9 @@ import ( "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func (src *CloudStackMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // nolint @@ -57,13 +60,29 @@ func (dst *CloudStackMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error { } func Convert_v1beta1_CloudStackMachineTemplateSpec_To_v1beta3_CloudStackMachineTemplateSpec(in *CloudStackMachineTemplateSpec, out *v1beta3.CloudStackMachineTemplateSpec, s machineryconversion.Scope) error { // nolint - return autoConvert_v1beta1_CloudStackMachineSpec_To_v1beta3_CloudStackMachineSpec(&in.Spec.Spec, &out.Template.Spec, s) + return Convert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(&in.Spec, &out.Template, s) } func Convert_v1beta3_CloudStackMachineTemplateSpec_To_v1beta1_CloudStackMachineTemplateSpec(in *v1beta3.CloudStackMachineTemplateSpec, out *CloudStackMachineTemplateSpec, s machineryconversion.Scope) error { // nolint - return autoConvert_v1beta3_CloudStackMachineSpec_To_v1beta1_CloudStackMachineSpec(&in.Template.Spec, &out.Spec.Spec, s) + return Convert_v1beta3_CloudStackMachineTemplateResource_To_v1beta1_CloudStackMachineTemplateResource(&in.Template, &out.Spec, s) } -func Convert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in *CloudStackMachineTemplateResource, out *v1beta3.CloudStackMachineTemplateResource, s machineryconversion.Scope) error { //nolint - return autoConvert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in, out, s) +func Convert_v1beta1_ObjectMeta_To_v1_ObjectMeta(in *clusterv1.ObjectMeta, out *metav1.ObjectMeta, s machineryconversion.Scope) error { // nolint + if in.Annotations != nil { + out.Annotations = in.Annotations + } + if in.Labels != nil { + out.Labels = in.Labels + } + return nil +} + +func Convert_v1_ObjectMeta_To_v1beta1_ObjectMeta(in *metav1.ObjectMeta, out *clusterv1.ObjectMeta, s machineryconversion.Scope) error { // nolint + if in.Annotations != nil { + out.Annotations = in.Annotations + } + if in.Labels != nil { + out.Labels = in.Labels + } + return nil } diff --git a/api/v1beta1/conversion_test.go b/api/v1beta1/conversion_test.go index f965b644..32ffcd37 100644 --- a/api/v1beta1/conversion_test.go +++ b/api/v1beta1/conversion_test.go @@ -23,7 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1beta1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" - capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) var _ = Describe("Conversion", func() { @@ -46,7 +46,7 @@ var _ = Describe("Conversion", func() { }, }, }, - ControlPlaneEndpoint: capiv1.APIEndpoint{ + ControlPlaneEndpoint: clusterv1.APIEndpoint{ Host: "endpoint1", Port: 443, }, @@ -99,7 +99,7 @@ var _ = Describe("Conversion", func() { }, }, }, - ControlPlaneEndpoint: capiv1.APIEndpoint{ + ControlPlaneEndpoint: clusterv1.APIEndpoint{ Host: "endpoint1", Port: 443, }, @@ -122,7 +122,7 @@ var _ = Describe("Conversion", func() { }, }, }, - ControlPlaneEndpoint: capiv1.APIEndpoint{ + ControlPlaneEndpoint: clusterv1.APIEndpoint{ Host: "endpoint1", Port: 443, }, @@ -143,7 +143,7 @@ var _ = Describe("Conversion", func() { Namespace: "namespace1", }, Spec: v1beta3.CloudStackClusterSpec{ - ControlPlaneEndpoint: capiv1.APIEndpoint{ + ControlPlaneEndpoint: clusterv1.APIEndpoint{ Host: "endpoint1", Port: 443, }, diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 42224c18..16c82c57 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -23,10 +23,12 @@ package v1beta1 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" v1beta3 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" + apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func init() { @@ -196,6 +198,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*CloudStackMachineTemplateResource)(nil), (*v1beta3.CloudStackMachineTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(a.(*CloudStackMachineTemplateResource), b.(*v1beta3.CloudStackMachineTemplateResource), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*v1beta3.CloudStackMachineTemplateResource)(nil), (*CloudStackMachineTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta3_CloudStackMachineTemplateResource_To_v1beta1_CloudStackMachineTemplateResource(a.(*v1beta3.CloudStackMachineTemplateResource), b.(*CloudStackMachineTemplateResource), scope) }); err != nil { @@ -241,13 +248,13 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*CloudStackCluster)(nil), (*v1beta3.CloudStackCluster)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_CloudStackCluster_To_v1beta3_CloudStackCluster(a.(*CloudStackCluster), b.(*v1beta3.CloudStackCluster), scope) + if err := s.AddConversionFunc((*v1.ObjectMeta)(nil), (*apiv1beta1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_ObjectMeta_To_v1beta1_ObjectMeta(a.(*v1.ObjectMeta), b.(*apiv1beta1.ObjectMeta), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*CloudStackMachineTemplateResource)(nil), (*v1beta3.CloudStackMachineTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(a.(*CloudStackMachineTemplateResource), b.(*v1beta3.CloudStackMachineTemplateResource), scope) + if err := s.AddConversionFunc((*CloudStackCluster)(nil), (*v1beta3.CloudStackCluster)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_CloudStackCluster_To_v1beta3_CloudStackCluster(a.(*CloudStackCluster), b.(*v1beta3.CloudStackCluster), scope) }); err != nil { return err } @@ -256,6 +263,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*apiv1beta1.ObjectMeta)(nil), (*v1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ObjectMeta_To_v1_ObjectMeta(a.(*apiv1beta1.ObjectMeta), b.(*v1.ObjectMeta), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta3.CloudStackAffinityGroupSpec)(nil), (*CloudStackAffinityGroupSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta3_CloudStackAffinityGroupSpec_To_v1beta1_CloudStackAffinityGroupSpec(a.(*v1beta3.CloudStackAffinityGroupSpec), b.(*CloudStackAffinityGroupSpec), scope) }); err != nil { @@ -612,7 +624,7 @@ func autoConvert_v1beta1_CloudStackMachineSpec_To_v1beta3_CloudStackMachineSpec( out.Details = *(*map[string]string)(unsafe.Pointer(&in.Details)) out.AffinityGroupIDs = *(*[]string)(unsafe.Pointer(&in.AffinityGroupIDs)) out.Affinity = in.Affinity - out.AffinityGroupRef = (*v1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) + out.AffinityGroupRef = (*corev1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) // INFO: in.ZoneID opted out of conversion generation // INFO: in.ZoneName opted out of conversion generation @@ -642,7 +654,7 @@ func autoConvert_v1beta3_CloudStackMachineSpec_To_v1beta1_CloudStackMachineSpec( out.Details = *(*map[string]string)(unsafe.Pointer(&in.Details)) out.AffinityGroupIDs = *(*[]string)(unsafe.Pointer(&in.AffinityGroupIDs)) out.Affinity = in.Affinity - out.AffinityGroupRef = (*v1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) + out.AffinityGroupRef = (*corev1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) // WARNING: in.FailureDomainName requires manual conversion: does not exist in peer-type // WARNING: in.UncompressedUserData requires manual conversion: does not exist in peer-type @@ -745,7 +757,7 @@ func Convert_v1beta3_CloudStackMachineStateCheckerStatus_To_v1beta1_CloudStackMa func autoConvert_v1beta1_CloudStackMachineStatus_To_v1beta3_CloudStackMachineStatus(in *CloudStackMachineStatus, out *v1beta3.CloudStackMachineStatus, s conversion.Scope) error { // INFO: in.ZoneID opted out of conversion generation - out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = string(in.InstanceState) out.InstanceStateLastUpdated = in.InstanceStateLastUpdated out.Ready = in.Ready @@ -758,7 +770,7 @@ func Convert_v1beta1_CloudStackMachineStatus_To_v1beta3_CloudStackMachineStatus( } func autoConvert_v1beta3_CloudStackMachineStatus_To_v1beta1_CloudStackMachineStatus(in *v1beta3.CloudStackMachineStatus, out *CloudStackMachineStatus, s conversion.Scope) error { - out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = InstanceState(in.InstanceState) out.InstanceStateLastUpdated = in.InstanceStateLastUpdated out.Ready = in.Ready @@ -836,14 +848,24 @@ func Convert_v1beta3_CloudStackMachineTemplateList_To_v1beta1_CloudStackMachineT } func autoConvert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in *CloudStackMachineTemplateResource, out *v1beta3.CloudStackMachineTemplateResource, s conversion.Scope) error { - // WARNING: in.ObjectMeta requires manual conversion: does not exist in peer-type + if err := Convert_v1_ObjectMeta_To_v1beta1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { + return err + } if err := Convert_v1beta1_CloudStackMachineSpec_To_v1beta3_CloudStackMachineSpec(&in.Spec, &out.Spec, s); err != nil { return err } return nil } +// Convert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource is an autogenerated conversion function. +func Convert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in *CloudStackMachineTemplateResource, out *v1beta3.CloudStackMachineTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta1_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in, out, s) +} + func autoConvert_v1beta3_CloudStackMachineTemplateResource_To_v1beta1_CloudStackMachineTemplateResource(in *v1beta3.CloudStackMachineTemplateResource, out *CloudStackMachineTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta1_ObjectMeta_To_v1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { + return err + } if err := Convert_v1beta3_CloudStackMachineSpec_To_v1beta1_CloudStackMachineSpec(&in.Spec, &out.Spec, s); err != nil { return err } diff --git a/api/v1beta2/cloudstackmachinetemplate_conversion.go b/api/v1beta2/cloudstackmachinetemplate_conversion.go index 09415447..721d8bd0 100644 --- a/api/v1beta2/cloudstackmachinetemplate_conversion.go +++ b/api/v1beta2/cloudstackmachinetemplate_conversion.go @@ -17,8 +17,10 @@ limitations under the License. package v1beta2 import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" machineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" ) @@ -49,13 +51,29 @@ func (dst *CloudStackMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error { } func Convert_v1beta2_CloudStackMachineTemplateSpec_To_v1beta3_CloudStackMachineTemplateSpec(in *CloudStackMachineTemplateSpec, out *v1beta3.CloudStackMachineTemplateSpec, s machineryconversion.Scope) error { // nolint - return autoConvert_v1beta2_CloudStackMachineSpec_To_v1beta3_CloudStackMachineSpec(&in.Spec.Spec, &out.Template.Spec, s) + return Convert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(&in.Spec, &out.Template, s) } func Convert_v1beta3_CloudStackMachineTemplateSpec_To_v1beta2_CloudStackMachineTemplateSpec(in *v1beta3.CloudStackMachineTemplateSpec, out *CloudStackMachineTemplateSpec, s machineryconversion.Scope) error { // nolint - return autoConvert_v1beta3_CloudStackMachineSpec_To_v1beta2_CloudStackMachineSpec(&in.Template.Spec, &out.Spec.Spec, s) + return Convert_v1beta3_CloudStackMachineTemplateResource_To_v1beta2_CloudStackMachineTemplateResource(&in.Template, &out.Spec, s) } -func Convert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in *CloudStackMachineTemplateResource, out *v1beta3.CloudStackMachineTemplateResource, s machineryconversion.Scope) error { //nolint - return autoConvert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in, out, s) +func Convert_v1beta1_ObjectMeta_To_v1_ObjectMeta(in *clusterv1.ObjectMeta, out *metav1.ObjectMeta, s machineryconversion.Scope) error { // nolint + if in.Annotations != nil { + out.Annotations = in.Annotations + } + if in.Labels != nil { + out.Labels = in.Labels + } + return nil +} + +func Convert_v1_ObjectMeta_To_v1beta1_ObjectMeta(in *metav1.ObjectMeta, out *clusterv1.ObjectMeta, s machineryconversion.Scope) error { // nolint + if in.Annotations != nil { + out.Annotations = in.Annotations + } + if in.Labels != nil { + out.Labels = in.Labels + } + return nil } diff --git a/api/v1beta2/zz_generated.conversion.go b/api/v1beta2/zz_generated.conversion.go index 05436ca6..f4cc9f2c 100644 --- a/api/v1beta2/zz_generated.conversion.go +++ b/api/v1beta2/zz_generated.conversion.go @@ -23,7 +23,8 @@ package v1beta2 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" v1beta3 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" @@ -297,6 +298,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*CloudStackMachineTemplateResource)(nil), (*v1beta3.CloudStackMachineTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(a.(*CloudStackMachineTemplateResource), b.(*v1beta3.CloudStackMachineTemplateResource), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*v1beta3.CloudStackMachineTemplateResource)(nil), (*CloudStackMachineTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta3_CloudStackMachineTemplateResource_To_v1beta2_CloudStackMachineTemplateResource(a.(*v1beta3.CloudStackMachineTemplateResource), b.(*CloudStackMachineTemplateResource), scope) }); err != nil { @@ -342,8 +348,13 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*CloudStackMachineTemplateResource)(nil), (*v1beta3.CloudStackMachineTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(a.(*CloudStackMachineTemplateResource), b.(*v1beta3.CloudStackMachineTemplateResource), scope) + if err := s.AddConversionFunc((*v1.ObjectMeta)(nil), (*v1beta1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_ObjectMeta_To_v1beta1_ObjectMeta(a.(*v1.ObjectMeta), b.(*v1beta1.ObjectMeta), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta1.ObjectMeta)(nil), (*v1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ObjectMeta_To_v1_ObjectMeta(a.(*v1beta1.ObjectMeta), b.(*v1.ObjectMeta), scope) }); err != nil { return err } @@ -839,7 +850,7 @@ func autoConvert_v1beta2_CloudStackMachineSpec_To_v1beta3_CloudStackMachineSpec( out.Details = *(*map[string]string)(unsafe.Pointer(&in.Details)) out.AffinityGroupIDs = *(*[]string)(unsafe.Pointer(&in.AffinityGroupIDs)) out.Affinity = in.Affinity - out.AffinityGroupRef = (*v1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) + out.AffinityGroupRef = (*corev1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomainName = in.FailureDomainName out.UncompressedUserData = (*bool)(unsafe.Pointer(in.UncompressedUserData)) @@ -868,7 +879,7 @@ func autoConvert_v1beta3_CloudStackMachineSpec_To_v1beta2_CloudStackMachineSpec( out.Details = *(*map[string]string)(unsafe.Pointer(&in.Details)) out.AffinityGroupIDs = *(*[]string)(unsafe.Pointer(&in.AffinityGroupIDs)) out.Affinity = in.Affinity - out.AffinityGroupRef = (*v1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) + out.AffinityGroupRef = (*corev1.ObjectReference)(unsafe.Pointer(in.AffinityGroupRef)) out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomainName = in.FailureDomainName out.UncompressedUserData = (*bool)(unsafe.Pointer(in.UncompressedUserData)) @@ -975,7 +986,7 @@ func Convert_v1beta3_CloudStackMachineStateCheckerStatus_To_v1beta2_CloudStackMa } func autoConvert_v1beta2_CloudStackMachineStatus_To_v1beta3_CloudStackMachineStatus(in *CloudStackMachineStatus, out *v1beta3.CloudStackMachineStatus, s conversion.Scope) error { - out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = in.InstanceState out.InstanceStateLastUpdated = in.InstanceStateLastUpdated out.Ready = in.Ready @@ -990,7 +1001,7 @@ func Convert_v1beta2_CloudStackMachineStatus_To_v1beta3_CloudStackMachineStatus( } func autoConvert_v1beta3_CloudStackMachineStatus_To_v1beta2_CloudStackMachineStatus(in *v1beta3.CloudStackMachineStatus, out *CloudStackMachineStatus, s conversion.Scope) error { - out.Addresses = *(*[]v1.NodeAddress)(unsafe.Pointer(&in.Addresses)) + out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = in.InstanceState out.InstanceStateLastUpdated = in.InstanceStateLastUpdated out.Ready = in.Ready @@ -1073,14 +1084,24 @@ func Convert_v1beta3_CloudStackMachineTemplateList_To_v1beta2_CloudStackMachineT } func autoConvert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in *CloudStackMachineTemplateResource, out *v1beta3.CloudStackMachineTemplateResource, s conversion.Scope) error { - // WARNING: in.ObjectMeta requires manual conversion: does not exist in peer-type + if err := Convert_v1_ObjectMeta_To_v1beta1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { + return err + } if err := Convert_v1beta2_CloudStackMachineSpec_To_v1beta3_CloudStackMachineSpec(&in.Spec, &out.Spec, s); err != nil { return err } return nil } +// Convert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource is an autogenerated conversion function. +func Convert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in *CloudStackMachineTemplateResource, out *v1beta3.CloudStackMachineTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta2_CloudStackMachineTemplateResource_To_v1beta3_CloudStackMachineTemplateResource(in, out, s) +} + func autoConvert_v1beta3_CloudStackMachineTemplateResource_To_v1beta2_CloudStackMachineTemplateResource(in *v1beta3.CloudStackMachineTemplateResource, out *CloudStackMachineTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta1_ObjectMeta_To_v1_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { + return err + } if err := Convert_v1beta3_CloudStackMachineSpec_To_v1beta2_CloudStackMachineSpec(&in.Spec, &out.Spec, s); err != nil { return err } diff --git a/api/v1beta3/cloudstackmachinetemplate_types.go b/api/v1beta3/cloudstackmachinetemplate_types.go index 7eaeae75..16b54fb1 100644 --- a/api/v1beta3/cloudstackmachinetemplate_types.go +++ b/api/v1beta3/cloudstackmachinetemplate_types.go @@ -16,10 +16,18 @@ limitations under the License. package v1beta3 -import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) // CloudStackMachineTemplateResource defines the data needed to create a CloudstackMachine from a template type CloudStackMachineTemplateResource struct { + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` + // Spec is the specification of a desired behavior of the machine Spec CloudStackMachineSpec `json:"spec"` } diff --git a/api/v1beta3/zz_generated.deepcopy.go b/api/v1beta3/zz_generated.deepcopy.go index eabf2dc8..993a974a 100644 --- a/api/v1beta3/zz_generated.deepcopy.go +++ b/api/v1beta3/zz_generated.deepcopy.go @@ -689,6 +689,7 @@ func (in *CloudStackMachineTemplateList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CloudStackMachineTemplateResource) DeepCopyInto(out *CloudStackMachineTemplateResource) { *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) } diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinetemplates.yaml index f93eba63..2c1fe5bb 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinetemplates.yaml @@ -425,6 +425,27 @@ spec: description: CloudStackMachineTemplateResource defines the data needed to create a CloudstackMachine from a template properties: + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + properties: + annotations: + additionalProperties: + type: string + description: 'Annotations is an unstructured key value map + stored with a resource that may be set by external tools + to store and retrieve arbitrary metadata. They are not queryable + and should be preserved when modifying objects. More info: + http://kubernetes.io/docs/user-guide/annotations' + type: object + labels: + additionalProperties: + type: string + description: 'Map of string keys and values that can be used + to organize and categorize (scope and select) objects. May + match selectors of replication controllers and services. + More info: http://kubernetes.io/docs/user-guide/labels' + type: object + type: object spec: description: Spec is the specification of a desired behavior of the machine