Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hub and conversion for AzureMachinePoolMachine #1799

Merged
merged 1 commit into from Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 AzureMachinePoolMachine to the Hub version (v1beta1).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devigned I believe you also need to add conversion from v1alpha3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AzureMachinePoolMachines didn't exist in v1alpha3. They were introduced in v1alpha4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's what I was missing. Thank you.

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() {}