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

Method GetConfig

pkg/configs/db/postgres/postgres.go:145–161  ·  view source on GitHub ↗

GetConfig gets a configuration.

(ctx context.Context, userID string)

Source from the content-addressed store, hash-verified

143
144// GetConfig gets a configuration.
145func (d DB) GetConfig(ctx context.Context, userID string) (userconfig.View, error) {
146 var cfgView userconfig.View
147 var cfgBytes []byte
148 var deletedAt sql.NullTime
149 err := d.Select("id", "config", "deleted_at").
150 From("configs").
151 Where(squirrel.And{allConfigs, squirrel.Eq{"owner_id": userID}}).
152 OrderBy("id DESC").
153 Limit(1).
154 QueryRow().Scan(&cfgView.ID, &cfgBytes, &deletedAt)
155 if err != nil {
156 return cfgView, err
157 }
158 cfgView.DeletedAt = deletedAt.Time
159 err = json.Unmarshal(cfgBytes, &cfgView.Config)
160 return cfgView, err
161}
162
163// SetConfig sets a configuration.
164func (d DB) SetConfig(ctx context.Context, userID string, cfg userconfig.Config) error {

Callers 4

GetRulesConfigMethod · 0.95
SetRulesConfigMethod · 0.95
DeactivateConfigMethod · 0.95
RestoreConfigMethod · 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 5

QueryRowMethod · 0.80
ScanMethod · 0.65
LimitMethod · 0.65
SelectMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected