diff --git a/exp/api/v1alpha4/azuremachinepoolmachine_conversion.go b/exp/api/v1alpha4/azuremachinepoolmachine_conversion.go new file mode 100644 index 00000000000..efcbeb5f2e7 --- /dev/null +++ b/exp/api/v1alpha4/azuremachinepoolmachine_conversion.go @@ -0,0 +1,36 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha4 + +import ( + expv1beta1 "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/conversion" +) + +// ConvertTo converts this AzureMachinePoolMachine to the Hub version (v1beta1). +func (src *AzureMachinePoolMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint + dst := dstRaw.(*expv1beta1.AzureMachinePoolMachine) + + return Convert_v1alpha4_AzureMachinePoolMachine_To_v1beta1_AzureMachinePoolMachine(src, dst, nil) +} + +// ConvertFrom converts from the Hub version (v1beta1) to this version. +func (dst *AzureMachinePoolMachine) ConvertFrom(srcRaw conversion.Hub) error { // nolint + src := srcRaw.(*expv1beta1.AzureMachinePoolMachine) + + return Convert_v1beta1_AzureMachinePoolMachine_To_v1alpha4_AzureMachinePoolMachine(src, dst, nil) +} diff --git a/exp/api/v1alpha4/conversion_test.go b/exp/api/v1alpha4/conversion_test.go index 9379999c568..c313d9b8e77 100644 --- a/exp/api/v1alpha4/conversion_test.go +++ b/exp/api/v1alpha4/conversion_test.go @@ -56,4 +56,10 @@ func TestFuzzyConversion(t *testing.T) { Spoke: &AzureManagedMachinePool{}, })) + t.Run("for AzureMachinePoolMachine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ + Scheme: scheme, + Hub: &v1beta1.AzureMachinePoolMachine{}, + Spoke: &AzureMachinePoolMachine{}, + })) + } diff --git a/exp/api/v1beta1/azuremachinepoolmachine_conversion.go b/exp/api/v1beta1/azuremachinepoolmachine_conversion.go new file mode 100644 index 00000000000..c9b39359fc5 --- /dev/null +++ b/exp/api/v1beta1/azuremachinepoolmachine_conversion.go @@ -0,0 +1,23 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +// Hub marks AzureMachinePoolMachine as a conversion hub. +func (*AzureMachinePoolMachine) Hub() {} + +// Hub marks AzureMachinePoolMachineList as a conversion hub. +func (*AzureMachinePoolMachineList) Hub() {}