Skip to content

Commit

Permalink
Updates RestMapper to use controller-runtime DynamicRestMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
danehans committed Aug 12, 2020
1 parent 8aa1ce2 commit 826c995
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 115 deletions.
15 changes: 13 additions & 2 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ import (
dnscontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller/dns"
ingresscontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller/ingress"
statuscontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller/status"
operatorutil "github.com/openshift/cluster-ingress-operator/pkg/util"

operatorv1 "github.com/openshift/api/operator/v1"

"k8s.io/client-go/rest"

"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"

"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/manager"
)

Expand Down Expand Up @@ -59,7 +60,7 @@ func New(config operatorconfig.Config, kubeConfig *rest.Config) (*Operator, erro
mgr, err := manager.New(kubeConfig, manager.Options{
Namespace: config.Namespace,
Scheme: scheme,
MapperProvider: operatorutil.NewDynamicRESTMapper,
MapperProvider: newDynamicRESTMapper,
NewCache: cache.MultiNamespacedCacheBuilder([]string{
config.Namespace,
manifests.DefaultOperandNamespace,
Expand Down Expand Up @@ -187,3 +188,13 @@ func (o *Operator) ensureDefaultIngressController() error {
log.Info("created default ingresscontroller", "namespace", ic.Namespace, "name", ic.Name)
return nil
}

// newDynamicRESTMapper returns a DynamicRestMapper with default options.
func newDynamicRESTMapper(cfg *rest.Config) (meta.RESTMapper, error) {
drm, err := apiutil.NewDynamicRESTMapper(cfg)
if err != nil {
return nil, err
}

return drm, nil
}
113 changes: 0 additions & 113 deletions pkg/util/restmapper.go

This file was deleted.

0 comments on commit 826c995

Please sign in to comment.