Skip to content

Move away from use of controller-runtime scheme while registering api types #2287

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

Merged
merged 1 commit into from
Apr 2, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions api/v1beta2/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ limitations under the License.
package v1beta2

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"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta2"}

// 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 = []runtime.Object{}
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,5 @@ func (rf *ResourceReference) Set(resource ResourceReference) {
}

func init() {
SchemeBuilder.Register(&IBMPowerVSCluster{}, &IBMPowerVSClusterList{})
objectTypes = append(objectTypes, &IBMPowerVSCluster{}, &IBMPowerVSClusterList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervsclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ type IBMPowerVSClusterTemplateResource struct {
}

func init() {
SchemeBuilder.Register(&IBMPowerVSClusterTemplate{}, &IBMPowerVSClusterTemplateList{})
objectTypes = append(objectTypes, &IBMPowerVSClusterTemplate{}, &IBMPowerVSClusterTemplateList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervsimage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ type IBMPowerVSImageList struct {
}

func init() {
SchemeBuilder.Register(&IBMPowerVSImage{}, &IBMPowerVSImageList{})
objectTypes = append(objectTypes, &IBMPowerVSImage{}, &IBMPowerVSImageList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,5 @@ type IBMPowerVSMachineList struct {
}

func init() {
SchemeBuilder.Register(&IBMPowerVSMachine{}, &IBMPowerVSMachineList{})
objectTypes = append(objectTypes, &IBMPowerVSMachine{}, &IBMPowerVSMachineList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmpowervsmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ type IBMPowerVSMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&IBMPowerVSMachineTemplate{}, &IBMPowerVSMachineTemplateList{})
objectTypes = append(objectTypes, &IBMPowerVSMachineTemplate{}, &IBMPowerVSMachineTemplateList{})
}
8 changes: 4 additions & 4 deletions api/v1beta2/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ type IBMVPCClusterList struct {
Items []IBMVPCCluster `json:"items"`
}

func init() {
SchemeBuilder.Register(&IBMVPCCluster{}, &IBMVPCClusterList{})
}

// GetConditions returns the observations of the operational state of the IBMVPCCluster resource.
func (r *IBMVPCCluster) GetConditions() capiv1beta1.Conditions {
return r.Status.Conditions
Expand All @@ -398,3 +394,7 @@ func (r *IBMVPCCluster) GetConditions() capiv1beta1.Conditions {
func (r *IBMVPCCluster) SetConditions(conditions capiv1beta1.Conditions) {
r.Status.Conditions = conditions
}

func init() {
objectTypes = append(objectTypes, &IBMVPCCluster{}, &IBMVPCClusterList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmvpcclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ type IBMVPCClusterTemplateResource struct {
}

func init() {
SchemeBuilder.Register(&IBMVPCClusterTemplate{}, &IBMVPCClusterTemplateList{})
objectTypes = append(objectTypes, &IBMVPCClusterTemplate{}, &IBMVPCClusterTemplateList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmvpcmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,5 @@ type IBMVPCMachineList struct {
}

func init() {
SchemeBuilder.Register(&IBMVPCMachine{}, &IBMVPCMachineList{})
objectTypes = append(objectTypes, &IBMVPCMachine{}, &IBMVPCMachineList{})
}
2 changes: 1 addition & 1 deletion api/v1beta2/ibmvpcmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ type IBMVPCMachineTemplateList struct {
}

func init() {
SchemeBuilder.Register(&IBMVPCMachineTemplate{}, &IBMVPCMachineTemplateList{})
objectTypes = append(objectTypes, &IBMVPCMachineTemplate{}, &IBMVPCMachineTemplateList{})
}