From 53f4260a3dce8b0fe8ba1e290c2aeec2d3483882 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Mon, 10 Jun 2024 11:49:28 +0545 Subject: [PATCH] feat: change severity --- db/update.go | 5 +++++ go.mod | 2 +- go.sum | 4 ++-- hack/generate-schemas/go.mod | 2 +- hack/generate-schemas/go.sum | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/db/update.go b/db/update.go index fba99621..39a2140c 100644 --- a/db/update.go +++ b/db/update.go @@ -21,6 +21,7 @@ import ( dutyContext "github.com/flanksource/duty/context" dutyModels "github.com/flanksource/duty/models" "github.com/flanksource/gomplate/v3" + "github.com/flanksource/is-healthy/events" "github.com/google/uuid" "github.com/hexops/gotextdiff" "github.com/hexops/gotextdiff/myers" @@ -256,6 +257,10 @@ func extractChanges(ctx api.ScrapeContext, result *v1.ScrapeResult, ci *models.C } } + if change.Severity == "" && change.ChangeType != "diff" { + change.Severity = events.GetSeverity(change.ChangeType) + } + if change.ConfigID == "" { // Some scrapers can generate changes for config items that don't exist on our db. // Example: Cloudtrail scraper reporting changes for a resource that has been excluded. diff --git a/go.mod b/go.mod index ebe1ab06..9dd570be 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/fergusstrange/embedded-postgres v1.25.0 github.com/flanksource/commons v1.22.1 github.com/flanksource/duty v1.0.486 - github.com/flanksource/is-healthy v1.0.7 + github.com/flanksource/is-healthy v1.0.10 github.com/flanksource/ketall v1.1.6 github.com/flanksource/mapstructure v1.6.0 github.com/go-logr/zapr v1.2.4 diff --git a/go.sum b/go.sum index 0d717007..c6308078 100644 --- a/go.sum +++ b/go.sum @@ -860,8 +860,8 @@ github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9 github.com/flanksource/gomplate/v3 v3.24.2 h1:WZSriw1MaBhzrDV1IOP9eNsupIPxIHy0yTaMOVhCvsk= github.com/flanksource/gomplate/v3 v3.24.2/go.mod h1:94BxYobZqouGdVezuz6LNto5C+yLMG0LnNnM9CUPyoo= github.com/flanksource/is-healthy v0.0.0-20230705092916-3b4cf510c5fc/go.mod h1:4pQhmF+TnVqJroQKY8wSnSp+T18oLson6YQ2M0qPHfQ= -github.com/flanksource/is-healthy v1.0.7 h1:0muDQttzTkNLcOpsA23OHvLiweN44anxUgvQhucbh5E= -github.com/flanksource/is-healthy v1.0.7/go.mod h1:ijdyDDpdRzDtIt1UVZv5WNpAnb8V4hGUz75rnr3Ubhk= +github.com/flanksource/is-healthy v1.0.10 h1:g7cyLTK/a5PqTJmRG35+4l7I6vzQqGAQAxpwrw0efkE= +github.com/flanksource/is-healthy v1.0.10/go.mod h1:ijdyDDpdRzDtIt1UVZv5WNpAnb8V4hGUz75rnr3Ubhk= github.com/flanksource/ketall v1.1.6 h1:gGZsbDUf4ULznNMEC076cyrhGAZbaRnZXuhZ42PTyaE= github.com/flanksource/ketall v1.1.6/go.mod h1:s76Y3Anqptx5CdP4Jtav3LWjAu297ME8YXEsAiw/NcE= github.com/flanksource/kommons v0.31.4 h1:zksAgYjZuwPgS8XTejDIWEYB0nPSU1i3Jxcavm/vovI= diff --git a/hack/generate-schemas/go.mod b/hack/generate-schemas/go.mod index 43f21525..9f2432d9 100644 --- a/hack/generate-schemas/go.mod +++ b/hack/generate-schemas/go.mod @@ -25,7 +25,7 @@ require ( github.com/distribution/reference v0.5.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/flanksource/gomplate/v3 v3.24.2 // indirect - github.com/flanksource/is-healthy v1.0.7 // indirect + github.com/flanksource/is-healthy v1.0.10 // indirect github.com/flanksource/kubectl-neat v1.0.4 // indirect github.com/flanksource/mapstructure v1.6.0 // indirect github.com/flanksource/postq v0.1.3 // indirect diff --git a/hack/generate-schemas/go.sum b/hack/generate-schemas/go.sum index 51f68501..a4eef199 100644 --- a/hack/generate-schemas/go.sum +++ b/hack/generate-schemas/go.sum @@ -247,8 +247,8 @@ github.com/flanksource/duty v1.0.486 h1:6rwqihXF8/LoKRQqnJ/Awir7f2mGGsVIr8xZIMGe github.com/flanksource/duty v1.0.486/go.mod h1:5B7rHV8hsttX/Ku92XI2FoRY4xZaeAoUGl2ngB/wZV0= github.com/flanksource/gomplate/v3 v3.24.2 h1:WZSriw1MaBhzrDV1IOP9eNsupIPxIHy0yTaMOVhCvsk= github.com/flanksource/gomplate/v3 v3.24.2/go.mod h1:94BxYobZqouGdVezuz6LNto5C+yLMG0LnNnM9CUPyoo= -github.com/flanksource/is-healthy v1.0.7 h1:0muDQttzTkNLcOpsA23OHvLiweN44anxUgvQhucbh5E= -github.com/flanksource/is-healthy v1.0.7/go.mod h1:ijdyDDpdRzDtIt1UVZv5WNpAnb8V4hGUz75rnr3Ubhk= +github.com/flanksource/is-healthy v1.0.10 h1:g7cyLTK/a5PqTJmRG35+4l7I6vzQqGAQAxpwrw0efkE= +github.com/flanksource/is-healthy v1.0.10/go.mod h1:ijdyDDpdRzDtIt1UVZv5WNpAnb8V4hGUz75rnr3Ubhk= github.com/flanksource/kubectl-neat v1.0.4 h1:t5/9CqgE84oEtB0KitgJ2+WIeLfD+RhXSxYrqb4X8yI= github.com/flanksource/kubectl-neat v1.0.4/go.mod h1:Un/Voyh3cmiZNKQrW/TkAl28nAA7vwnwDGVjRErKjOw= github.com/flanksource/mapstructure v1.6.0 h1:+1kJ+QsO1SxjAgktfLlpZXetsVSJ0uCLhGKrA4BtwTE=