K8s: expose namespace in frontend_settings (#78090)
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
This commit is contained in:
co-authored by
Todd Treece
parent
1be1432926
commit
ea37a116f7
@@ -230,6 +230,9 @@ type FrontendSettingsDTO struct {
|
||||
|
||||
LoginError string `json:"loginError,omitempty"`
|
||||
|
||||
// The K8s namespace to use for this user
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
|
||||
PluginsCDNBaseURL string `json:"pluginsCDNBaseURL,omitempty"`
|
||||
|
||||
SqlConnectionLimits FrontendSettingsSqlConnectionLimitsDTO `json:"sqlConnectionLimits"`
|
||||
|
||||
@@ -274,6 +274,9 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
frontendSettings.GeomapDisableCustomBaseLayer = true
|
||||
}
|
||||
|
||||
// Set the kubernetes namespace
|
||||
frontendSettings.Namespace = hs.namespacer(c.SignedInUser.OrgID)
|
||||
|
||||
return frontendSettings, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/pluginscdn"
|
||||
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/grafana-apiserver/endpoints/request"
|
||||
"github.com/grafana/grafana/pkg/services/licensing"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||
@@ -75,6 +76,7 @@ func setupTestEnvironment(t *testing.T, cfg *setting.Cfg, features *featuremgmt.
|
||||
PluginsCDNURLTemplate: cfg.PluginsCDNURLTemplate,
|
||||
PluginSettings: cfg.PluginSettings,
|
||||
}),
|
||||
namespacer: request.GetNamespaceMapper(cfg),
|
||||
SocialService: social.ProvideService(cfg, features, &usagestats.UsageStatsMock{}, supportbundlestest.NewFakeBundleService(), remotecache.NewFakeCacheStorage()),
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
grafanaapiserver "github.com/grafana/grafana/pkg/services/grafana-apiserver"
|
||||
"github.com/grafana/grafana/pkg/services/grafana-apiserver/endpoints/request"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/avatar"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
@@ -206,6 +207,7 @@ type HTTPServer struct {
|
||||
starApi *starApi.API
|
||||
promRegister prometheus.Registerer
|
||||
clientConfigProvider grafanaapiserver.DirectRestConfigProvider
|
||||
namespacer request.NamespaceMapper
|
||||
}
|
||||
|
||||
type ServerOptions struct {
|
||||
@@ -348,6 +350,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
|
||||
starApi: starApi,
|
||||
promRegister: promRegister,
|
||||
clientConfigProvider: clientConfigProvider,
|
||||
namespacer: request.GetNamespaceMapper(cfg),
|
||||
}
|
||||
if hs.Listener != nil {
|
||||
hs.log.Debug("Using provided listener")
|
||||
|
||||
Reference in New Issue
Block a user