Skip to content

Commit

Permalink
fix: use deterministic sort for identifier field (#93)
Browse files Browse the repository at this point in the history
@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.
  • Loading branch information
jaypipes authored Jun 17, 2021
1 parent 8e82f0a commit 32c9216
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/model/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (r *CRD) SpecIdentifierField() *string {
r.Names.Original + "Name",
r.Names.Original + "Id",
}
for memberName := range r.SpecFields {
for _, memberName := range r.SpecFieldNames() {
if util.InStrings(memberName, lookup) {
return &r.SpecFields[memberName].Names.Camel
}
Expand Down

0 comments on commit 32c9216

Please sign in to comment.