Skip to content

Commit

Permalink
Generate v1alpha4 types and conversions
Browse files Browse the repository at this point in the history
Signed-off-by: Sagar Muchhal <[email protected]>
  • Loading branch information
srm09 committed Jan 21, 2021
1 parent 69bfeb2 commit 5622424
Show file tree
Hide file tree
Showing 56 changed files with 7,134 additions and 216 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ generate-go: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate tar
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt

$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha2 \
--input-dirs=./api/v1alpha3 \
--output-file-base=zz_generated.conversion \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

Expand Down
22 changes: 12 additions & 10 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ version: "2"
domain: cluster.x-k8s.io
repo: sigs.k8s.io/cluster-api-provider-vsphere
resources:
- group: infrastructure
version: v1alpha2
kind: VSphereCluster
- group: infrastructure
version: v1alpha2
kind: VSphereMachine
- group: infrastructure
version: v1alpha2
kind: VSphereMachineTemplate
- group: infrastructure
version: v1alpha3
kind: VSphereCluster
Expand All @@ -26,4 +17,15 @@ resources:
- group: infrastructure
version: v1alpha3
kind: HAProxyLoadBalancer

- group: infrastructure
version: v1alpha4
kind: VSphereCluster
- group: infrastructure
version: v1alpha4
kind: VSphereMachine
- group: infrastructure
version: v1alpha4
kind: VSphereMachineTemplate
- group: infrastructure
version: v1alpha4
kind: VSphereVM
44 changes: 44 additions & 0 deletions api/v1alpha3/conversion_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2020 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 v1alpha3

import (
"testing"

. "github.com/onsi/gomega"

"k8s.io/apimachinery/pkg/runtime"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"

nextver "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4"
)

func TestFuzzyConversion(t *testing.T) {
g := NewWithT(t)
scheme := runtime.NewScheme()
g.Expect(AddToScheme(scheme)).To(Succeed())
g.Expect(nextver.AddToScheme(scheme)).To(Succeed())

t.Run("for VSphereCluster", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereCluster{}, &VSphereCluster{}))
t.Run("for VSphereCluster", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereClusterList{}, &VSphereClusterList{}))
t.Run("for VSphereMachine", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereMachine{}, &VSphereMachine{}))
t.Run("for VSphereMachineList", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereMachineList{}, &VSphereMachineList{}))
t.Run("for VSphereMachineTemplate", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereMachineTemplate{}, &VSphereMachineTemplate{}))
t.Run("for VSphereMachineTemplateList", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereMachineTemplateList{}, &VSphereMachineTemplateList{}))
t.Run("for VSphereVM", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereVM{}, &VSphereVM{}))
t.Run("for VSphereVMList", utilconversion.FuzzTestFunc(scheme, &nextver.VSphereVMList{}, &VSphereVMList{}))
}
1 change: 1 addition & 0 deletions api/v1alpha3/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ limitations under the License.
// Package v1alpha3 contains API Schema definitions for the infrastructure v1alpha3 API group
// +kubebuilder:object:generate=true
// +groupName=infrastructure.cluster.x-k8s.io
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4
package v1alpha3
3 changes: 3 additions & 0 deletions api/v1alpha3/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

// localSchemeBuilder is used for type conversions.
localSchemeBuilder = SchemeBuilder.SchemeBuilder
)
31 changes: 27 additions & 4 deletions api/v1alpha3/haproxyloadbalancer_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,31 @@ limitations under the License.

package v1alpha3

// Hub marks HAProxyLoadBalancer as a conversion hub.
func (*HAProxyLoadBalancer) Hub() {}
import (
infrav1alpha4 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks HAProxyLoadBalancerList as a conversion hub.
func (*HAProxyLoadBalancerList) Hub() {}
// ConvertTo converts this HAProxyLoadBalancer to the Hub version (v1alpha4).
func (src *HAProxyLoadBalancer) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.HAProxyLoadBalancer)
return Convert_v1alpha3_HAProxyLoadBalancer_To_v1alpha4_HAProxyLoadBalancer(src, dst, nil)
}

// ConvertFrom converts from the Hub version (v1alpha4) to this HAProxyLoadBalancer.
func (dst *HAProxyLoadBalancer) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.HAProxyLoadBalancer)
return Convert_v1alpha4_HAProxyLoadBalancer_To_v1alpha3_HAProxyLoadBalancer(src, dst, nil)
}

// ConvertTo converts this HAProxyLoadBalancerList to the Hub version (v1alpha4).
func (src *HAProxyLoadBalancerList) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.HAProxyLoadBalancerList)
return Convert_v1alpha3_HAProxyLoadBalancerList_To_v1alpha4_HAProxyLoadBalancerList(src, dst, nil)
}

// ConvertFrom converts this VSphereVM to the Hub version (v1alpha4).
func (dst *HAProxyLoadBalancerList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.HAProxyLoadBalancerList)
return Convert_v1alpha4_HAProxyLoadBalancerList_To_v1alpha3_HAProxyLoadBalancerList(src, dst, nil)
}
1 change: 0 additions & 1 deletion api/v1alpha3/haproxyloadbalancer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type HAProxyLoadBalancerStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=haproxyloadbalancers,scope=Namespaced
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// HAProxyLoadBalancer is the Schema for the haproxyloadbalancers API
Expand Down
31 changes: 27 additions & 4 deletions api/v1alpha3/vspherecluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,31 @@ limitations under the License.

package v1alpha3

// Hub marks VSphereCluster as a conversion hub.
func (*VSphereCluster) Hub() {}
import (
infrav1alpha4 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks VSphereClusterList as a conversion hub.
func (*VSphereClusterList) Hub() {}
// ConvertTo converts this VSphereCluster to the Hub version (v1alpha4).
func (src *VSphereCluster) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereCluster)
return Convert_v1alpha3_VSphereCluster_To_v1alpha4_VSphereCluster(src, dst, nil)
}

// ConvertFrom converts from the Hub version (v1alpha4) to this VSphereCluster.
func (dst *VSphereCluster) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereCluster)
return Convert_v1alpha4_VSphereCluster_To_v1alpha3_VSphereCluster(src, dst, nil)
}

// ConvertTo converts this VSphereClusterList to the Hub version (v1alpha4).
func (src *VSphereClusterList) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereClusterList)
return Convert_v1alpha3_VSphereClusterList_To_v1alpha4_VSphereClusterList(src, dst, nil)
}

// ConvertFrom converts this VSphereVM to the Hub version (v1alpha4).
func (dst *VSphereClusterList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereClusterList)
return Convert_v1alpha4_VSphereClusterList_To_v1alpha3_VSphereClusterList(src, dst, nil)
}
1 change: 0 additions & 1 deletion api/v1alpha3/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ type VSphereClusterStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=vsphereclusters,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// VSphereCluster is the Schema for the vsphereclusters API
Expand Down
31 changes: 27 additions & 4 deletions api/v1alpha3/vspheremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,31 @@ limitations under the License.

package v1alpha3

// Hub marks VSphereMachine as a conversion hub.
func (*VSphereMachine) Hub() {}
import (
infrav1alpha4 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks VSphereMachineList as a conversion hub.
func (*VSphereMachineList) Hub() {}
// ConvertTo converts this VSphereMachine to the Hub version (v1alpha4).
func (src *VSphereMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereMachine)
return Convert_v1alpha3_VSphereMachine_To_v1alpha4_VSphereMachine(src, dst, nil)
}

// ConvertFrom converts from the Hub version (v1alpha4) to this VSphereMachine.
func (dst *VSphereMachine) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereMachine)
return Convert_v1alpha4_VSphereMachine_To_v1alpha3_VSphereMachine(src, dst, nil)
}

// ConvertTo converts this VSphereMachineList to the Hub version (v1alpha4).
func (src *VSphereMachineList) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereMachineList)
return Convert_v1alpha3_VSphereMachineList_To_v1alpha4_VSphereMachineList(src, dst, nil)
}

// ConvertFrom converts from the Hub version (v1alpha4) to this VSphereMachineList.
func (dst *VSphereMachineList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereMachineList)
return Convert_v1alpha4_VSphereMachineList_To_v1alpha3_VSphereMachineList(src, dst, nil)
}
1 change: 0 additions & 1 deletion api/v1alpha3/vspheremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ type VSphereMachineStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=vspheremachines,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// VSphereMachine is the Schema for the vspheremachines API
Expand Down
28 changes: 24 additions & 4 deletions api/v1alpha3/vspheremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,28 @@ limitations under the License.

package v1alpha3

// Hub marks VSphereMachineTemplate as a conversion hub.
func (*VSphereMachineTemplate) Hub() {}
import (
infrav1alpha4 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks VSphereMachineTemplateList as a conversion hub.
func (*VSphereMachineTemplateList) Hub() {}
// ConvertTo
func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereMachineTemplate)
return Convert_v1alpha3_VSphereMachineTemplate_To_v1alpha4_VSphereMachineTemplate(src, dst, nil)
}

func (dst *VSphereMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereMachineTemplate)
return Convert_v1alpha4_VSphereMachineTemplate_To_v1alpha3_VSphereMachineTemplate(src, dst, nil)
}

func (src *VSphereMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereMachineTemplateList)
return Convert_v1alpha3_VSphereMachineTemplateList_To_v1alpha4_VSphereMachineTemplateList(src, dst, nil)
}

func (dst *VSphereMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereMachineTemplateList)
return Convert_v1alpha4_VSphereMachineTemplateList_To_v1alpha3_VSphereMachineTemplateList(src, dst, nil)
}
1 change: 0 additions & 1 deletion api/v1alpha3/vspheremachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type VSphereMachineTemplateSpec struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=vspheremachinetemplates,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion

// VSphereMachineTemplate is the Schema for the vspheremachinetemplates API
type VSphereMachineTemplate struct {
Expand Down
31 changes: 27 additions & 4 deletions api/v1alpha3/vspherevm_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,31 @@ limitations under the License.

package v1alpha3

// Hub marks VSphereVM as a conversion hub.
func (*VSphereVM) Hub() {}
import (
infrav1alpha4 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks VSphereVMList as a conversion hub.
func (*VSphereVMList) Hub() {}
// ConvertTo converts this VSphereVM to the Hub version (v1alpha4).
func (src *VSphereVM) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereVM)
return Convert_v1alpha3_VSphereVM_To_v1alpha4_VSphereVM(src, dst, nil)
}

// ConvertFrom converts from the Hub version (v1alpha4) to this VSphereVM.
func (dst *VSphereVM) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereVM)
return Convert_v1alpha4_VSphereVM_To_v1alpha3_VSphereVM(src, dst, nil)
}

// ConvertTo converts this VSphereVMList to the Hub version (v1alpha4).
func (src *VSphereVMList) ConvertTo(dstRaw conversion.Hub) error { // nolint
dst := dstRaw.(*infrav1alpha4.VSphereVMList)
return Convert_v1alpha3_VSphereVMList_To_v1alpha4_VSphereVMList(src, dst, nil)
}

// ConvertFrom converts this VSphereVM to the Hub version (v1alpha4).
func (dst *VSphereVMList) ConvertFrom(srcRaw conversion.Hub) error { // nolint
src := srcRaw.(*infrav1alpha4.VSphereVMList)
return Convert_v1alpha4_VSphereVMList_To_v1alpha3_VSphereVMList(src, dst, nil)
}
1 change: 0 additions & 1 deletion api/v1alpha3/vspherevm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ type VSphereVMStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=vspherevms,scope=Namespaced
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// VSphereVM is the Schema for the vspherevms API
Expand Down
Loading

0 comments on commit 5622424

Please sign in to comment.