File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5353 - google-cloud-cli
5454 - krew
5555 - luarocks
56+ - persistence
5657 steps :
5758 - uses : actions/checkout@v3
5859
Original file line number Diff line number Diff line change 1+
2+ # Persistance (persistence)
3+
4+ Store data you with to persist between cntainer rebuilds.
5+
6+ ## Example Usage
7+
8+ ``` json
9+ "features" : {
10+ "ghcr.io/lugoues/devcontainer-features/persistence:1" : {}
11+ }
12+ ```
13+
14+ ## Options
15+
16+ | Options Id | Description | Type | Default Value |
17+ | -----| -----| -----| -----|
18+ | paths | Colon separated list of directory paths to persist. | string | - |
19+
20+
21+
22+ ---
23+
24+ _ Note: This file was auto-generated from the [ devcontainer-feature.json] ( https://github.com/lugoues/devcontainer-features/blob/main/src/persistence/devcontainer-feature.json ) . Add additional notes to a ` NOTES.md ` ._
Original file line number Diff line number Diff line change 1+ {
2+ "id" : " persistence" ,
3+ "version" : " 1.0.11" ,
4+ "name" : " Persistance" ,
5+ "documentationURL" : " http://github.com/lugoues/devcontainers-features/tree/main/src/persistence" ,
6+ "description" : " Store data you with to persist between cntainer rebuilds." ,
7+ "options" : {
8+ "paths" : {
9+ "default" : " " ,
10+ "description" : " Colon separated list of directory paths to persist." ,
11+ "type" : " string"
12+ }
13+ },
14+ "mounts" : [
15+ {
16+ "source" : " persistence-${devcontainerId}" ,
17+ "target" : " /mnt/persistence-data" ,
18+ "type" : " volume"
19+ }
20+ ],
21+ "postCreateCommand" : " /usr/local/share/persistence_post_create" ,
22+ "installsAfter" : [
23+ " ghcr.io/devcontainers/features/common-utils"
24+ ]
25+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ PERSIST_DIR=" /mnt/persistence-data"
6+ PERSIST_POST_CREATE=" /usr/local/share/persistence_post_create"
7+
8+ cat > " $PERSIST_POST_CREATE " << EOF
9+ #!/bin/sh
10+ set -e
11+
12+ SUDO_CMD=""
13+ [ "\$ {USER}" != "root" ] && SUDO_CMD="sudo"
14+
15+ EOF
16+
17+ IFS=' :' read -ra PATH_ARRAY <<< " ${PATHS}"
18+ for path in " ${PATH_ARRAY[@]} " ; do
19+ [[ -z " ${path} " ]] && continue
20+
21+ path=" ${path/# \~ / ${_REMOTE_USER_HOME} } "
22+ path=" ${path/# \$ HOME/ ${_REMOTE_USER_HOME} } "
23+
24+ original_path=$( realpath -m " ${path} " )
25+ safe_name=" ${original_path// \/ / _} "
26+ persist_path=" ${PERSIST_DIR} /${safe_name# _} "
27+
28+ # Add directory creation to post-create
29+ echo " \$ {SUDO_CMD} mkdir -p \" ${persist_path} \" " >> " ${PERSIST_POST_CREATE} "
30+
31+ parent_dir=" $( dirname " ${original_path} " ) "
32+ mkdir -p " ${parent_dir} "
33+
34+ if [[ -d " ${original_path} " ]]; then
35+ mv " ${original_path} " " ${original_path} .backup"
36+ fi
37+
38+ ln -s " ${persist_path} " " ${original_path} "
39+
40+ echo " \$ {SUDO_CMD} chown -R \$ USER \" ${parent_dir} \" " >> " ${PERSIST_POST_CREATE} "
41+ done
42+
43+ cat >> " $PERSIST_POST_CREATE " << EOF
44+
45+ echo "Setting owner for ${PERSIST_DIR} to \$ {USER}"
46+ \$ {SUDO_CMD} chown -R \$ USER "${PERSIST_DIR} "
47+
48+ EOF
49+
50+ chmod +x " ${PERSIST_POST_CREATE} "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ source dev-container-features-test-lib
6+
7+ # from scenario
8+ source=" /mnt/persistence-data"
9+ home=" /home/vscode"
10+
11+
12+ check " source exists" test -d " ${source} "
13+ check " target symlink" test -L " ${home} /.config/tests/nested/deep"
14+ check " write test file to new linked dir" touch " ${home} /.config/tests/nested/deep/test_file"
15+ check " ensure it exists in target" test -f " ${source} /home_vscode_.config_tests_nested_deep/test_file"
16+ check " ensure user owns target" bash -xc " [[ \$ (stat -c '%U' ${source} /home_vscode_.config_tests_nested_deep/test_file) == vscode ]]"
17+
18+ reportResults
Original file line number Diff line number Diff line change 1+ {
2+ "persitence_single_link" : {
3+ "image" : " mcr.microsoft.com/devcontainers/base:ubuntu" ,
4+ "features" : {
5+ "persistence" : {
6+ "paths" : " ~/.config/tests/nested/deep"
7+ }
8+ },
9+ "containerUser" : " vscode" ,
10+ "onCreateCommand" : " mkdir -p /mnt/persistence-data"
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ source dev-container-features-test-lib
4+
5+
6+ reportResults
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+
4+ set -e
5+
6+ source dev-container-features-test-lib
7+
8+ check " uv version" uv --version
9+
10+ reportResults
You can’t perform that action at this time.
0 commit comments