-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_case_4.yaml
75 lines (71 loc) · 1.94 KB
/
test_case_4.yaml
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
request:
path: /my-webhook
body:
apiVersion: admission.k8s.io/v1
kind: AdmissionReview
request:
uid: "1234"
object:
apiVersion: v1
kind: ServiceAccount
metadata:
name: experimental-descheduler
namespace: kube-system
labels:
app.kubernetes.io/name: descheduler
app.kubernetes.io/version: "0.27.1"
webhook_config:
apiVersion: generic-webhook/v1beta1
kind: GenericWebhookConfig
webhooks:
- name: my-webhook-1
path: /my-webhook
actions:
# Refuse the request if the name is "random-name"
- condition: .metadata.name == "random-name"
accept: false
# Otherwise, accept it and add a label
- accept: true
patch:
- op: add
path: .metadata.labels
value:
myLabel: myValue
- name: my-webhook-2
path: /my-webhook
actions:
# Add another label if myLabel is present. This only happens if the previous
# call to my-webhook-1 went through the second action
- condition: .metadata.labels.myLabel == "myValue"
patch:
- op: add
path: .metadata.labels
value:
otherLabel: otherValue
cases:
- patches: []
expected_response:
apiVersion: admission.k8s.io/v1
kind: AdmissionReview
response:
uid: "1234"
allowed: True
patchType: JSONPatch
patch:
- op: add
path: /metadata/labels
value:
myLabel: myValue
- op: add
path: /metadata/labels
value:
otherLabel: otherValue
- patches:
- key: [request, body, request, object, metadata, name]
value: random-name
expected_response:
apiVersion: admission.k8s.io/v1
kind: AdmissionReview
response:
uid: "1234"
allowed: False