diff --git a/components/odh-notebook-controller/controllers/notebook_controller.go b/components/odh-notebook-controller/controllers/notebook_controller.go index b97b12ea18b..c71aad584c5 100644 --- a/components/odh-notebook-controller/controllers/notebook_controller.go +++ b/components/odh-notebook-controller/controllers/notebook_controller.go @@ -54,7 +54,7 @@ const ( // OpenshiftNotebookReconciler holds the controller configuration. type OpenshiftNotebookReconciler struct { client.Client - Namespace: string + Namespace string Scheme *runtime.Scheme Log logr.Logger } diff --git a/components/odh-notebook-controller/controllers/notebook_webhook.go b/components/odh-notebook-controller/controllers/notebook_webhook.go index 8b96ac0f822..2e431049829 100644 --- a/components/odh-notebook-controller/controllers/notebook_webhook.go +++ b/components/odh-notebook-controller/controllers/notebook_webhook.go @@ -37,7 +37,6 @@ import ( "k8s.io/client-go/rest" "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" - ctrlruntime "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) @@ -458,26 +457,6 @@ func InjectCertConfig(notebook *nbv1.Notebook, configMapName string) error { return nil } -func getControllerNamespace() (string, error) { - // Check if running inside a Kubernetes cluster - // GetConfig(): If KUBECONFIG env variable is set, it is used to create - // the client, else the inClusterConfig() is used. - // Lastly if none of them are set, it uses $HOME/.kube/config to create the client. - _, err := ctrlruntime.GetConfig() - if err != nil { - return "", fmt.Errorf("error creating the config object, not running inside a Kubernetes/Openshift Cluster %v", err) - } - - // Try to get the namespace from the service account secret - if data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { - if ns := string(data); len(ns) > 0 { - return ns, nil - } - } - - return "", fmt.Errorf("unable to determine the namespace") -} - // SetContainerImageFromRegistry checks if there is an internal registry and takes the corresponding actions to set the container.image value. // If an internal registry is detected, it uses the default values specified in the Notebook Custom Resource (CR). // Otherwise, it checks the last-image-selection annotation to find the image stream and fetches the image from status.dockerImageReference,