From 46cf5cde6836af93d10ff4122df65646ce581c53 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Tue, 9 Jul 2024 11:08:04 +0100 Subject: [PATCH] load default namespace at initialisation Signed-off-by: Enrique Lacal --- internal/apiserver/server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/apiserver/server.go b/internal/apiserver/server.go index 3fb337868..ca1671a05 100644 --- a/internal/apiserver/server.go +++ b/internal/apiserver/server.go @@ -61,6 +61,7 @@ type apiServer struct { ffiSwaggerGen FFISwaggerGen apiPublicURL string dynamicPublicURLHeader string + defaultNamespace string } func InitConfig() { @@ -76,6 +77,7 @@ func NewAPIServer() Server { apiTimeout: config.GetDuration(coreconfig.APIRequestTimeout), apiMaxTimeout: config.GetDuration(coreconfig.APIRequestMaxTimeout), dynamicPublicURLHeader: config.GetString(coreconfig.APIDynamicPublicURLHeader), + defaultNamespace: config.GetString(coreconfig.NamespacesDefault), metricsEnabled: config.GetBool(coreconfig.MetricsEnabled), ffiSwaggerGen: &ffiSwaggerGen{}, } @@ -188,9 +190,9 @@ func (as *apiServer) getBaseURL(req *http.Request) string { vars := mux.Vars(req) if ns, ok := vars["ns"]; ok && ns != "" { baseURL += `/namespaces/` + ns - } else if ns := config.GetString(coreconfig.NamespacesDefault); ns != "" { + } else { // Use the default namespace - baseURL += `/namespaces/` + ns + baseURL += `/namespaces/` + as.defaultNamespace } return baseURL