Skip to content
Open
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
20 changes: 2 additions & 18 deletions cmd/catalogd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/metadata"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -97,7 +95,6 @@ type config struct {
webhookPort int
pullCasDir string
globalPullSecret string
kubeconfig string
// Generated config
globalPullSecretKey *k8stypes.NamespacedName
}
Expand Down Expand Up @@ -139,7 +136,6 @@ func init() {
flags.IntVar(&cfg.webhookPort, "webhook-server-port", 9443, "Webhook server port")
flags.StringVar(&cfg.pullCasDir, "pull-cas-dir", "", "The directory of TLS certificate authorities to use for verifying HTTPS connections to image registries.")
flags.StringVar(&cfg.globalPullSecret, "global-pull-secret", "", "Global pull secret (<namespace>/<name>)")
flags.StringVar(&cfg.kubeconfig, "kubeconfig", "", "Path to kubeconfig file for API server access. Uses in-cluster config if empty.")

// adds version subcommand
catalogdCmd.AddCommand(versionCommand)
Expand Down Expand Up @@ -277,20 +273,8 @@ func run(ctx context.Context) error {
return err
}

// Create manager with kubeconfig support for non-default kubeconfig
var restConfig *rest.Config
if cfg.kubeconfig != "" {
setupLog.Info("loading kubeconfig from file", "path", cfg.kubeconfig)
restConfig, err = clientcmd.BuildConfigFromFlags("", cfg.kubeconfig)
if err != nil {
setupLog.Error(err, "unable to load kubeconfig")
return err
}
} else {
restConfig = ctrl.GetConfigOrDie()
}

mgr, err := ctrl.NewManager(restConfig, ctrl.Options{
// Create manager
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metricsServerOptions,
PprofBindAddress: cfg.pprofAddr,
Expand Down
17 changes: 1 addition & 16 deletions cmd/operator-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import (
"k8s.io/client-go/discovery/cached/memory"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
"pkg.package-operator.run/boxcutter/managedcache"
Expand Down Expand Up @@ -107,7 +105,6 @@ type config struct {
catalogdCasDir string
pullCasDir string
globalPullSecret string
kubeconfig string
}

type reconcilerConfigurator interface {
Expand Down Expand Up @@ -187,7 +184,6 @@ func init() {
flags.StringVar(&cfg.cachePath, "cache-path", "/var/cache", "The local directory path used for filesystem based caching")
flags.StringVar(&cfg.systemNamespace, "system-namespace", "", "Configures the namespace that gets used to deploy system resources.")
flags.StringVar(&cfg.globalPullSecret, "global-pull-secret", "", "The <namespace>/<name> of the global pull secret that is going to be used to pull bundle images.")
flags.StringVar(&cfg.kubeconfig, "kubeconfig", "", "Path to kubeconfig file for API server access. Uses in-cluster config if empty.")

//adds version sub command
operatorControllerCmd.AddCommand(versionCommand)
Expand Down Expand Up @@ -329,18 +325,7 @@ func run() error {
"Metrics will not be served since the TLS certificate and key file are not provided.")
}

// Load REST config with kubeconfig support for non-default kubeconfig
var restConfig *rest.Config
if cfg.kubeconfig != "" {
setupLog.Info("loading kubeconfig from file", "path", cfg.kubeconfig)
restConfig, err = clientcmd.BuildConfigFromFlags("", cfg.kubeconfig)
if err != nil {
setupLog.Error(err, "unable to load kubeconfig")
return err
}
} else {
restConfig = ctrl.GetConfigOrDie()
}
restConfig := ctrl.GetConfigOrDie()
mgr, err := ctrl.NewManager(restConfig, ctrl.Options{
Scheme: scheme.Scheme,
Metrics: metricsServerOptions,
Expand Down
Loading