1
2
3
4 package yaml
5
6
7
8 var fieldSortOrder = []string{
9
10 "name", "generateName", "namespace", "clusterName",
11 "apiVersion", "kind", "metadata", "type",
12 "labels", "annotations",
13 "spec", "status",
14
15
16 "stringData", "data", "binaryData",
17
18
19
20 "parallelism", "completions", "activeDeadlineSeconds", "backoffLimit",
21 "replicas", "selector", "manualSelector", "template",
22 "ttlSecondsAfterFinished", "volumeClaimTemplates", "service", "serviceName",
23 "podManagementPolicy", "updateStrategy", "strategy", "minReadySeconds",
24 "revision", "revisionHistoryLimit", "paused", "progressDeadlineSeconds",
25
26
27
28 "restartPolicy", "terminationGracePeriodSeconds",
29 "activeDeadlineSeconds", "dnsPolicy", "serviceAccountName",
30 "serviceAccount", "automountServiceAccountToken", "nodeName",
31 "hostNetwork", "hostPID", "hostIPC", "shareProcessNamespace", "hostname",
32 "subdomain", "schedulerName", "priorityClassName", "priority",
33 "runtimeClassName", "enableServiceLinks",
34
35
36 "nodeSelector", "hostAliases",
37
38
39 "initContainers", "containers", "volumes", "securityContext",
40 "imagePullSecrets", "affinity", "tolerations", "dnsConfig",
41 "readinessGates",
42
43
44 "image", "command", "args", "workingDir", "ports", "envFrom", "env",
45 "resources", "volumeMounts", "volumeDevices", "livenessProbe",
46 "readinessProbe", "lifecycle", "terminationMessagePath",
47 "terminationMessagePolicy", "imagePullPolicy", "securityContext",
48 "stdin", "stdinOnce", "tty",
49
50
51 "clusterIP", "externalIPs", "loadBalancerIP", "loadBalancerSourceRanges",
52 "externalName", "externalTrafficPolicy", "sessionAffinity",
53
54
55 "protocol", "port", "targetPort", "hostPort", "containerPort", "hostIP",
56
57
58 "readOnly", "mountPath", "subPath", "subPathExpr", "mountPropagation",
59
60
61 "value", "valueFrom", "fieldRef", "resourceFieldRef", "configMapKeyRef",
62 "secretKeyRef", "prefix", "configMapRef", "secretRef",
63 }
64
65 type set map[string]interface{}
66
67 func newSet(values ...string) set {
68 m := map[string]interface{}{}
69 for _, value := range values {
70 m[value] = nil
71 }
72 return m
73 }
74
75 func (s set) Has(key string) bool {
76 _, found := s[key]
77 return found
78 }
79
80
81
82 var WhitelistedListSortKinds = newSet(
83 "CronJob", "DaemonSet", "Deployment", "Job", "ReplicaSet", "StatefulSet",
84 "ValidatingWebhookConfiguration")
85
86
87
88 var WhitelistedListSortApis = newSet(
89 "apps/v1", "apps/v1beta1", "apps/v1beta2", "batch/v1", "batch/v1beta1",
90 "extensions/v1beta1", "v1", "admissionregistration.k8s.io/v1")
91
92
93
94 var WhitelistedListSortFields = map[string]string{
95 ".spec.template.spec.containers": "name",
96 ".webhooks.rules.operations": "",
97 }
98
99
100 var FieldOrder = func() map[string]int {
101
102 fo := map[string]int{}
103 for i, f := range fieldSortOrder {
104 fo[f] = i + 1
105 }
106 return fo
107 }()
108
View as plain text