Skip to content

Commit 0ad46fd

Browse files
authored
Deterministic result order in GetImmutableFieldPaths (#405)
This patch addresses the issue of non-deterministic result order in the `GetImmutableFieldPath` function. In Go, maps and hashmaps access their elements randomly, which resulted in non-deterministic return arrays from `GetImmutableFieldPaths`. This patch leverages `sort.Strings` to ensure deterministic result order, ensuring deterministic behaviour in generated code. Signed-off-by: Amine Hilaly <[email protected]> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent d13b586 commit 0ad46fd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pkg/model/crd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ func (r *CRD) GetImmutableFieldPaths() []string {
346346
}
347347
}
348348

349+
// We need a deterministic order to traverse the immutable fields
350+
sort.Strings(immutableFields)
349351
return immutableFields
350352
}
351353

0 commit comments

Comments
 (0)