-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Kwon <[email protected]>
- Loading branch information
Showing
9 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
pkg/library/home/testdata/persistent-home/creates-initcontainer-from-first-component.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: "Creates init container from the first component when persistUserHome is enabled" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
config: | ||
workspace: | ||
persistUserHome: | ||
enabled: true | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: testing-container-2 | ||
container: | ||
image: testing-image-2 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: my-defined-volume | ||
volume: {} | ||
|
||
output: | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: persistent-home | ||
path: /home/user/ | ||
- name: testing-container-2 | ||
container: | ||
image: testing-image-2 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: persistent-home | ||
path: /home/user/ | ||
- name: my-defined-volume | ||
volume: {} | ||
- name: init-persistent-home | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: persistent-home | ||
path: /home/user/ | ||
command: | ||
- /bin/sh | ||
- -c | ||
args: | ||
- | | ||
(echo "Checking for stow command" | ||
STOW_COMPLETE=/home/user/.stow_completed | ||
if command -v stow &> /dev/null; then | ||
if [ ! -f $STOW_COMPLETE ]; then | ||
echo "Running stow command" | ||
stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /home/user/.stow.log 2>&1 | ||
cp -n /home/tooling/.viminfo /home/user/.viminfo | ||
cp -n /home/tooling/.bashrc /home/user/.bashrc | ||
cp -n /home/tooling/.bash_profile /home/user/.bash_profile | ||
touch $STOW_COMPLETE | ||
else | ||
echo "Stow command already run. If you wish to re-run it, delete $STOW_COMPLETE from the persistent volume and restart the workspace." | ||
fi | ||
else | ||
echo "Stow command not found" | ||
fi) || true | ||
- name: persistent-home | ||
volume: {} | ||
commands: | ||
- id: init-persistent-home | ||
apply: | ||
component: init-persistent-home | ||
events: | ||
prestart: | ||
- init-persistent-home |
68 changes: 68 additions & 0 deletions
68
pkg/library/home/testdata/persistent-home/creates-initcontainer-when-enabled.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: "Creates init container when persistUserHome is enabled" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
config: | ||
workspace: | ||
persistUserHome: | ||
enabled: true | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: my-defined-volume | ||
volume: {} | ||
|
||
output: | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: persistent-home | ||
path: /home/user/ | ||
- name: my-defined-volume | ||
volume: {} | ||
- name: init-persistent-home | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: persistent-home | ||
path: /home/user/ | ||
command: | ||
- /bin/sh | ||
- -c | ||
args: | ||
- | | ||
(echo "Checking for stow command" | ||
STOW_COMPLETE=/home/user/.stow_completed | ||
if command -v stow &> /dev/null; then | ||
if [ ! -f $STOW_COMPLETE ]; then | ||
echo "Running stow command" | ||
stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /home/user/.stow.log 2>&1 | ||
cp -n /home/tooling/.viminfo /home/user/.viminfo | ||
cp -n /home/tooling/.bashrc /home/user/.bashrc | ||
cp -n /home/tooling/.bash_profile /home/user/.bash_profile | ||
touch $STOW_COMPLETE | ||
else | ||
echo "Stow command already run. If you wish to re-run it, delete $STOW_COMPLETE from the persistent volume and restart the workspace." | ||
fi | ||
else | ||
echo "Stow command not found" | ||
fi) || true | ||
- name: persistent-home | ||
volume: {} | ||
commands: | ||
- id: init-persistent-home | ||
apply: | ||
component: init-persistent-home | ||
events: | ||
prestart: | ||
- init-persistent-home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
pkg/library/home/testdata/persistent-home/noop-if-init-command-already-defined.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: "Does not create persistent home volume if command with an id of 'init-persistent-home' is already defined" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
config: | ||
workspace: | ||
persistUserHome: | ||
enabled: true | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
commands: | ||
- id: init-persistent-home | ||
apply: | ||
component: testing-container-1 | ||
|
||
output: | ||
error: "failed to add init container for home persistence setup: command with id init-persistent-home already exists in the devworkspace" | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
commands: | ||
- id: init-persistent-home | ||
apply: | ||
component: testing-container-1 |
55 changes: 55 additions & 0 deletions
55
pkg/library/home/testdata/persistent-home/noop-if-init-component-already-defined.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: "Does not create persistent home volume if component named 'init-persistent-home' is already defined" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
config: | ||
workspace: | ||
persistUserHome: | ||
enabled: true | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: my-defined-volume | ||
volume: {} | ||
- name: init-persistent-home | ||
container: | ||
image: testing-image-1 | ||
command: | ||
- echo helloworld | ||
commands: | ||
- id: init-persistent-home | ||
apply: | ||
component: init-persistent-home | ||
events: | ||
prestart: | ||
- init-persistent-home | ||
|
||
output: | ||
error: "failed to add init container for home persistence setup: component named init-persistent-home already exists in the devworkspace" | ||
workspace: | ||
components: | ||
- name: testing-container-1 | ||
container: | ||
image: testing-image-1 | ||
volumeMounts: | ||
- name: my-defined-volume | ||
path: /my-defined-volume-path | ||
- name: my-defined-volume | ||
volume: {} | ||
- name: init-persistent-home | ||
container: | ||
image: testing-image-1 | ||
command: | ||
- echo helloworld | ||
commands: | ||
- id: init-persistent-home | ||
apply: | ||
component: init-persistent-home | ||
events: | ||
prestart: | ||
- init-persistent-home |
19 changes: 19 additions & 0 deletions
19
pkg/library/home/testdata/persistent-home/noop-if-init-prestartevent-already-defined.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: "Does not create persistent home volume if prestart event with an id of 'init-persistent-home' is already defined" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
config: | ||
workspace: | ||
persistUserHome: | ||
enabled: true | ||
workspace: | ||
events: | ||
prestart: | ||
- init-persistent-home | ||
|
||
output: | ||
error: "failed to add init container for home persistence setup: command with id init-persistent-home already exists in the devworkspace" | ||
workspace: | ||
events: | ||
prestart: | ||
- init-persistent-home |
14 changes: 14 additions & 0 deletions
14
pkg/library/home/testdata/persistent-home/noop-if-no-components.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "No op if there are no components" | ||
|
||
input: | ||
devworkspaceId: "test-workspaceid" | ||
config: | ||
workspace: | ||
persistUserHome: | ||
enabled: true | ||
workspace: | ||
components: [] | ||
|
||
output: | ||
workspace: | ||
components: [] |