Skip to content

Commit 32c9216

Browse files
authored
fix: use deterministic sort for identifier field (#93)
@kumargauravsharma noticed that when generating the User resource package in the elasticache-controller, sometimes he saw the Identifier field be User.Spec.UserID. Other times it was User.Spec.UserName. Turns out in the `pkg/model.CRD:SpecIdentifierField()` method, we were looping over the `CRD.SpecFields` map keys (which are not ordered) instead of a sorted list of spec field names, which is returned by the `CRD.SpecFieldNames()` method. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 8e82f0a commit 32c9216

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/model/crd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func (r *CRD) SpecIdentifierField() *string {
435435
r.Names.Original + "Name",
436436
r.Names.Original + "Id",
437437
}
438-
for memberName := range r.SpecFields {
438+
for _, memberName := range r.SpecFieldNames() {
439439
if util.InStrings(memberName, lookup) {
440440
return &r.SpecFields[memberName].Names.Camel
441441
}

0 commit comments

Comments
 (0)