Skip to content

Commit

Permalink
Add overrides test cases for patch directives
Browse files Browse the repository at this point in the history
Signed-off-by: Angel Misevski <[email protected]>
  • Loading branch information
amisevsk committed Nov 10, 2022
1 parent b18b386 commit 890b27c
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,4 @@ input:


output:
container:
name: test-component
image: test-image
command: ["original"]
args: ["original"]
ports:
- name: original-port
containerPort: 8080
volumeMounts:
- name: original-volume
mountPath: original-mountPath
env:
- name: original_env
value: original_val
errRegexp: "cannot use container-overrides to override container env"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "container overrides can override securityContext"

input:
component:
name: test-component
attributes:
container-overrides:
securityContext:
runAsUser: 1001
container:
image: test-image

container:
name: test-component
image: test-image
securityContext:
runAsUser: 1000
runAsGroup: 2000

output:
container:
name: test-component
image: test-image
securityContext:
runAsUser: 1001
runAsGroup: 2000
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "container overrides can use $patch: delete to delete fields rather than merging"

input:
component:
name: test-component
attributes:
container-overrides:
securityContext:
$patch: delete
container:
image: test-image

container:
name: test-component
image: test-image
securityContext:
runAsUser: 1000
runAsGroup: 2000

output:
container:
name: test-component
image: test-image
securityContext: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "container overrides can use $patch: replace to overwrite fields rather than merging"

input:
component:
name: test-component
attributes:
container-overrides:
securityContext:
runAsUser: 1001
$patch: replace
container:
image: test-image

container:
name: test-component
image: test-image
securityContext:
runAsUser: 1000
runAsGroup: 2000

output:
container:
name: test-component
image: test-image
securityContext:
runAsUser: 1001
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Returns error when attempting to patch pod volumes"

input:
workspace:
attributes:
pod-overrides:
spec:
volumes:
- name: test-volume
components:
- name: test-component
container:
image: test-image

podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image

output:
errRegexp: "cannot use pod-overrides to override pod volumes"
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Pod overrides can override securityContext"

input:
workspace:
attributes:
pod-overrides:
spec:
securityContext:
runAsUser: 1001
components:
- name: test-component
container:
image: test-image

podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image
securityContext:
fsGroup: 2000
runAsGroup: 3000
runAsUser: 1000


output:
podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image
securityContext:
fsGroup: 2000
runAsGroup: 3000
runAsUser: 1001
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Pod overrides can use $patch: delete to delete fields rather than merging"

input:
workspace:
attributes:
pod-overrides:
spec:
securityContext:
$patch: delete
components:
- name: test-component
container:
image: test-image

podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image
securityContext:
fsGroup: 2000
runAsGroup: 3000
runAsUser: 1000


output:
podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image
securityContext: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Pod overrides can use $patch: replace to overwrite fields rather than merging"

input:
workspace:
attributes:
pod-overrides:
spec:
securityContext:
runAsUser: 1001
$patch: replace
components:
- name: test-component
container:
image: test-image

podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image
securityContext:
fsGroup: 2000
runAsGroup: 3000
runAsUser: 1000


output:
podTemplateSpec:
metadata:
labels:
controller.devfile.io/devworkspace-id: test-id
spec:
containers:
- name: test-component
image: test-image
securityContext:
runAsUser: 1001

0 comments on commit 890b27c

Please sign in to comment.