diff --git a/api/v1alpha1/provider_conversion.go b/api/v1alpha1/provider_conversion.go index 9666b8a08..05e06ee4a 100644 --- a/api/v1alpha1/provider_conversion.go +++ b/api/v1alpha1/provider_conversion.go @@ -21,6 +21,7 @@ import ( apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "k8s.io/utils/pointer" + utilconversion "sigs.k8s.io/cluster-api/util/conversion" ctrlconfigv1 "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/conversion" @@ -34,7 +35,19 @@ func (src *BootstrapProvider) ConvertTo(dstRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.BootstrapProvider") } - return Convert_v1alpha1_BootstrapProvider_To_v1alpha2_BootstrapProvider(src, dst, nil) + if err := Convert_v1alpha1_BootstrapProvider_To_v1alpha2_BootstrapProvider(src, dst, nil); err != nil { + return err + } + + // Manually restore data. + restored := &operatorv1.BootstrapProvider{} + if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { + return err + } + + dst.Spec.ManifestPatches = restored.Spec.ManifestPatches + + return nil } // ConvertFrom converts from the BootstrapProvider version (v1alpha2) to this version. @@ -44,7 +57,16 @@ func (dst *BootstrapProvider) ConvertFrom(srcRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.BootstrapProvider") } - return Convert_v1alpha2_BootstrapProvider_To_v1alpha1_BootstrapProvider(src, dst, nil) + if err := Convert_v1alpha2_BootstrapProvider_To_v1alpha1_BootstrapProvider(src, dst, nil); err != nil { + return err + } + + // Preserve Hub data on down-conversion. + if err := utilconversion.MarshalData(src, dst); err != nil { + return err + } + + return nil } // ConvertTo converts this BootstrapProviderList to the Hub version (v1alpha2). @@ -74,7 +96,19 @@ func (src *ControlPlaneProvider) ConvertTo(dstRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.ControlPlaneProvider") } - return Convert_v1alpha1_ControlPlaneProvider_To_v1alpha2_ControlPlaneProvider(src, dst, nil) + if err := Convert_v1alpha1_ControlPlaneProvider_To_v1alpha2_ControlPlaneProvider(src, dst, nil); err != nil { + return err + } + + // Manually restore data. + restored := &operatorv1.ControlPlaneProvider{} + if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { + return err + } + + dst.Spec.ManifestPatches = restored.Spec.ManifestPatches + + return nil } // ConvertFrom converts from the ControlPlaneProvider version (v1alpha2) to this version. @@ -84,7 +118,16 @@ func (dst *ControlPlaneProvider) ConvertFrom(srcRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.ControlPlaneProvider") } - return Convert_v1alpha2_ControlPlaneProvider_To_v1alpha1_ControlPlaneProvider(src, dst, nil) + if err := Convert_v1alpha2_ControlPlaneProvider_To_v1alpha1_ControlPlaneProvider(src, dst, nil); err != nil { + return err + } + + // Preserve Hub data on down-conversion. + if err := utilconversion.MarshalData(src, dst); err != nil { + return err + } + + return nil } // ConvertTo converts this ControlPlaneProviderList to the Hub version (v1alpha2). @@ -114,7 +157,19 @@ func (src *CoreProvider) ConvertTo(dstRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.CoreProvider") } - return Convert_v1alpha1_CoreProvider_To_v1alpha2_CoreProvider(src, dst, nil) + if err := Convert_v1alpha1_CoreProvider_To_v1alpha2_CoreProvider(src, dst, nil); err != nil { + return err + } + + // Manually restore data. + restored := &operatorv1.CoreProvider{} + if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { + return err + } + + dst.Spec.ManifestPatches = restored.Spec.ManifestPatches + + return nil } // ConvertFrom converts from the CoreProvider version (v1alpha2) to this version. @@ -124,7 +179,16 @@ func (dst *CoreProvider) ConvertFrom(srcRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.CoreProvider") } - return Convert_v1alpha2_CoreProvider_To_v1alpha1_CoreProvider(src, dst, nil) + if err := Convert_v1alpha2_CoreProvider_To_v1alpha1_CoreProvider(src, dst, nil); err != nil { + return err + } + + // Preserve Hub data on down-conversion. + if err := utilconversion.MarshalData(src, dst); err != nil { + return err + } + + return nil } // ConvertTo converts this CoreProviderList to the Hub version (v1alpha2). @@ -154,7 +218,19 @@ func (src *InfrastructureProvider) ConvertTo(dstRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.InfrastructureProvider") } - return Convert_v1alpha1_InfrastructureProvider_To_v1alpha2_InfrastructureProvider(src, dst, nil) + if err := Convert_v1alpha1_InfrastructureProvider_To_v1alpha2_InfrastructureProvider(src, dst, nil); err != nil { + return err + } + + // Manually restore data. + restored := &operatorv1.InfrastructureProvider{} + if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { + return err + } + + dst.Spec.ManifestPatches = restored.Spec.ManifestPatches + + return nil } // ConvertFrom converts from the InfrastructureProvider version (v1alpha2) to this version. @@ -164,7 +240,16 @@ func (dst *InfrastructureProvider) ConvertFrom(srcRaw conversion.Hub) error { panic("expected to get an of object of type v1alpha2.InfrastructureProvider") } - return Convert_v1alpha2_InfrastructureProvider_To_v1alpha1_InfrastructureProvider(src, dst, nil) + if err := Convert_v1alpha2_InfrastructureProvider_To_v1alpha1_InfrastructureProvider(src, dst, nil); err != nil { + return err + } + + // Preserve Hub data on down-conversion. + if err := utilconversion.MarshalData(src, dst); err != nil { + return err + } + + return nil } // ConvertTo converts this InfrastructureProviderList to the Hub version (v1alpha2). diff --git a/api/v1alpha1/zz_generated.conversion.go b/api/v1alpha1/zz_generated.conversion.go index 89e65dec9..c0f86fc96 100644 --- a/api/v1alpha1/zz_generated.conversion.go +++ b/api/v1alpha1/zz_generated.conversion.go @@ -944,6 +944,7 @@ func autoConvert_v1alpha2_ProviderSpec_To_v1alpha1_ProviderSpec(in *v1alpha2.Pro // WARNING: in.ConfigSecret requires manual conversion: does not exist in peer-type out.FetchConfig = (*FetchConfiguration)(unsafe.Pointer(in.FetchConfig)) out.AdditionalManifestsRef = (*ConfigmapReference)(unsafe.Pointer(in.AdditionalManifestsRef)) + // WARNING: in.ManifestPatches requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1alpha2/provider_types.go b/api/v1alpha2/provider_types.go index 9620232ea..d2bd04711 100644 --- a/api/v1alpha2/provider_types.go +++ b/api/v1alpha2/provider_types.go @@ -65,6 +65,14 @@ type ProviderSpec struct { // namespace of the provider will be used. There is no validation of the yaml content inside the configmap. // +optional AdditionalManifestsRef *ConfigmapReference `json:"additionalManifests,omitempty"` + + // ManifestPatches are applied to rendered provider manifests to customize the + // provider manifests. Patches are applied in the order they are specified. + // The `kind` field must match the target object, and + // if `apiVersion` is specified it will only be applied to matching objects. + // This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396 + // +optional + ManifestPatches []string `json:"manifestPatches,omitempty"` } // ConfigmapReference contains enough information to locate the configmap. diff --git a/api/v1alpha2/zz_generated.deepcopy.go b/api/v1alpha2/zz_generated.deepcopy.go index 1b5da16b7..4c81e750e 100644 --- a/api/v1alpha2/zz_generated.deepcopy.go +++ b/api/v1alpha2/zz_generated.deepcopy.go @@ -786,6 +786,11 @@ func (in *ProviderSpec) DeepCopyInto(out *ProviderSpec) { *out = new(ConfigmapReference) **out = **in } + if in.ManifestPatches != nil { + in, out := &in.ManifestPatches, &out.ManifestPatches + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpec. diff --git a/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml index 2b1cb8509..452e5a95c 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_addonproviders.yaml @@ -1466,6 +1466,15 @@ spec: type: integer type: object type: object + manifestPatches: + description: ManifestPatches are applied to rendered provider manifests + to customize the provider manifests. Patches are applied in the + order they are specified. The `kind` field must match the target + object, and if `apiVersion` is specified it will only be applied + to matching objects. This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396 + items: + type: string + type: array version: description: Version indicates the provider version. type: string diff --git a/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml index 238f04bc8..2e04be231 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml @@ -2995,6 +2995,15 @@ spec: type: integer type: object type: object + manifestPatches: + description: ManifestPatches are applied to rendered provider manifests + to customize the provider manifests. Patches are applied in the + order they are specified. The `kind` field must match the target + object, and if `apiVersion` is specified it will only be applied + to matching objects. This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396 + items: + type: string + type: array version: description: Version indicates the provider version. type: string diff --git a/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml index b84958716..6e288462b 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml @@ -2998,6 +2998,15 @@ spec: type: integer type: object type: object + manifestPatches: + description: ManifestPatches are applied to rendered provider manifests + to customize the provider manifests. Patches are applied in the + order they are specified. The `kind` field must match the target + object, and if `apiVersion` is specified it will only be applied + to matching objects. This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396 + items: + type: string + type: array version: description: Version indicates the provider version. type: string diff --git a/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml index ee58fd530..b1d50c4d7 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml @@ -2995,6 +2995,15 @@ spec: type: integer type: object type: object + manifestPatches: + description: ManifestPatches are applied to rendered provider manifests + to customize the provider manifests. Patches are applied in the + order they are specified. The `kind` field must match the target + object, and if `apiVersion` is specified it will only be applied + to matching objects. This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396 + items: + type: string + type: array version: description: Version indicates the provider version. type: string diff --git a/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml b/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml index 5a57c38e2..6d85fbbcc 100644 --- a/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml +++ b/config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml @@ -2998,6 +2998,15 @@ spec: type: integer type: object type: object + manifestPatches: + description: ManifestPatches are applied to rendered provider manifests + to customize the provider manifests. Patches are applied in the + order they are specified. The `kind` field must match the target + object, and if `apiVersion` is specified it will only be applied + to matching objects. This should be an inline yaml blob-string https://datatracker.ietf.org/doc/html/rfc7396 + items: + type: string + type: array version: description: Version indicates the provider version. type: string