You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crd.yaml
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,19 @@ spec:
6
6
group: vaultwebhook.uswitch.com
7
7
versions:
8
8
- name: v1alpha1
9
+
# Each version can be enabled/disabled by Served flag.
9
10
served: true
11
+
# One and only one version must be marked as the storage version.
10
12
storage: true
11
13
schema:
12
14
openAPIV3Schema:
15
+
type: object
16
+
description: |-
17
+
A MutatingAdmissionController that will add the vault-creds container to your pod
18
+
for you when your pod is created (assuming that vault webhook is enabled on your namespace
13
19
properties:
14
20
spec:
21
+
type: object
15
22
properties:
16
23
database:
17
24
type: string
@@ -20,7 +27,29 @@ spec:
20
27
outputPath:
21
28
type: string
22
29
outputFile:
30
+
type: string
31
+
serviceAccount:
23
32
type: string
33
+
container:
34
+
description: Specification of the container that will be created as part of this binding.
35
+
type: object
36
+
properties:
37
+
lifecycle:
38
+
description: Specification of the lifecycle hooks of the container. https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
39
+
type: object
40
+
properties:
41
+
preStop:
42
+
description: This hook is called immediately before a container is terminated due to an API request or management event such as a liveness/startup probe failure, preemption, resource contention and others
43
+
type: object
44
+
properties:
45
+
exec:
46
+
description: Executes a specific command, inside the cgroups and namespaces of the Container.
// Can we add a preStop hook to the vault container?
190
+
funcTestAddLifecyclePreStopHook(t*testing.T) {
191
+
192
+
// Define test cases
193
+
vartests= []struct {
194
+
scenariostring
195
+
lifecycleObj v1alpha1.Container
196
+
answerbool
197
+
}{
198
+
{
199
+
scenario: "Test passing a complete lifecyle config",
200
+
lifecycleObj: v1alpha1.Container{
201
+
Lifecycle: v1.Lifecycle{
202
+
PreStop: &v1.LifecycleHandler{
203
+
Exec: &v1.ExecAction{
204
+
Command: []string{"echo", "hello"},
205
+
},
206
+
},
207
+
},
208
+
},
209
+
answer: true,
210
+
},
211
+
{
212
+
scenario: "Test passing an incomplete lifecycle config",
213
+
lifecycleObj: v1alpha1.Container{
214
+
Lifecycle: v1.Lifecycle{
215
+
PreStop: &v1.LifecycleHandler{
216
+
Exec: nil,
217
+
},
218
+
},
219
+
},
220
+
answer: false,
221
+
},
222
+
{
223
+
// v1alpha1.Container{}, comes from corev1.Container{} and this ALWAYS have a c.Lifecycle object. The latter, always has pointers to PostStart and PreStop handlers ( but no further down the struct since they are pointers )
224
+
// if our dcb input does not specify a container object, the received input will look like this: {Lifecycle:{PostStart:nil PreStop:nil}}
225
+
scenario: "Test passing no lifecycle config",
226
+
lifecycleObj: v1alpha1.Container{
227
+
Lifecycle: v1.Lifecycle{
228
+
PreStop: nil,
229
+
},
230
+
},
231
+
answer: false,
232
+
},
233
+
}
234
+
235
+
// Run tests
236
+
for_, tt:=rangetests {
237
+
// t.Run enables running "subtests", one for each table entry. These are shown separately when executing `go test -v`.
238
+
vaultContainer:= v1.Container{} // Define a Vault sidecar Container
0 commit comments