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

Method load

pkg/cortex/runtime_config.go:57–89  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

55}
56
57func (l runtimeConfigLoader) load(r io.Reader) (any, error) {
58 var overrides = &RuntimeConfigValues{}
59
60 decoder := yaml.NewDecoder(r)
61 decoder.SetStrict(true)
62
63 // Decode the first document. An empty document (EOF) is OK.
64 if err := decoder.Decode(&overrides); err != nil && !errors.Is(err, io.EOF) {
65 return nil, err
66 }
67
68 // Ensure the provided YAML config is not composed of multiple documents,
69 if err := decoder.Decode(&RuntimeConfigValues{}); !errors.Is(err, io.EOF) {
70 return nil, errMultipleDocuments
71 }
72
73 targetStr := l.cfg.Target.String()
74 for _, target := range tenantLimitCheckTargets {
75 if strings.Contains(targetStr, target) {
76 // only check if target is `all`, `distributor`, "querier", and "ruler"
77 // refer to https://github.com/cortexproject/cortex/issues/6741#issuecomment-3067244929
78 if overrides != nil {
79 for _, ul := range overrides.TenantLimits {
80 if err := ul.Validate(l.cfg.NameValidationScheme, l.cfg.Distributor.ShardByAllLabels, l.cfg.Ingester.ActiveSeriesMetricsEnabled); err != nil {
81 return nil, err
82 }
83 }
84 }
85 }
86 }
87
88 return overrides, nil
89}
90
91func multiClientRuntimeConfigChannel(manager *runtimeconfig.Manager) func() <-chan kv.MultiRuntimeConfig {
92 if manager == nil {

Calls 4

DecodeMethod · 0.95
StringMethod · 0.65
IsMethod · 0.45
ValidateMethod · 0.45