MCPcopy
hub / github.com/etcd-io/etcd / Add

Method Add

pkg/featuregate/feature_gate.go:265–292  ·  view source on GitHub ↗

Add adds features to the featureGate.

(features map[Feature]FeatureSpec)

Source from the content-addressed store, hash-verified

263
264// Add adds features to the featureGate.
265func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
266 f.lock.Lock()
267 defer f.lock.Unlock()
268
269 if f.closed {
270 return fmt.Errorf("cannot add a feature gate after adding it to the flag set")
271 }
272
273 // Copy existing state
274 known := map[Feature]FeatureSpec{}
275 maps.Copy(known, f.known.Load().(map[Feature]FeatureSpec))
276
277 for name, spec := range features {
278 if existingSpec, found := known[name]; found {
279 if existingSpec == spec {
280 continue
281 }
282 return fmt.Errorf("feature gate %q with different spec already exists: %v", name, existingSpec)
283 }
284
285 known[name] = spec
286 }
287
288 // Persist updated state
289 f.known.Store(known)
290
291 return nil
292}
293
294func (f *featureGate) OverrideDefault(name Feature, override bool) error {
295 f.lock.Lock()

Callers

nothing calls this directly

Calls 6

LoadMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
ErrorfMethod · 0.65
CopyMethod · 0.65
StoreMethod · 0.65

Tested by

no test coverage detected