Skip to content

Commit

Permalink
Use apimachinery runtime to register API scheme
Browse files Browse the repository at this point in the history
To remove controller-runtime from our API package we replace its
"scheme" package with apimachinery's runtime.
  • Loading branch information
Fedosin committed Sep 28, 2023
1 parent 9398981 commit 6f0d541
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
4 changes: 0 additions & 4 deletions api/v1alpha2/addonprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ type AddonProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []AddonProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&AddonProvider{}, &AddonProviderList{})
}
4 changes: 0 additions & 4 deletions api/v1alpha2/bootstrapprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ type BootstrapProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []BootstrapProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&BootstrapProvider{}, &BootstrapProviderList{})
}
4 changes: 0 additions & 4 deletions api/v1alpha2/controlplaneprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ type ControlPlaneProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []ControlPlaneProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&ControlPlaneProvider{}, &ControlPlaneProviderList{})
}
4 changes: 0 additions & 4 deletions api/v1alpha2/coreprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ type CoreProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []CoreProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&CoreProvider{}, &CoreProviderList{})
}
20 changes: 18 additions & 2 deletions api/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,33 @@ limitations under the License.
package v1alpha2

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: "operator.cluster.x-k8s.io", Version: "v1alpha2"}

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

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

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&CoreProvider{}, &CoreProviderList{},
&BootstrapProvider{}, &BootstrapProviderList{},
&ControlPlaneProvider{}, &ControlPlaneProviderList{},
&InfrastructureProvider{}, &InfrastructureProviderList{},
&AddonProvider{}, &AddonProviderList{},
)

metav1.AddToGroupVersion(scheme, GroupVersion)

return nil
}
4 changes: 0 additions & 4 deletions api/v1alpha2/infrastructureprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,3 @@ type InfrastructureProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []InfrastructureProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&InfrastructureProvider{}, &InfrastructureProviderList{})
}

0 comments on commit 6f0d541

Please sign in to comment.