Skip to content

Commit

Permalink
chore: add tests for ensuring project source and root are first env vars
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Obuchowicz <[email protected]>
  • Loading branch information
AObuchow committed Jul 3, 2024
1 parent ae31bc4 commit 26b9f18
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ output:
memory: "-1"
cpu: "-1"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: "TEST_ENVVAR"
value: "TEST_VALUE"
- name: "PROJECTS_ROOT"
value: "/source-mapping"
- name: "PROJECT_SOURCE"
value: "/source-mapping"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: "TEST_ENVVAR"
value: "TEST_VALUE"
command:
- "test"
- "command"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: "Ensures PROJECT_ROOT and PROJECT_SOURCE env vars are first in list of env vars"

input:
projects:
- name: test_project
clonePath: clone-path
components:
- name: testing-container-1
container:
image: testing-image-1
memoryRequest: "-1" # isolate test to not include this field
memoryLimit: "-1" # isolate test to not include this field
cpuRequest: "-1" # isolate test to not include this field
cpuLimit: "-1" # isolate test to not include this field
# no mountSources defined -> should mount sources
env:
- name: user-env-var-1
value: value1
- name: user-env-var-1
value: value1
- name: testing-container-2
container:
image: testing-image-2
memoryRequest: "-1" # isolate test to not include this field
memoryLimit: "-1" # isolate test to not include this field
cpuRequest: "-1" # isolate test to not include this field
cpuLimit: "-1" # isolate test to not include this field
# No sourceMapping -> defaults to "/projects"
mountSources: true # mountSources: true -> should mount sources
env:
- name: user-env-var-2
value: value1
- name: user-env-var-3
value: value1
- name: testing-container-3
container:
image: testing-image-3
memoryRequest: "-1" # isolate test to not include this field
memoryLimit: "-1" # isolate test to not include this field
cpuRequest: "-1" # isolate test to not include this field
cpuLimit: "-1" # isolate test to not include this field
sourceMapping: "/projects"
mountSources: false # mountSources: false -> should not mount sources
env:
- name: user-env-var-4
value: value1
- name: user-env-var-5
value: value1
output:
podAdditions:
containers:
- name: testing-container-1
image: testing-image-1
imagePullPolicy: Always
resources:
requests:
memory: "-1"
cpu: "-1"
limits:
memory: "-1"
cpu: "-1"
volumeMounts:
- name: "projects"
mountPath: "/projects"
env:
- name: "PROJECTS_ROOT"
value: "/projects"
- name: "PROJECT_SOURCE"
value: "/projects/clone-path"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: user-env-var-1
value: value1
- name: user-env-var-1
value: value1
- name: testing-container-2
image: testing-image-2
imagePullPolicy: Always
resources:
requests:
memory: "-1"
cpu: "-1"
limits:
memory: "-1"
cpu: "-1"
volumeMounts:
- name: "projects"
mountPath: "/projects"
env:
- name: "PROJECTS_ROOT"
value: "/projects"
- name: "PROJECT_SOURCE"
value: "/projects/clone-path"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: user-env-var-2
value: value1
- name: user-env-var-3
value: value1
- name: testing-container-3
image: testing-image-3
imagePullPolicy: Always
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-3"
- name: user-env-var-4
value: value1
- name: user-env-var-5
value: value1
resources:
requests:
memory: "-1"
cpu: "-1"
limits:
memory: "-1"
cpu: "-1"
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ output:
- name: "projects"
mountPath: "/testdir1"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: "PROJECTS_ROOT"
value: "/testdir1"
- name: "PROJECT_SOURCE"
value: "/testdir1/clone-path"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: testing-container-2
image: testing-image-2
imagePullPolicy: Always
Expand All @@ -71,12 +71,12 @@ output:
- name: "projects"
mountPath: "/projects"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: "PROJECTS_ROOT"
value: "/projects"
- name: "PROJECT_SOURCE"
value: "/projects/clone-path"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: testing-container-3
image: testing-image-3
imagePullPolicy: Always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ output:
- name: "projects"
mountPath: "/testdir1"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: "PROJECTS_ROOT"
value: "/testdir1"
- name: "PROJECT_SOURCE"
value: "/testdir1/test_project"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: testing-container-2
image: testing-image-2
imagePullPolicy: Always
Expand All @@ -70,12 +70,12 @@ output:
- name: "projects"
mountPath: "/projects"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: "PROJECTS_ROOT"
value: "/projects"
- name: "PROJECT_SOURCE"
value: "/projects/test_project"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: testing-container-3
image: testing-image-3
imagePullPolicy: Always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ output:
- name: "projects"
mountPath: "/not-source-mapping"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: "PROJECTS_ROOT"
value: "/not-source-mapping"
- name: "PROJECT_SOURCE"
value: "/not-source-mapping"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
8 changes: 4 additions & 4 deletions pkg/library/container/testdata/volume/mountSources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ output:
- name: "projects"
mountPath: "/testdir1"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: "PROJECTS_ROOT"
value: "/testdir1"
- name: "PROJECT_SOURCE"
value: "/testdir1"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-1"
- name: testing-container-2
image: testing-image-2
imagePullPolicy: Always
Expand All @@ -66,12 +66,12 @@ output:
- name: "projects"
mountPath: "/projects"
env:
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: "PROJECTS_ROOT"
value: "/projects"
- name: "PROJECT_SOURCE"
value: "/projects"
- name: "DEVWORKSPACE_COMPONENT_NAME"
value: "testing-container-2"
- name: testing-container-3
image: testing-image-3
imagePullPolicy: Always
Expand Down

0 comments on commit 26b9f18

Please sign in to comment.