NormalizeTenantIDs is creating a normalized form by sorting and de-duplicating the list of tenantIDs
(tenantIDs []string)
| 36 | |
| 37 | // NormalizeTenantIDs is creating a normalized form by sorting and de-duplicating the list of tenantIDs |
| 38 | func 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 |
| 58 | func ValidTenantID(s string) error { |