Skip to content

Commit

Permalink
fix: register scheme in operator (#619)
Browse files Browse the repository at this point in the history
Instead of trying to shoehorn it into the controller.

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
  • Loading branch information
jan--f authored Nov 7, 2024
1 parent 21e89a0 commit d86ab09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 0 additions & 13 deletions pkg/controllers/operator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

type resourceManager struct {
Expand All @@ -49,17 +47,6 @@ type resourceManager struct {
// RegisterWithManager registers the controller with Manager
func RegisterWithManager(mgr ctrl.Manager, namespace string) error {

// GroupVersion is group version used to register these objects
GroupVersion := schema.GroupVersion{Group: "", Version: "v1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder := &scheme.Builder{GroupVersion: GroupVersion}
SchemeBuilder.Register(&corev1.Service{}, &corev1.ServiceList{})
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "monitoring.coreos.com", Version: "v1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
SchemeBuilder.Register(&monv1.ServiceMonitor{}, &monv1.ServiceMonitorList{})

rm := &resourceManager{
k8sClient: mgr.GetClient(),
scheme: mgr.GetScheme(),
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
osv1 "github.com/openshift/api/console/v1"
osv1alpha1 "github.com/openshift/api/console/v1alpha1"
operatorv1 "github.com/openshift/api/operator/v1"
monv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
monitoringv1 "github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring/v1"
multiclusterhubv1 "github.com/stolostron/multiclusterhub-operator/api/v1"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -29,6 +31,8 @@ func NewScheme(cfg *OperatorConfiguration) *runtime.Scheme {
utilruntime.Must(osv1alpha1.Install(scheme))
utilruntime.Must(operatorv1.Install(scheme))
utilruntime.Must(multiclusterhubv1.AddToScheme(scheme))
utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(monv1.AddToScheme(scheme))
}

return scheme
Expand Down

0 comments on commit d86ab09

Please sign in to comment.