MCPcopy
hub / github.com/grafana/tempo / validateExtensionLegacyKeys

Function validateExtensionLegacyKeys

modules/overrides/extension.go:121–142  ·  view source on GitHub ↗

validateExtensionLegacyKeys checks that legacyKeys declared by extension key are valid. Must be called with extensionRegistry.Lock held.

(key string, legacyKeys []string)

Source from the content-addressed store, hash-verified

119// validateExtensionLegacyKeys checks that legacyKeys declared by extension key are valid.
120// Must be called with extensionRegistry.Lock held.
121func validateExtensionLegacyKeys(key string, legacyKeys []string) {
122 seen := make(map[string]struct{}, len(legacyKeys))
123 for _, lk := range legacyKeys {
124 if lk == "" {
125 panic(fmt.Sprintf("overrides: extension %q has an empty legacy key", key))
126 }
127 if _, dup := seen[lk]; dup {
128 panic(fmt.Sprintf("overrides: extension %q has duplicate legacy key %q", key, lk))
129 }
130 seen[lk] = struct{}{}
131 if isKnownLegacyOverridesField(lk) {
132 panic(fmt.Sprintf("overrides: extension %q legacy key %q conflicts with a built-in LegacyOverrides field; choose a different legacy key", key, lk))
133 }
134 // Guard against collisions with already-registered extensions' nested keys and legacy keys.
135 if _, conflict := extensionRegistry.entries[lk]; conflict {
136 panic(fmt.Sprintf("overrides: extension %q legacy key %q conflicts with the key of extension %q", key, lk, lk))
137 }
138 if _, conflict := extensionRegistry.allLegacyKeys[lk]; conflict {
139 panic(fmt.Sprintf("overrides: extension %q legacy key %q conflicts with a legacy key of an already-registered extension", key, lk))
140 }
141 }
142}
143
144// processExtensions validates all entries in o.Extensions against the registry, converts raw
145// decoded values (from YAML or JSON) to typed Extension instances, applies defaults, and

Callers 1

RegisterExtensionFunction · 0.85

Calls 1

Tested by

no test coverage detected