Skip to content

Commit

Permalink
Add hub and conversion for AzureMachinePoolMachine
Browse files Browse the repository at this point in the history
  • Loading branch information
devigned committed Oct 27, 2021
1 parent 505ea5f commit dfd8119
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
36 changes: 36 additions & 0 deletions 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 AzureMachinePool 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)
}
6 changes: 6 additions & 0 deletions exp/api/v1alpha4/conversion_test.go
Expand Up @@ -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{},
}))

}
23 changes: 23 additions & 0 deletions 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() {}

0 comments on commit dfd8119

Please sign in to comment.