GetRulesConfig gets the latest alertmanager config for a user.
(ctx context.Context, userID string)
| 192 | |
| 193 | // GetRulesConfig gets the latest alertmanager config for a user. |
| 194 | func (d DB) GetRulesConfig(ctx context.Context, userID string) (userconfig.VersionedRulesConfig, error) { |
| 195 | current, err := d.GetConfig(ctx, userID) |
| 196 | if err != nil { |
| 197 | return userconfig.VersionedRulesConfig{}, err |
| 198 | } |
| 199 | cfg := current.GetVersionedRulesConfig() |
| 200 | if cfg == nil { |
| 201 | return userconfig.VersionedRulesConfig{}, sql.ErrNoRows |
| 202 | } |
| 203 | return *cfg, nil |
| 204 | } |
| 205 | |
| 206 | // SetRulesConfig sets the current alertmanager config for a user. |
| 207 | func (d DB) SetRulesConfig(ctx context.Context, userID string, oldConfig, newConfig userconfig.RulesConfig) (bool, error) { |