feat(go): persist Python-compatible incidents
This commit is contained in:
parent
f85c2e831a
commit
538d1d954a
13 changed files with 555 additions and 46 deletions
|
|
@ -61,6 +61,9 @@ type Config struct {
|
|||
HeartbeatMaxAge int
|
||||
MaxSnapshots int
|
||||
MaxSnapshotAgeDays int
|
||||
IncidentTracking bool
|
||||
IncidentWindow int
|
||||
IncidentLineageDepth int
|
||||
Detectors map[string]bool
|
||||
InputSnooperAllowComms map[string]bool
|
||||
CredentialAccessAllowComms map[string]bool
|
||||
|
|
@ -97,6 +100,9 @@ func Default() Config {
|
|||
HeartbeatMaxAge: 120,
|
||||
MaxSnapshots: 300,
|
||||
MaxSnapshotAgeDays: 60,
|
||||
IncidentTracking: true,
|
||||
IncidentWindow: 1800,
|
||||
IncidentLineageDepth: 8,
|
||||
Detectors: detectors,
|
||||
InputSnooperAllowComms: stringSet(defaultInputSnooperAllowComms),
|
||||
CredentialAccessAllowComms: stringSet(defaultCredentialAccessAllowComms),
|
||||
|
|
@ -204,6 +210,24 @@ func Load(path string) (Config, error) {
|
|||
return Config{}, fmt.Errorf("max_snapshot_age_days must be non-negative: %q", value)
|
||||
}
|
||||
cfg.MaxSnapshotAgeDays = days
|
||||
case "incident_tracking":
|
||||
enabled, err := boolean(value)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("incident_tracking: %w", err)
|
||||
}
|
||||
cfg.IncidentTracking = enabled
|
||||
case "incident_window":
|
||||
window, err := nonNegativeInt(value)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("incident_window: %w", err)
|
||||
}
|
||||
cfg.IncidentWindow = window
|
||||
case "incident_lineage_depth":
|
||||
depth, err := nonNegativeInt(value)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("incident_lineage_depth: %w", err)
|
||||
}
|
||||
cfg.IncidentLineageDepth = depth
|
||||
case "detectors":
|
||||
names, err := stringArray(value)
|
||||
if err != nil {
|
||||
|
|
@ -351,6 +375,14 @@ func nonNegativeSeconds(value string) (time.Duration, error) {
|
|||
return time.Duration(seconds * float64(time.Second)), nil
|
||||
}
|
||||
|
||||
func nonNegativeInt(value string) (int, error) {
|
||||
parsed, err := strconv.Atoi(value)
|
||||
if err != nil || parsed < 0 {
|
||||
return 0, fmt.Errorf("must be non-negative: %q", value)
|
||||
}
|
||||
return parsed, nil
|
||||
}
|
||||
|
||||
func boolean(value string) (bool, error) {
|
||||
switch value {
|
||||
case "true":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue