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

Method SetConfig

pkg/configs/db/postgres/postgres.go:164–178  ·  view source on GitHub ↗

SetConfig sets a configuration.

(ctx context.Context, userID string, cfg userconfig.Config)

Source from the content-addressed store, hash-verified

162
163// SetConfig sets a configuration.
164func (d DB) SetConfig(ctx context.Context, userID string, cfg userconfig.Config) error {
165 if !cfg.RulesConfig.FormatVersion.IsValid() {
166 return fmt.Errorf("invalid rule format version %v", cfg.RulesConfig.FormatVersion)
167 }
168 cfgBytes, err := json.Marshal(cfg)
169 if err != nil {
170 return err
171 }
172
173 _, err = d.Insert("configs").
174 Columns("owner_id", "owner_type", "subsystem", "config").
175 Values(userID, entityType, subsystem, cfgBytes).
176 Exec()
177 return err
178}
179
180// GetAllConfigs gets all of the userconfig.
181func (d DB) GetAllConfigs(ctx context.Context) (map[string]userconfig.View, error) {

Callers 1

SetRulesConfigMethod · 0.95

Implementers 4

timedpkg/configs/db/timed.go
tracedpkg/configs/db/traced.go
DBpkg/configs/db/postgres/postgres.go
DBpkg/configs/db/memory/memory.go

Calls 4

IsValidMethod · 0.80
InsertMethod · 0.80
ExecMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected