MCPcopy Create free account
hub / github.com/cozystack/cozystack / ParsePinnedTenants

Function ParsePinnedTenants

internal/fluxshardoperator/config.go:140–156  ·  view source on GitHub ↗

ParsePinnedTenants parses the --pinned-tenants flag value ("tenant-a=shard1,tenant-b=shard0") into a map.

(s string)

Source from the content-addressed store, hash-verified

138// ParsePinnedTenants parses the --pinned-tenants flag value
139// ("tenant-a=shard1,tenant-b=shard0") into a map.
140func ParsePinnedTenants(s string) (map[string]string, error) {
141 pinned := map[string]string{}
142 if s == "" {
143 return pinned, nil
144 }
145 for _, pair := range strings.Split(s, ",") {
146 k, v, found := strings.Cut(strings.TrimSpace(pair), "=")
147 if !found || k == "" {
148 return nil, fmt.Errorf("invalid pinned tenant entry %q, expected <tenant-namespace>=<shard>", pair)
149 }
150 if _, ok := ParseShardIndex(v); !ok {
151 return nil, fmt.Errorf("invalid shard %q for pinned tenant %q", v, k)
152 }
153 pinned[k] = v
154 }
155 return pinned, nil
156}

Callers 1

TestParsePinnedTenantsFunction · 0.85

Calls 1

ParseShardIndexFunction · 0.85

Tested by 1

TestParsePinnedTenantsFunction · 0.68