K8s: Use stacks plural not singular in grafana namespaces (#92550)
This commit is contained in:
@@ -17,6 +17,21 @@ type NamespaceMapper = claims.NamespaceFormatter
|
||||
|
||||
// GetNamespaceMapper returns a function that will convert orgIds into a consistent namespace
|
||||
func GetNamespaceMapper(cfg *setting.Cfg) NamespaceMapper {
|
||||
if cfg != nil && cfg.StackID != "" {
|
||||
stackId, err := strconv.ParseInt(cfg.StackID, 10, 64)
|
||||
if err != nil {
|
||||
stackId = 0
|
||||
}
|
||||
// Temporarily force this as plural
|
||||
cloudNamespace := fmt.Sprintf("stacks-%d", stackId)
|
||||
// cloudNamespace := claims.CloudNamespaceFormatter(stackIdInt)
|
||||
return func(_ int64) string { return cloudNamespace }
|
||||
}
|
||||
return claims.OrgNamespaceFormatter
|
||||
}
|
||||
|
||||
// Temporary version that is only passed to th
|
||||
func GetTemporarySingularNamespaceMapper(cfg *setting.Cfg) NamespaceMapper {
|
||||
if cfg != nil && cfg.StackID != "" {
|
||||
stackIdInt, err := strconv.ParseInt(cfg.StackID, 10, 64)
|
||||
if err != nil {
|
||||
|
||||
@@ -32,8 +32,8 @@ func TestNamespaceMapper(t *testing.T) {
|
||||
{
|
||||
name: "with stackId",
|
||||
cfg: "abc",
|
||||
orgId: 123, // ignored
|
||||
expected: "stack-0", // we parse to int and default to 0
|
||||
orgId: 123, // ignored
|
||||
expected: "stacks-0", // we parse to int and default to 0
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user