From bdb98d508e2e1817edac44599755e422b0abca16 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Fri, 4 Mar 2022 11:44:41 -0500 Subject: [PATCH] fix(genapi): Sort slice in removeDups template function (#1889) The removeDups template function converts a slice into a map and back into a slice in order to leverage the map keys to remove duplicates. However, since the iteration order over a map is not specified it would be possible to get different orders for multiple runs of `make api`. While this would not have an impact on any functionality, it is causing sporadic failures for the new make-gen-deltas CI job. See: https://go.dev/ref/spec#For_statements Ref: d57603022a317c99ac4feb0bcb78727e08f9dcfb --- internal/api/genapi/templates.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/api/genapi/templates.go b/internal/api/genapi/templates.go index a15aa2601f..57afc13b8d 100644 --- a/internal/api/genapi/templates.go +++ b/internal/api/genapi/templates.go @@ -816,5 +816,8 @@ func removeDups(in []string) []string { for val := range vals { ret = append(ret, val) } + + sort.Strings(ret) + return ret }