github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/kustomize/ordering.go (about) 1 package kustomize 2 3 /** 4 Code for ordering Kubernetes entities by kind. 5 6 Adapted from 7 https://github.com/kubernetes-sigs/kustomize/blob/9686cc9861f25d831e4158e928ba584f3e5feea8/api/resid/gvk.go 8 9 Copyright 2019 The Kubernetes Authors. 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 */ 23 24 // An attempt to order things to help k8s, e.g. 25 // a Service should come before things that refer to it. 26 // Namespace should be first. 27 // In some cases order just specified to provide determinism. 28 // Adapted from Kustomize: 29 // https://github.com/kubernetes-sigs/kustomize/blob/9686cc9861f25d831e4158e928ba584f3e5feea8/api/resid/gvk.go 30 31 var OrderFirst = []string{ 32 "Namespace", 33 "ResourceQuota", 34 "StorageClass", 35 "CustomResourceDefinition", 36 "MutatingWebhookConfiguration", 37 "ServiceAccount", 38 "PodSecurityPolicy", 39 "Role", 40 "ClusterRole", 41 "RoleBinding", 42 "ClusterRoleBinding", 43 "PersistentVolume", 44 "PersistentVolumeClaim", 45 "ConfigMap", 46 "Secret", 47 "Service", 48 "LimitRange", 49 "PriorityClass", 50 "Deployment", 51 "StatefulSet", 52 "CronJob", 53 "PodDisruptionBudget", 54 } 55 56 var TypeOrders = func() map[string]int { 57 m := map[string]int{} 58 for i, n := range OrderFirst { 59 m[n] = -len(OrderFirst) + i 60 } 61 return m 62 }()