MCPcopy Create free account
hub / github.com/cortexproject/cortex / Validate

Method Validate

pkg/cortex/cortex.go:189–262  ·  view source on GitHub ↗

Validate the cortex config and returns an error if the validation doesn't pass

(log log.Logger)

Source from the content-addressed store, hash-verified

187// Validate the cortex config and returns an error if the validation
188// doesn't pass
189func (c *Config) Validate(log log.Logger) error {
190 if err := c.validateYAMLEmptyNodes(); err != nil {
191 return err
192 }
193
194 switch c.NameValidationScheme {
195 case model.LegacyValidation, model.UTF8Validation:
196 default:
197 return fmt.Errorf("unsupported name validation scheme: %s", c.NameValidationScheme)
198 }
199
200 if c.HTTPPrefix != "" && !strings.HasPrefix(c.HTTPPrefix, "/") {
201 return errInvalidHTTPPrefix
202 }
203
204 if err := c.API.Validate(); err != nil {
205 return errors.Wrap(err, "invalid api config")
206 }
207 if err := c.Storage.Validate(); err != nil {
208 return errors.Wrap(err, "invalid storage config")
209 }
210 if err := c.RulerStorage.Validate(); err != nil {
211 return errors.Wrap(err, "invalid rulestore config")
212 }
213 if err := c.Ruler.Validate(c.LimitsConfig, log); err != nil {
214 return errors.Wrap(err, "invalid ruler config")
215 }
216 if err := c.BlocksStorage.Validate(); err != nil {
217 return errors.Wrap(err, "invalid TSDB config")
218 }
219 if err := c.LimitsConfig.Validate(c.NameValidationScheme, c.Distributor.ShardByAllLabels, c.Ingester.ActiveSeriesMetricsEnabled); err != nil {
220 return errors.Wrap(err, "invalid limits config")
221 }
222 if err := c.ResourceMonitor.Validate(); err != nil {
223 return errors.Wrap(err, "invalid resource-monitor config")
224 }
225 if err := c.Distributor.Validate(c.LimitsConfig); err != nil {
226 return errors.Wrap(err, "invalid distributor config")
227 }
228 if err := c.Querier.Validate(); err != nil {
229 return errors.Wrap(err, "invalid querier config")
230 }
231 if err := c.IngesterClient.Validate(log); err != nil {
232 return errors.Wrap(err, "invalid ingester_client config")
233 }
234 if err := c.Worker.Validate(log); err != nil {
235 return errors.Wrap(err, "invalid frontend_worker config")
236 }
237 if err := c.QueryRange.Validate(c.Querier); err != nil {
238 return errors.Wrap(err, "invalid query_range config")
239 }
240 if err := c.StoreGateway.Validate(c.LimitsConfig, c.ResourceMonitor.Resources); err != nil {
241 return errors.Wrap(err, "invalid store-gateway config")
242 }
243 if err := c.Compactor.Validate(c.LimitsConfig); err != nil {
244 return errors.Wrap(err, "invalid compactor config")
245 }
246 if err := c.AlertmanagerStorage.Validate(); err != nil {

Callers 2

TestConfigValidationFunction · 0.45
loadMethod · 0.45

Calls 2

WrapMethod · 0.65

Tested by 1

TestConfigValidationFunction · 0.36