Skip to content

Commit ff4370b

Browse files
committed
🌱 adjust naming in SortForCreate
1 parent 0270e04 commit ff4370b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

util/resource/resource.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import (
2323
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2424
)
2525

26-
var priorityMap = map[string]int{
26+
// orderMapping maps resource kinds to their creation order,
27+
// the lower the number, the earlier the resource should be created.
28+
var orderMapping = map[string]int{
2729
// Namespaces go first because all namespaced resources depend on them.
2830
"Namespace": -100,
2931
// Custom Resource Definitions come before Custom Resource so that they can be
@@ -53,8 +55,8 @@ var priorityMap = map[string]int{
5355
// priorityLess returns true if o1 should be created before o2.
5456
// To be used in sort.{Slice,SliceStable} to sort manifests in place.
5557
func priorityLess(o1, o2 unstructured.Unstructured) bool {
56-
p1 := priorityMap[o1.GetKind()]
57-
p2 := priorityMap[o2.GetKind()]
58+
p1 := orderMapping[o1.GetKind()]
59+
p2 := orderMapping[o2.GetKind()]
5860
return p1 < p2
5961
}
6062

0 commit comments

Comments
 (0)