Skip to content

Commit

Permalink
add remove duplicates function
Browse files Browse the repository at this point in the history
  • Loading branch information
ermirizio committed Jun 25, 2024
1 parent c3aa303 commit 70144b4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions policy/variations.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,23 @@ func createVariationKey(branch, trigger, testsuite string) string {
return fmt.Sprintf("%s-%s-%s", branch, trigger, testsuite)
}

func removeDuplicates(s []string) []string {
bucket := make(map[string]bool)
var result []string
for _, str := range s {
if _, ok := bucket[str]; !ok {
bucket[str] = true
result = append(result, str)
}
}
return result
}

func parseVariations(sv ghMatrix, depth int, rv *repoVariations, path variationPath) {
for level, levelMatrix := range sv.Level {
levelMatrix.EnvFiles = append(levelMatrix.EnvFiles, sv.EnvFiles...)
levelMatrix.Pump = append(levelMatrix.Pump, sv.Pump...)
levelMatrix.Sink = append(levelMatrix.Sink, sv.Sink...)
levelMatrix.Pump = removeDuplicates(append(levelMatrix.Pump, sv.Pump...))
levelMatrix.Sink = removeDuplicates(append(levelMatrix.Sink, sv.Sink...))
switch depth {
case Branch:
path.Branch = level
Expand Down

0 comments on commit 70144b4

Please sign in to comment.