Skip to content

Commit

Permalink
Merge pull request #281 from leanix/bugfix/HEL-2718_event_per_workload
Browse files Browse the repository at this point in the history
HEL-2718 Updated id creating to include workloadType
  • Loading branch information
DennisBerthold-leanix authored May 23, 2023
2 parents 06db8dd + b1fba8a commit 10a162f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/iris/workloads/models/eventsEcst.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ func CreateEcstDiscoveryEvent(eventType string, changeAction string, data Data,

func GenerateId(workspaceId string, configId string, data Data) string {
scope := fmt.Sprintf(models.EventScopeFormat, workspaceId, configId)
// workspace/{workspaceId}/configuration/{configurationId}/discoveryItem/service/kubernetes/workload/{clusterName}/{workloadName}
idString := fmt.Sprintf("%s/%s/%s/%s", scope, models.EventClassWorkload, data.Workload.ClusterName, data.Workload.WorkloadName)
// workspace/{workspaceId}/configuration/{configurationId}/discoveryItem/service/kubernetes/workload/{clusterName}/{workloadType}/{workloadName}
idString := fmt.Sprintf("%s/%s/%s/%s/%s", scope, models.EventClassWorkload, data.Workload.ClusterName, data.Workload.WorkloadType, data.Workload.WorkloadName)
sum := sha256.Sum256([]byte(idString))
id := hex.EncodeToString(sum[:])
return id
Expand Down
9 changes: 5 additions & 4 deletions pkg/iris/workloads/services/events/eventProducer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ func Test_eventProducer_filter_updated_changed(t *testing.T) {

func Test_eventProducer_createECSTEvents(t *testing.T) {
mockApi := mocks.NewIrisApi(t)
id1 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster1", "testWorkload1")))
id2 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster1", "testWorkload2")))
id3 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster2", "testWorkload1")))
id4 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster2", "testWorkload2")))
id1 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster1", "deployment", "testWorkload1")))
//workspace/testWorkspaceId/configuration/testConfigId/discoveryItem/service/kubernetes/workload/testCluster1/deployment/testWorkload2
id2 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster1", "deployment", "testWorkload2")))
id3 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster2", "deployment", "testWorkload1")))
id4 := sha256.Sum256([]byte(fmt.Sprintf("%s/%s/%s/%s/%s", "workspace/testWorkspaceId/configuration/testConfigId", models.EventClassWorkload, "testCluster2", "deployment", "testWorkload2")))
newData := []workload.Workload{
{
ClusterName: "testCluster1",
Expand Down

0 comments on commit 10a162f

Please sign in to comment.