diff --git a/go.sum b/go.sum index 3c7ed2897e6..7ad2f5bdecb 100644 --- a/go.sum +++ b/go.sum @@ -1394,8 +1394,6 @@ github.com/grafana/saml v0.4.13-0.20230331080031-67cbfa09c7b6 h1:oHn/OOUkECNX06D github.com/grafana/saml v0.4.13-0.20230331080031-67cbfa09c7b6/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= github.com/grafana/sqlds/v2 v2.3.10 h1:HWKhE0vR6LoEiE+Is8CSZOgaB//D1yqb2ntkass9Fd4= github.com/grafana/sqlds/v2 v2.3.10/go.mod h1:c6ibxnxRVGxV/0YkEgvy7QpQH/lyifFyV7K/14xvdIs= -github.com/grafana/thema v0.0.0-20230601172625-e3eaca4d36bd h1:gK5LMNi8AUp8xcrOSNfbvE5g3dT46Qgy+/pCon1Z9jc= -github.com/grafana/thema v0.0.0-20230601172625-e3eaca4d36bd/go.mod h1:KWAKeFXxQYiJ/kBVbijBLRVq9atxkfkeeFIvmj4clEA= github.com/grafana/thema v0.0.0-20230615161902-b6e21996aef8 h1:ESVwKjvGWVucGY65rJq0Hny3a6p8UYqEbClqXhP2qJk= github.com/grafana/thema v0.0.0-20230615161902-b6e21996aef8/go.mod h1:KWAKeFXxQYiJ/kBVbijBLRVq9atxkfkeeFIvmj4clEA= github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6 h1:I9dh1MXGX0wGyxdV/Sl7+ugnki4Dfsy8lv2s5Yf887o= diff --git a/pkg/services/ngalert/state/compat.go b/pkg/services/ngalert/state/compat.go index fbe934bc344..e660b3b232c 100644 --- a/pkg/services/ngalert/state/compat.go +++ b/pkg/services/ngalert/state/compat.go @@ -48,11 +48,8 @@ func StateToPostableAlert(alertState *State, appURL *url.URL) *models.PostableAl nA[alertingModels.ValueStringAnnotation] = alertState.LastEvaluationString } - if alertState.Image != nil { - imageURI := generateImageURI(alertState.Image) - if imageURI != "" { - nA[alertingModels.ImageTokenAnnotation] = imageURI - } + if alertState.Image != nil && alertState.Image.Token != "" { + nA[alertingModels.ImageTokenAnnotation] = alertState.Image.Token } if alertState.StateReason != "" { @@ -169,17 +166,3 @@ func FromAlertsStateToStoppedAlert(firingStates []StateTransition, appURL *url.U } return alerts } - -// generateImageURI returns a string that serves as an identifier for the image. -// It first checks if there is an image URL available, and if not, -// it prefixes the image token with `token://` and uses it as the URI. -func generateImageURI(image *ngModels.Image) string { - if image.URL != "" { - return image.URL - } - if image.Token != "" { - return "token://" + image.Token - } - - return "" -} diff --git a/pkg/services/ngalert/state/compat_test.go b/pkg/services/ngalert/state/compat_test.go index f98f32ff7a1..21de47f026a 100644 --- a/pkg/services/ngalert/state/compat_test.go +++ b/pkg/services/ngalert/state/compat_test.go @@ -129,7 +129,7 @@ func Test_StateToPostableAlert(t *testing.T) { for k, v := range alertState.Annotations { expected[k] = v } - expected["__alertImageToken__"] = "token://" + alertState.Image.Token + expected["__alertImageToken__"] = alertState.Image.Token require.Equal(t, expected, result.Annotations) })