forked from grafana/jsonnet-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlegacy-subtypes.libsonnet
168 lines (156 loc) · 4.34 KB
/
legacy-subtypes.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// legacy-subtypes.libsonnet makes first-class entities available as subtypes like in ksonnet-lib.
// It also makes the empty new() functions and camelCased functions available.
// This is largely based on kausal-shim.libsonnet from k8s-alpha.
{
core+: { v1+: {
container+: {
envType: $.core.v1.envVar,
envFromType: $.core.v1.envFromSource,
portsType: $.core.v1.containerPort,
volumeMountsType: $.core.v1.volumeMount,
},
pod+: {
spec+: {
volumesType: $.core.v1.volume,
},
},
service+: {
spec+: {
withClusterIp: self.withClusterIP,
withLoadBalancerIp: self.withLoadBalancerIP,
portsType: $.core.v1.servicePort,
},
},
envFromSource+: { new():: {} },
nodeSelector+: { new():: {} },
nodeSelectorTerm+: { new():: {} },
podAffinityTerm+: { new():: {} },
preferredSchedulingTerm+: { new():: {} },
toleration+: { new():: {} },
localObjectReference+: { new():: {} },
} },
local appsAffinityPatch = {
nodeAffinity+: {
requiredDuringSchedulingIgnoredDuringExecutionType: $.core.v1.nodeSelector {
nodeSelectorTermsType: $.core.v1.nodeSelectorTerm {
matchFieldsType: $.core.v1.nodeSelectorRequirement,
},
},
preferredDuringSchedulingIgnoredDuringExecutionType: $.core.v1.preferredSchedulingTerm {
preferenceType: {
matchFieldsType: $.core.v1.nodeSelectorRequirement,
},
},
},
podAntiAffinity+: {
requiredDuringSchedulingIgnoredDuringExecutionType: $.core.v1.podAffinityTerm,
},
},
local appsPatch = {
deployment+: {
spec+: { template+: { spec+: {
volumesType: $.core.v1.volume,
containersType: $.core.v1.container,
tolerationsType: $.core.v1.toleration,
affinity+: appsAffinityPatch,
} } },
},
daemonSet+: {
spec+: { template+: { spec+: {
withHostPid:: self.withHostPID,
tolerationsType: $.core.v1.toleration,
affinity+: appsAffinityPatch,
} } },
},
statefulSet+: {
spec+: { template+: { spec+: {
volumesType: $.core.v1.volume,
affinity+: appsAffinityPatch,
tolerationsType: $.core.v1.toleration,
imagePullSecretsType: $.core.v1.localObjectReference,
} } },
},
},
apps+: {
v1+: appsPatch,
v1beta1+: appsPatch,
},
extensions+: {
v1beta1+: appsPatch {
ingress+: {
spec+: {
rulesType: $.extensions.v1beta1.ingressRule {
httpType+: { pathsType: $.extensions.v1beta1.httpIngressPath },
},
},
},
},
},
batch+: {
local patch = {
mixin+: { spec+: { jobTemplate+: { spec+: { template+: { spec+: {
imagePullSecretsType: $.core.v1.localObjectReference,
} } } } } },
},
v1+: {
job+: patch,
cronJob+: patch,
},
v1beta1+: {
job+: patch,
cronJob+: patch,
},
},
local rbacPatch = {
local role = {
rulesType: $.rbac.v1beta1.policyRule,
},
role+: role,
clusterRole+: role,
local binding = {
subjectsType: $.rbac.v1beta1.subject,
},
roleBinding+: binding,
clusterRoleBinding+: binding,
subject+: { new():: {} },
policyRule+: {
new():: {},
withNonResourceUrls: self.withNonResourceURLs,
},
},
rbac+: {
v1+: rbacPatch,
v1beta1+: rbacPatch,
},
policy+: {
v1beta1+: {
idRange+: { new():: {} },
podSecurityPolicy+: {
mixin+: { spec+: {
runAsUser+: { rangesType: $.policy.v1beta1.idRange },
withHostIpc: self.withHostIPC,
withHostPid: self.withHostPID,
} },
},
},
},
admissionregistration+: { v1beta1+: {
webhook+: { new():: {} },
ruleWithOperations+: { new():: {} },
local webhooksType = $.admissionregistration.v1beta1.webhook {
rulesType: $.admissionregistration.v1beta1.ruleWithOperations,
mixin+: { namespaceSelector+: { matchExpressionsType: {
new():: {},
withKey(key):: { key: key },
withOperator(operator):: { operator: operator },
withValues(values):: { values: if std.isArray(values) then values else [values] },
} } },
},
mutatingWebhookConfiguration+: {
webhooksType: webhooksType,
},
validatingWebhookConfiguration+: {
webhooksType: webhooksType,
},
} },
}