MCPcopy Index your code
hub / github.com/cortexproject/cortex / setAllSecrets

Function setAllSecrets

pkg/cortex/modules_test.go:337–357  ·  view source on GitHub ↗

setAllSecrets recursively walks a reflect.Value and sets every flagext.Secret field's Value to the given sentinel string.

(v reflect.Value, sentinel string)

Source from the content-addressed store, hash-verified

335// setAllSecrets recursively walks a reflect.Value and sets every flagext.Secret
336// field's Value to the given sentinel string.
337func setAllSecrets(v reflect.Value, sentinel string) {
338 switch v.Kind() {
339 case reflect.Ptr:
340 if !v.IsNil() {
341 setAllSecrets(v.Elem(), sentinel)
342 }
343 case reflect.Struct:
344 secretType := reflect.TypeFor[flagext.Secret]()
345 for i := 0; i < v.NumField(); i++ {
346 f := v.Field(i)
347 if !f.CanSet() {
348 continue
349 }
350 if f.Type() == secretType {
351 f.Set(reflect.ValueOf(flagext.Secret{Value: sentinel}))
352 } else {
353 setAllSecrets(f, sentinel)
354 }
355 }
356 }
357}

Callers 1

Calls 2

TypeMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected