MCPcopy Create free account
hub / github.com/cortexproject/cortex / NormalizeTenantIDs

Function NormalizeTenantIDs

pkg/util/users/tenant.go:38–55  ·  view source on GitHub ↗

NormalizeTenantIDs is creating a normalized form by sorting and de-duplicating the list of tenantIDs

(tenantIDs []string)

Source from the content-addressed store, hash-verified

36
37// NormalizeTenantIDs is creating a normalized form by sorting and de-duplicating the list of tenantIDs
38func NormalizeTenantIDs(tenantIDs []string) []string {
39 sort.Strings(tenantIDs)
40
41 count := len(tenantIDs)
42 if count <= 1 {
43 return tenantIDs
44 }
45
46 posOut := 1
47 for posIn := 1; posIn < count; posIn++ {
48 if tenantIDs[posIn] != tenantIDs[posIn-1] {
49 tenantIDs[posOut] = tenantIDs[posIn]
50 posOut++
51 }
52 }
53
54 return tenantIDs[0:posOut]
55}
56
57// ValidTenantID validate tenantID
58func ValidTenantID(s string) error {

Callers 1

ValidateOrgIDsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected