Skip to content

Commit

Permalink
Improve API package dependencies on controller-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
laozc committed Aug 16, 2023
1 parent 1a94554 commit a9541fc
Show file tree
Hide file tree
Showing 33 changed files with 87 additions and 47 deletions.
20 changes: 15 additions & 5 deletions apis/v1alpha3/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const (
Expand All @@ -33,12 +34,21 @@ var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// schemeBuilder is used to add go types to the GroupVersionKind scheme.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

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

// objectTypes contains all types to be registered to the GroupVersion.
objectTypes = []runtime.Object{}

// localSchemeBuilder is used for type conversions.
localSchemeBuilder = SchemeBuilder.SchemeBuilder
localSchemeBuilder = schemeBuilder
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/haproxyloadbalancer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ type HAProxyLoadBalancerList struct {
}

func init() {
SchemeBuilder.Register(&HAProxyLoadBalancer{}, &HAProxyLoadBalancerList{})
objectTypes = append(objectTypes, &HAProxyLoadBalancer{}, &HAProxyLoadBalancerList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ type VSphereClusterList struct {
}

func init() {
SchemeBuilder.Register(&VSphereCluster{}, &VSphereClusterList{})
objectTypes = append(objectTypes, &VSphereCluster{}, &VSphereClusterList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vsphereclusteridentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ type VSphereClusterIdentityList struct {
}

func init() {
SchemeBuilder.Register(&VSphereClusterIdentity{}, &VSphereClusterIdentityList{})
objectTypes = append(objectTypes, &VSphereClusterIdentity{}, &VSphereClusterIdentityList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vspheredeploymentzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ type VSphereDeploymentZoneList struct {
}

func init() {
SchemeBuilder.Register(&VSphereDeploymentZone{}, &VSphereDeploymentZoneList{})
objectTypes = append(objectTypes, &VSphereDeploymentZone{}, &VSphereDeploymentZoneList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vspherefailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ type VSphereFailureDomainList struct {
}

func init() {
SchemeBuilder.Register(&VSphereFailureDomain{}, &VSphereFailureDomainList{})
objectTypes = append(objectTypes, &VSphereFailureDomain{}, &VSphereFailureDomainList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vspheremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ type VSphereMachineList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachine{}, &VSphereMachineList{})
objectTypes = append(objectTypes, &VSphereMachine{}, &VSphereMachineList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vspheremachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ type VSphereMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
objectTypes = append(objectTypes, &VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha3/vspherevm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,5 @@ type VSphereVMList struct {
}

func init() {
SchemeBuilder.Register(&VSphereVM{}, &VSphereVMList{})
objectTypes = append(objectTypes, &VSphereVM{}, &VSphereVMList{})
}
20 changes: 15 additions & 5 deletions apis/v1alpha4/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package v1alpha4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const (
Expand All @@ -33,12 +34,21 @@ var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// schemeBuilder is used to add go types to the GroupVersionKind scheme.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

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

// objectTypes contains all types to be registered to the GroupVersion.
objectTypes = []runtime.Object{}

// localSchemeBuilder is used for type conversions.
localSchemeBuilder = SchemeBuilder.SchemeBuilder
localSchemeBuilder = schemeBuilder
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ type VSphereClusterList struct {
}

func init() {
SchemeBuilder.Register(&VSphereCluster{}, &VSphereClusterList{})
objectTypes = append(objectTypes, &VSphereCluster{}, &VSphereClusterList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vsphereclusteridentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ type VSphereClusterIdentityList struct {
}

func init() {
SchemeBuilder.Register(&VSphereClusterIdentity{}, &VSphereClusterIdentityList{})
objectTypes = append(objectTypes, &VSphereClusterIdentity{}, &VSphereClusterIdentityList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vsphereclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type VSphereClusterTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereClusterTemplate{}, &VSphereClusterTemplateList{})
objectTypes = append(objectTypes, &VSphereClusterTemplate{}, &VSphereClusterTemplateList{})
}

type VSphereClusterTemplateResource struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha4/vspheredeploymentzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ type VSphereDeploymentZoneList struct {
}

func init() {
SchemeBuilder.Register(&VSphereDeploymentZone{}, &VSphereDeploymentZoneList{})
objectTypes = append(objectTypes, &VSphereDeploymentZone{}, &VSphereDeploymentZoneList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vspherefailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ type VSphereFailureDomainList struct {
}

func init() {
SchemeBuilder.Register(&VSphereFailureDomain{}, &VSphereFailureDomainList{})
objectTypes = append(objectTypes, &VSphereFailureDomain{}, &VSphereFailureDomainList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vspheremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ type VSphereMachineList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachine{}, &VSphereMachineList{})
objectTypes = append(objectTypes, &VSphereMachine{}, &VSphereMachineList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vspheremachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ type VSphereMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
objectTypes = append(objectTypes, &VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
}
2 changes: 1 addition & 1 deletion apis/v1alpha4/vspherevm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,5 @@ type VSphereVMList struct {
}

func init() {
SchemeBuilder.Register(&VSphereVM{}, &VSphereVMList{})
objectTypes = append(objectTypes, &VSphereVM{}, &VSphereVMList{})
}
18 changes: 14 additions & 4 deletions apis/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const (
Expand All @@ -33,9 +34,18 @@ var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// schemeBuilder is used to add go types to the GroupVersionKind scheme.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

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

// objectTypes contains all types to be registered to the GroupVersion.
objectTypes = []runtime.Object{}
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ type VSphereClusterList struct {
}

func init() {
SchemeBuilder.Register(&VSphereCluster{}, &VSphereClusterList{})
objectTypes = append(objectTypes, &VSphereCluster{}, &VSphereClusterList{})
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vsphereclusteridentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ type VSphereClusterIdentityList struct {
}

func init() {
SchemeBuilder.Register(&VSphereClusterIdentity{}, &VSphereClusterIdentityList{})
objectTypes = append(objectTypes, &VSphereClusterIdentity{}, &VSphereClusterIdentityList{})
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vsphereclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type VSphereClusterTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereClusterTemplate{}, &VSphereClusterTemplateList{})
objectTypes = append(objectTypes, &VSphereClusterTemplate{}, &VSphereClusterTemplateList{})
}

type VSphereClusterTemplateResource struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/v1beta1/vspheredeploymentzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ type VSphereDeploymentZoneList struct {
}

func init() {
SchemeBuilder.Register(&VSphereDeploymentZone{}, &VSphereDeploymentZoneList{})
objectTypes = append(objectTypes, &VSphereDeploymentZone{}, &VSphereDeploymentZoneList{})
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vspherefailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@ type VSphereFailureDomainList struct {
}

func init() {
SchemeBuilder.Register(&VSphereFailureDomain{}, &VSphereFailureDomainList{})
objectTypes = append(objectTypes, &VSphereFailureDomain{}, &VSphereFailureDomainList{})
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vspheremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,5 @@ type VSphereMachineList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachine{}, &VSphereMachineList{})
objectTypes = append(objectTypes, &VSphereMachine{}, &VSphereMachineList{})
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vspheremachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ type VSphereMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
objectTypes = append(objectTypes, &VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
}
2 changes: 1 addition & 1 deletion apis/v1beta1/vspherevm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@ type VSphereVMList struct {
}

func init() {
SchemeBuilder.Register(&VSphereVM{}, &VSphereVMList{})
objectTypes = append(objectTypes, &VSphereVM{}, &VSphereVMList{})
}
18 changes: 14 additions & 4 deletions apis/vmware/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

const (
Expand All @@ -33,9 +34,18 @@ var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// schemeBuilder is used to add go types to the GroupVersionKind scheme.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

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

// objectTypes contains all types to be registered to the GroupVersion.
objectTypes = []runtime.Object{}
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion apis/vmware/v1beta1/providerserviceaccount_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ type ProviderServiceAccountList struct {
}

func init() {
SchemeBuilder.Register(&ProviderServiceAccount{}, &ProviderServiceAccountList{})
objectTypes = append(objectTypes, &ProviderServiceAccount{}, &ProviderServiceAccountList{})
}
2 changes: 1 addition & 1 deletion apis/vmware/v1beta1/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ func (r *VSphereCluster) SetConditions(conditions clusterv1.Conditions) {
}

func init() {
SchemeBuilder.Register(&VSphereCluster{}, &VSphereClusterList{})
objectTypes = append(objectTypes, &VSphereCluster{}, &VSphereClusterList{})
}
2 changes: 1 addition & 1 deletion apis/vmware/v1beta1/vsphereclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type VSphereClusterTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereClusterTemplate{}, &VSphereClusterTemplateList{})
objectTypes = append(objectTypes, &VSphereClusterTemplate{}, &VSphereClusterTemplateList{})
}

type VSphereClusterTemplateResource struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/vmware/v1beta1/vspheremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,5 @@ func (r *VSphereMachine) SetConditions(conditions clusterv1.Conditions) {
}

func init() {
SchemeBuilder.Register(&VSphereMachine{}, &VSphereMachineList{})
objectTypes = append(objectTypes, &VSphereMachine{}, &VSphereMachineList{})
}
2 changes: 1 addition & 1 deletion apis/vmware/v1beta1/vspheremachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ type VSphereMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
objectTypes = append(objectTypes, &VSphereMachineTemplate{}, &VSphereMachineTemplateList{})
}

0 comments on commit a9541fc

Please sign in to comment.