From a63ebbf68ccf3b577c4e5a662afab09737f07a3e Mon Sep 17 00:00:00 2001 From: Gaelle Fournier Date: Tue, 24 Oct 2023 11:26:05 +0200 Subject: [PATCH] fix(core): Access configmap from another namespace --- pkg/util/registry/kep_1755.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/util/registry/kep_1755.go b/pkg/util/registry/kep_1755.go index e35185fbba..38fcb23bc1 100644 --- a/pkg/util/registry/kep_1755.go +++ b/pkg/util/registry/kep_1755.go @@ -22,18 +22,16 @@ import ( "github.com/apache/camel-k/v2/pkg/client" "gopkg.in/yaml.v2" - corev1 "k8s.io/api/core/v1" - k8errors "k8s.io/apimachinery/pkg/api/errors" - ctrl "sigs.k8s.io/controller-runtime/pkg/client" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // GetRegistryAddress KEP-1755 // https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry func GetRegistryAddress(ctx context.Context, c client.Client) (*string, error) { - config := corev1.ConfigMap{} - err := c.Get(ctx, ctrl.ObjectKey{Namespace: "kube-public", Name: "local-registry-hosting"}, &config) + config, err := c.CoreV1().ConfigMaps("kube-public").Get(ctx, "local-registry-hosting", metav1.GetOptions{}) if err != nil { - if k8errors.IsNotFound(err) { + if k8serrors.IsNotFound(err) { return nil, nil } return nil, err