From 3af43c0010ca9b68a95e912cd8c04f0e0c7583c6 Mon Sep 17 00:00:00 2001 From: Joerg Poecher Date: Mon, 27 Jun 2022 16:12:19 +0200 Subject: [PATCH 1/4] add custom properties struct and use it in event handlers Signed-off-by: Joerg Poecher --- .../action/action_finished_event_handler.go | 2 +- .../action/action_triggered_event_handler.go | 2 +- internal/action/common.go | 30 ++++++++++++++----- .../deployment_finished_event_handler.go | 2 +- .../evaluation_finished_event_handler.go | 8 ++++- .../action/release_triggered_event_handler.go | 2 +- .../action/test_finished_event_handler.go | 2 +- .../action/test_triggered_event_handler.go | 2 +- internal/keptn/common.go | 24 ++++++++++++--- 9 files changed, 56 insertions(+), 18 deletions(-) diff --git a/internal/action/action_finished_event_handler.go b/internal/action/action_finished_event_handler.go index d34635716..18b8b9b20 100644 --- a/internal/action/action_finished_event_handler.go +++ b/internal/action/action_finished_event_handler.go @@ -52,7 +52,7 @@ func (eh *ActionFinishedEventHandler) HandleEvent(workCtx context.Context, _ con // https://github.com/keptn-contrib/dynatrace-service/issues/174 // Additionally to the problem comment, send Info or Configuration Change Event to the entities in Dynatrace to indicate that remediation actions have been executed - customProperties := createCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL) + customProperties := NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL) if eh.event.GetStatus() == keptnv2.StatusSucceeded { configurationEvent := dynatrace.ConfigurationEvent{ EventType: dynatrace.ConfigurationEventType, diff --git a/internal/action/action_triggered_event_handler.go b/internal/action/action_triggered_event_handler.go index 2bd6aa322..378d7f92d 100644 --- a/internal/action/action_triggered_event_handler.go +++ b/internal/action/action_triggered_event_handler.go @@ -61,7 +61,7 @@ func (eh *ActionTriggeredEventHandler) HandleEvent(workCtx context.Context, _ co Source: eventSource, Title: "Keptn Remediation Action Triggered", Description: eh.event.GetAction(), - CustomProperties: createCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL), + CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL), AttachRules: *eh.attachRules, } diff --git a/internal/action/common.go b/internal/action/common.go index e4b72b4f8..2717369d4 100644 --- a/internal/action/common.go +++ b/internal/action/common.go @@ -15,8 +15,10 @@ const bridgeURLKey = "Keptns Bridge" const contextless = "CONTEXTLESS" -func createCustomProperties(a adapter.EventContentAdapter, imageAndTag common.ImageAndTag, bridgeURL string) map[string]string { - customProperties := map[string]string{ +type CustomProperties map[string]string + +func NewCustomProperties(a adapter.EventContentAdapter, imageAndTag common.ImageAndTag, bridgeURL string) CustomProperties { + cp := CustomProperties{ "Project": a.GetProject(), "Stage": a.GetStage(), "Service": a.GetService(), @@ -27,16 +29,30 @@ func createCustomProperties(a adapter.EventContentAdapter, imageAndTag common.Im "Keptn Service": a.GetSource(), } - // now add the rest of the labels into custom properties (changed with #115_116) for key, value := range a.GetLabels() { - customProperties[key] = value + cp.add(key, value) + } + + cp.addIfNonEmpty(bridgeURLKey, bridgeURL) + + return cp +} + +func (cp CustomProperties) add(key string, value string) { + oldValue, isContained := cp[key] + if isContained { + log.Warnf("Overwriting current value '%s' of key '%s' with new value '%s in custom properties", oldValue, key, value) } - if bridgeURL != "" { - customProperties[bridgeURLKey] = bridgeURL + cp[key] = value +} + +func (cp CustomProperties) addIfNonEmpty(key string, value string) { + if key == "" || value == "" { + return } - return customProperties + cp.add(key, value) } func getValueFromLabels(a adapter.EventContentAdapter, key string, defaultValue string) string { diff --git a/internal/action/deployment_finished_event_handler.go b/internal/action/deployment_finished_event_handler.go index c19d7fa8b..f0918fbb2 100644 --- a/internal/action/deployment_finished_event_handler.go +++ b/internal/action/deployment_finished_event_handler.go @@ -41,7 +41,7 @@ func (eh *DeploymentFinishedEventHandler) HandleEvent(workCtx context.Context, _ DeploymentVersion: getValueFromLabels(eh.event, "deploymentVersion", imageAndTag.Tag()), CiBackLink: getValueFromLabels(eh.event, "ciBackLink", ""), RemediationAction: getValueFromLabels(eh.event, "remediationAction", ""), - CustomProperties: createCustomProperties(eh.event, imageAndTag, keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: NewCustomProperties(eh.event, imageAndTag, keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/action/evaluation_finished_event_handler.go b/internal/action/evaluation_finished_event_handler.go index 5b6300e7a..13ed836b2 100644 --- a/internal/action/evaluation_finished_event_handler.go +++ b/internal/action/evaluation_finished_event_handler.go @@ -12,6 +12,8 @@ import ( "github.com/keptn-contrib/dynatrace-service/internal/keptn" ) +const evaluationURLKey = "evaluationHeatmapURL" + // EvaluationFinishedEventHandler handles an evaluation finished event. type EvaluationFinishedEventHandler struct { event EvaluationFinishedAdapterInterface @@ -54,12 +56,16 @@ func (eh *EvaluationFinishedEventHandler) HandleEvent(workCtx context.Context, _ return fmt.Errorf("could not setup correct attach rules: %w", err) } + evaluationURL := keptn.TryGetBridgeURLForEvaluation(workCtx, eh.event) + customProperties := NewCustomProperties(eh.event, imageAndTag, bridgeURL) + customProperties.addIfNonEmpty(evaluationURLKey, evaluationURL) + infoEvent := dynatrace.InfoEvent{ EventType: dynatrace.InfoEventType, Source: eventSource, Title: eh.getTitle(isPartOfRemediation), Description: fmt.Sprintf("Quality Gate Result in stage %s: %s (%.2f/100)", eh.event.GetStage(), eh.event.GetResult(), eh.event.GetEvaluationScore()), - CustomProperties: createCustomProperties(eh.event, imageAndTag, bridgeURL), + CustomProperties: customProperties, AttachRules: attachRules, } diff --git a/internal/action/release_triggered_event_handler.go b/internal/action/release_triggered_event_handler.go index 293b27320..87f9b7588 100644 --- a/internal/action/release_triggered_event_handler.go +++ b/internal/action/release_triggered_event_handler.go @@ -46,7 +46,7 @@ func (eh *ReleaseTriggeredEventHandler) HandleEvent(workCtx context.Context, _ c Source: eventSource, Title: eh.getTitle(strategy, eh.event.GetLabels()["title"]), Description: eh.getTitle(strategy, eh.event.GetLabels()["description"]), - CustomProperties: createCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/action/test_finished_event_handler.go b/internal/action/test_finished_event_handler.go index c00e6d108..4180c1ac0 100644 --- a/internal/action/test_finished_event_handler.go +++ b/internal/action/test_finished_event_handler.go @@ -35,7 +35,7 @@ func (eh *TestFinishedEventHandler) HandleEvent(workCtx context.Context, _ conte Source: eventSource, AnnotationType: getValueFromLabels(eh.event, "type", "Stop Tests"), AnnotationDescription: getValueFromLabels(eh.event, "description", "Stop running tests: against "+eh.event.GetService()), - CustomProperties: createCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/action/test_triggered_event_handler.go b/internal/action/test_triggered_event_handler.go index 6118b9570..e2700ff00 100644 --- a/internal/action/test_triggered_event_handler.go +++ b/internal/action/test_triggered_event_handler.go @@ -36,7 +36,7 @@ func (eh *TestTriggeredEventHandler) HandleEvent(workCtx context.Context, _ cont Source: eventSource, AnnotationType: getValueFromLabels(eh.event, "type", "Start Tests: "+eh.event.GetTestStrategy()), AnnotationDescription: getValueFromLabels(eh.event, "description", "Start running tests: "+eh.event.GetTestStrategy()+" against "+eh.event.GetService()), - CustomProperties: createCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/keptn/common.go b/internal/keptn/common.go index a6b3dfe42..61cf58740 100644 --- a/internal/keptn/common.go +++ b/internal/keptn/common.go @@ -2,6 +2,7 @@ package keptn import ( "context" + "fmt" "github.com/keptn-contrib/dynatrace-service/internal/adapter" "github.com/keptn-contrib/dynatrace-service/internal/credentials" @@ -11,19 +12,34 @@ import ( v2 "github.com/keptn/go-utils/pkg/api/utils/v2" ) -// TryGetBridgeURLForKeptnContext gets a backlink to the Keptn Bridge if available or returns "". +// TryGetBridgeURLForKeptnContext gets a backlink to the Keptn Bridge if available or returns empty string. func TryGetBridgeURLForKeptnContext(ctx context.Context, event adapter.EventContentAdapter) string { - credentials, err := credentials.GetKeptnCredentials(ctx) + keptnBridgeURL := tryGetBridgeURL(ctx) + if keptnBridgeURL == "" { + return "" + } + + return keptnBridgeURL + "/trace/" + event.GetShKeptnContext() +} + +// tryGetBridgeURL gets the Keptn Bridge URL if available or returns empty string. +func tryGetBridgeURL(ctx context.Context) string { + creds, err := credentials.GetKeptnCredentials(ctx) if err != nil { return "" } - keptnBridgeURL := credentials.GetBridgeURL() + return creds.GetBridgeURL() +} + +// TryGetBridgeURLForEvaluation gets a backlink to the evaluation in Keptn Bridge if available or returns empty string. +func TryGetBridgeURLForEvaluation(ctx context.Context, event adapter.EventContentAdapter) string { + keptnBridgeURL := tryGetBridgeURL(ctx) if keptnBridgeURL == "" { return "" } - return keptnBridgeURL + "/trace/" + event.GetShKeptnContext() + return fmt.Sprintf("%s/evaluation/%s/%s", keptnBridgeURL, event.GetShKeptnContext(), event.GetStage()) } // GetV1InClusterAPIMappings returns the InClusterAPIMappings. From 773dedcd19506220cede6b0e5a035d6e09e5f882 Mon Sep 17 00:00:00 2001 From: Joerg Poecher Date: Wed, 29 Jun 2022 13:29:17 +0200 Subject: [PATCH 2/4] adds test for custom properties Signed-off-by: Joerg Poecher --- internal/action/common_test.go | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 internal/action/common_test.go diff --git a/internal/action/common_test.go b/internal/action/common_test.go new file mode 100644 index 000000000..ec6a413d4 --- /dev/null +++ b/internal/action/common_test.go @@ -0,0 +1,92 @@ +package action + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCustomProperties_Add(t *testing.T) { + testConfigs := []struct { + name string + key string + value string + expected CustomProperties + }{ + { + name: "both empty", + key: "", + value: "", + expected: CustomProperties{"": ""}, + }, + { + name: "key empty", + key: "", + value: "value", + expected: CustomProperties{"": "value"}, + }, + { + name: "value empty", + key: "key", + value: "", + expected: CustomProperties{"key": ""}, + }, + { + name: "value empty", + key: "key", + value: "value", + expected: CustomProperties{"key": "value"}, + }, + } + for _, testCfg := range testConfigs { + t.Run(testCfg.name, func(t *testing.T) { + cp := CustomProperties{} + cp.add(testCfg.key, testCfg.value) + + assert.Equal(t, testCfg.expected, cp) + }) + } +} + +func TestCustomProperties_AddIfNonEmpty(t *testing.T) { + + testConfigs := []struct { + name string + key string + value string + expected CustomProperties + }{ + { + name: "both empty", + key: "", + value: "", + expected: CustomProperties{}, + }, + { + name: "key empty", + key: "", + value: "value", + expected: CustomProperties{}, + }, + { + name: "value empty", + key: "key", + value: "", + expected: CustomProperties{}, + }, + { + name: "value empty", + key: "key", + value: "value", + expected: CustomProperties{"key": "value"}, + }, + } + for _, testCfg := range testConfigs { + t.Run(testCfg.name, func(t *testing.T) { + cp := CustomProperties{} + cp.addIfNonEmpty(testCfg.key, testCfg.value) + + assert.Equal(t, testCfg.expected, cp) + }) + } +} From 75cc1883afc3ae22e66df54991ceaaef3826191a Mon Sep 17 00:00:00 2001 From: Joerg Poecher Date: Thu, 30 Jun 2022 08:11:34 +0200 Subject: [PATCH 3/4] unexports custom properties Signed-off-by: Joerg Poecher --- .../action/action_finished_event_handler.go | 2 +- .../action/action_triggered_event_handler.go | 2 +- internal/action/common.go | 10 ++++---- internal/action/common_test.go | 24 +++++++++---------- .../deployment_finished_event_handler.go | 2 +- .../evaluation_finished_event_handler.go | 2 +- .../action/release_triggered_event_handler.go | 2 +- .../action/test_finished_event_handler.go | 2 +- .../action/test_triggered_event_handler.go | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/action/action_finished_event_handler.go b/internal/action/action_finished_event_handler.go index 18b8b9b20..0eba2db9d 100644 --- a/internal/action/action_finished_event_handler.go +++ b/internal/action/action_finished_event_handler.go @@ -52,7 +52,7 @@ func (eh *ActionFinishedEventHandler) HandleEvent(workCtx context.Context, _ con // https://github.com/keptn-contrib/dynatrace-service/issues/174 // Additionally to the problem comment, send Info or Configuration Change Event to the entities in Dynatrace to indicate that remediation actions have been executed - customProperties := NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL) + customProperties := newCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL) if eh.event.GetStatus() == keptnv2.StatusSucceeded { configurationEvent := dynatrace.ConfigurationEvent{ EventType: dynatrace.ConfigurationEventType, diff --git a/internal/action/action_triggered_event_handler.go b/internal/action/action_triggered_event_handler.go index 378d7f92d..2d4c88817 100644 --- a/internal/action/action_triggered_event_handler.go +++ b/internal/action/action_triggered_event_handler.go @@ -61,7 +61,7 @@ func (eh *ActionTriggeredEventHandler) HandleEvent(workCtx context.Context, _ co Source: eventSource, Title: "Keptn Remediation Action Triggered", Description: eh.event.GetAction(), - CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL), + CustomProperties: newCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), bridgeURL), AttachRules: *eh.attachRules, } diff --git a/internal/action/common.go b/internal/action/common.go index 2717369d4..228b4561c 100644 --- a/internal/action/common.go +++ b/internal/action/common.go @@ -15,10 +15,10 @@ const bridgeURLKey = "Keptns Bridge" const contextless = "CONTEXTLESS" -type CustomProperties map[string]string +type customProperties map[string]string -func NewCustomProperties(a adapter.EventContentAdapter, imageAndTag common.ImageAndTag, bridgeURL string) CustomProperties { - cp := CustomProperties{ +func newCustomProperties(a adapter.EventContentAdapter, imageAndTag common.ImageAndTag, bridgeURL string) customProperties { + cp := customProperties{ "Project": a.GetProject(), "Stage": a.GetStage(), "Service": a.GetService(), @@ -38,7 +38,7 @@ func NewCustomProperties(a adapter.EventContentAdapter, imageAndTag common.Image return cp } -func (cp CustomProperties) add(key string, value string) { +func (cp customProperties) add(key string, value string) { oldValue, isContained := cp[key] if isContained { log.Warnf("Overwriting current value '%s' of key '%s' with new value '%s in custom properties", oldValue, key, value) @@ -47,7 +47,7 @@ func (cp CustomProperties) add(key string, value string) { cp[key] = value } -func (cp CustomProperties) addIfNonEmpty(key string, value string) { +func (cp customProperties) addIfNonEmpty(key string, value string) { if key == "" || value == "" { return } diff --git a/internal/action/common_test.go b/internal/action/common_test.go index ec6a413d4..3076a0130 100644 --- a/internal/action/common_test.go +++ b/internal/action/common_test.go @@ -11,36 +11,36 @@ func TestCustomProperties_Add(t *testing.T) { name string key string value string - expected CustomProperties + expected customProperties }{ { name: "both empty", key: "", value: "", - expected: CustomProperties{"": ""}, + expected: customProperties{"": ""}, }, { name: "key empty", key: "", value: "value", - expected: CustomProperties{"": "value"}, + expected: customProperties{"": "value"}, }, { name: "value empty", key: "key", value: "", - expected: CustomProperties{"key": ""}, + expected: customProperties{"key": ""}, }, { name: "value empty", key: "key", value: "value", - expected: CustomProperties{"key": "value"}, + expected: customProperties{"key": "value"}, }, } for _, testCfg := range testConfigs { t.Run(testCfg.name, func(t *testing.T) { - cp := CustomProperties{} + cp := customProperties{} cp.add(testCfg.key, testCfg.value) assert.Equal(t, testCfg.expected, cp) @@ -54,36 +54,36 @@ func TestCustomProperties_AddIfNonEmpty(t *testing.T) { name string key string value string - expected CustomProperties + expected customProperties }{ { name: "both empty", key: "", value: "", - expected: CustomProperties{}, + expected: customProperties{}, }, { name: "key empty", key: "", value: "value", - expected: CustomProperties{}, + expected: customProperties{}, }, { name: "value empty", key: "key", value: "", - expected: CustomProperties{}, + expected: customProperties{}, }, { name: "value empty", key: "key", value: "value", - expected: CustomProperties{"key": "value"}, + expected: customProperties{"key": "value"}, }, } for _, testCfg := range testConfigs { t.Run(testCfg.name, func(t *testing.T) { - cp := CustomProperties{} + cp := customProperties{} cp.addIfNonEmpty(testCfg.key, testCfg.value) assert.Equal(t, testCfg.expected, cp) diff --git a/internal/action/deployment_finished_event_handler.go b/internal/action/deployment_finished_event_handler.go index f0918fbb2..b392ffb41 100644 --- a/internal/action/deployment_finished_event_handler.go +++ b/internal/action/deployment_finished_event_handler.go @@ -41,7 +41,7 @@ func (eh *DeploymentFinishedEventHandler) HandleEvent(workCtx context.Context, _ DeploymentVersion: getValueFromLabels(eh.event, "deploymentVersion", imageAndTag.Tag()), CiBackLink: getValueFromLabels(eh.event, "ciBackLink", ""), RemediationAction: getValueFromLabels(eh.event, "remediationAction", ""), - CustomProperties: NewCustomProperties(eh.event, imageAndTag, keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: newCustomProperties(eh.event, imageAndTag, keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/action/evaluation_finished_event_handler.go b/internal/action/evaluation_finished_event_handler.go index 13ed836b2..b59fe41f5 100644 --- a/internal/action/evaluation_finished_event_handler.go +++ b/internal/action/evaluation_finished_event_handler.go @@ -57,7 +57,7 @@ func (eh *EvaluationFinishedEventHandler) HandleEvent(workCtx context.Context, _ } evaluationURL := keptn.TryGetBridgeURLForEvaluation(workCtx, eh.event) - customProperties := NewCustomProperties(eh.event, imageAndTag, bridgeURL) + customProperties := newCustomProperties(eh.event, imageAndTag, bridgeURL) customProperties.addIfNonEmpty(evaluationURLKey, evaluationURL) infoEvent := dynatrace.InfoEvent{ diff --git a/internal/action/release_triggered_event_handler.go b/internal/action/release_triggered_event_handler.go index 87f9b7588..9d2d171a4 100644 --- a/internal/action/release_triggered_event_handler.go +++ b/internal/action/release_triggered_event_handler.go @@ -46,7 +46,7 @@ func (eh *ReleaseTriggeredEventHandler) HandleEvent(workCtx context.Context, _ c Source: eventSource, Title: eh.getTitle(strategy, eh.event.GetLabels()["title"]), Description: eh.getTitle(strategy, eh.event.GetLabels()["description"]), - CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: newCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/action/test_finished_event_handler.go b/internal/action/test_finished_event_handler.go index 4180c1ac0..3d9ba011b 100644 --- a/internal/action/test_finished_event_handler.go +++ b/internal/action/test_finished_event_handler.go @@ -35,7 +35,7 @@ func (eh *TestFinishedEventHandler) HandleEvent(workCtx context.Context, _ conte Source: eventSource, AnnotationType: getValueFromLabels(eh.event, "type", "Stop Tests"), AnnotationDescription: getValueFromLabels(eh.event, "description", "Stop running tests: against "+eh.event.GetService()), - CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: newCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } diff --git a/internal/action/test_triggered_event_handler.go b/internal/action/test_triggered_event_handler.go index e2700ff00..a31f5b6cf 100644 --- a/internal/action/test_triggered_event_handler.go +++ b/internal/action/test_triggered_event_handler.go @@ -36,7 +36,7 @@ func (eh *TestTriggeredEventHandler) HandleEvent(workCtx context.Context, _ cont Source: eventSource, AnnotationType: getValueFromLabels(eh.event, "type", "Start Tests: "+eh.event.GetTestStrategy()), AnnotationDescription: getValueFromLabels(eh.event, "description", "Start running tests: "+eh.event.GetTestStrategy()+" against "+eh.event.GetService()), - CustomProperties: NewCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), + CustomProperties: newCustomProperties(eh.event, eh.eClient.GetImageAndTag(workCtx, eh.event), keptn.TryGetBridgeURLForKeptnContext(workCtx, eh.event)), AttachRules: *eh.attachRules, } From a94fe77dd655c468c03e5a61064d063bd1744941 Mon Sep 17 00:00:00 2001 From: Joerg Poecher Date: Thu, 30 Jun 2022 08:12:00 +0200 Subject: [PATCH 4/4] inlines variable Signed-off-by: Joerg Poecher --- internal/action/evaluation_finished_event_handler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/action/evaluation_finished_event_handler.go b/internal/action/evaluation_finished_event_handler.go index b59fe41f5..51c7fc4b2 100644 --- a/internal/action/evaluation_finished_event_handler.go +++ b/internal/action/evaluation_finished_event_handler.go @@ -56,9 +56,8 @@ func (eh *EvaluationFinishedEventHandler) HandleEvent(workCtx context.Context, _ return fmt.Errorf("could not setup correct attach rules: %w", err) } - evaluationURL := keptn.TryGetBridgeURLForEvaluation(workCtx, eh.event) customProperties := newCustomProperties(eh.event, imageAndTag, bridgeURL) - customProperties.addIfNonEmpty(evaluationURLKey, evaluationURL) + customProperties.addIfNonEmpty(evaluationURLKey, keptn.TryGetBridgeURLForEvaluation(workCtx, eh.event)) infoEvent := dynatrace.InfoEvent{ EventType: dynatrace.InfoEventType,