Skip to content

Commit f556e7e

Browse files
authored
Always sort resources by name (#15907)
1 parent 7c110b7 commit f556e7e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mmv1/loader/loader.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88
"path/filepath"
99
"reflect"
10-
"sort"
10+
"strings"
1111
"sync"
1212

1313
"github.com/GoogleCloudPlatform/magic-modules/mmv1/api"
@@ -243,6 +243,10 @@ func (l *Loader) loadResources(product *api.Product) ([]*api.Resource, error) {
243243
return nil, err
244244
}
245245
}
246+
// Sort resources by name for consistent output
247+
slices.SortFunc(resources, func(a, b *api.Resource) int {
248+
return strings.Compare(a.Name, b.Name)
249+
})
246250

247251
return resources, nil
248252
}
@@ -267,11 +271,6 @@ func (l *Loader) reconcileOverrideResources(product *api.Product, resources []*a
267271
resources = append(resources, resource)
268272
}
269273

270-
// Sort resources by name for consistent output
271-
sort.Slice(resources, func(i, j int) bool {
272-
return resources[i].Name < resources[j].Name
273-
})
274-
275274
return resources, nil
276275
}
277276

0 commit comments

Comments
 (0)