Skip to content

Commit a33b38d

Browse files
authored
Merge pull request #53 from joshuanianji/edgedb-persistence
[edgedb] Cache config dir
2 parents a466b0d + 08ef3b6 commit a33b38d

File tree

5 files changed

+53
-30
lines changed

5 files changed

+53
-30
lines changed

src/edgedb-cli/NOTES.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## Note to Users
2+
3+
This feature mounts the edgedb config and data folder to the host machine for persistence. To do so, it makes some assumptions about `edgedb info`:
4+
5+
```bash
6+
$ edgedb info
7+
8+
EdgeDB uses the following local paths:
9+
┌────────────┬────────────────────────────────────────┐
10+
│ Cache │ /home/<user>/.cache/edgedb/ │
11+
│ Config │ /home/<user>/.config/edgedb/ │
12+
│ CLI Binary │ /home/<user>/.local/bin/edgedb │
13+
│ Data │ /home/<user>/.local/share/edgedb/data/ │
14+
│ Service │ /home/<user>/.config/systemd/user/ │
15+
└────────────┴────────────────────────────────────────┘
16+
```
17+
18+
**These paths may change based on the OS!**. This feature is tested on Ubuntu and Debian and the paths match up, but may not work for others.
19+
120
## OS and Architecture Support
221

322
Architectures: `amd` and `arm`
@@ -8,7 +27,8 @@ Shells: `bash`, `zsh`, `fish`
827

928
## Changelog
1029

11-
| Version | Notes |
12-
| ------- | ---------------------- |
13-
| 1.0.1 | Fix for non-root users |
14-
| 1.0.0 | Initial Version |
30+
| Version | Notes |
31+
| ------- | -------------------------- |
32+
| 1.0.2 | Cache edgedb config folder |
33+
| 1.0.1 | Fix for non-root users |
34+
| 1.0.0 | Initial Version |

src/edgedb-cli/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "EdgeDB",
33
"id": "edgedb-cli",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"documentationURL": "https://github.com/joshuanianji/devcontainer-features/tree/main/src/edgedb-cli",
6-
"description": "EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts ~/.local/share/edgedb for data persistence.",
6+
"description": "EdgeDB CLI via the official installation script. Includes the VSCode extension and mounts the config and data folder.",
77
"options": {},
88
"customizations": {
99
"vscode": {

src/edgedb-cli/install.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,14 @@ export DEBIAN_FRONTEND=noninteractive
7373

7474
check_packages curl ca-certificates
7575

76-
create_cache_dir "/dc/edgedb-cli" "${USERNAME}"
77-
create_symlink_dir "$_REMOTE_USER_HOME/.local/share/edgedb" "/dc/edgedb-cli" "${USERNAME}"
76+
# cache data directory
77+
create_cache_dir "/dc/edgedb-cli/data" "${USERNAME}"
78+
create_symlink_dir "$_REMOTE_USER_HOME/.local/share/edgedb" "/dc/edgedb-cli/data" "${USERNAME}"
79+
80+
# cache config directory
81+
create_cache_dir "/dc/edgedb-cli/config" "${USERNAME}"
82+
create_symlink_dir "$_REMOTE_USER_HOME/.config/edgedb" "/dc/edgedb-cli/config" "${USERNAME}"
83+
7884
install_edgedb "${USERNAME}"
7985

8086
# Set Lifecycle scripts

test/edgedb-cli/_default.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,28 @@ source dev-container-features-test-lib
1111
# check that the command is available
1212
check "help" bash -c "edgedb --help | grep 'Usage'"
1313

14-
# check that `.config/gh` and `/dc/github-cli` exist under the user (should be node)
14+
# make sure edgedb directories match up with our expectations
15+
check "edgedb cli data dir" bash -c "test \"$(edgedb info --get data-dir)\" = $HOME/.local/share/edgedb/data/"
16+
check "edgedb cli config dir" bash -c "test \"$(edgedb info --get config-dir)\" = $HOME/.config/edgedb/"
17+
18+
# check that data directories exist
1519
check "~/.local/share/edgedb exists" bash -c "ls -la ~/.local/share | grep 'edgedb'"
16-
check "/dc/edgedb-cli exists" bash -c "ls -la /dc | grep 'edgedb-cli'"
20+
check "/dc/edgedb-cli/data exists" bash -c "ls -la /dc/edgedb-cli | grep 'data'"
21+
22+
# check that config directories exist
23+
check "~/.config/edgedb exists" bash -c "ls -la ~/.config | grep 'edgedb'"
24+
check "/dc/edgedb-cli exists" bash -c "ls -la /dc/edgedb-cli | grep 'config'"
1725

1826
# check that the folders are owned by the user
1927
# https://askubuntu.com/a/175060
20-
echo "Checking ownership of ~/.local/share/edgedb and /dc/edgedb-cli (ensure it is owned by $USER)"
21-
ls -al ~/.local/share/
28+
# $USER is empty when running as root, so we use $(whoami)
29+
echo "Checking ownership of ~/.local/share/edgedb/data and /dc/edgedb-cli/data (ensure it is owned by $(whoami))"
30+
31+
check "~/.local/share/edgedb owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/edgedb)\" = $(whoami)"
32+
check "/dc/edgedb-cli/data owned by user" bash -c "test \"$(stat -c "%U" /dc/edgedb-cli/data)\" = $(whoami)"
2233

23-
check "~/.local/share/edgedb owned by user" bash -c "test \"$(stat -c "%U" ~/.local/share/edgedb)\" = $USER"
24-
check "/dc/edgedb-cli owned by user" bash -c "test \"$(stat -c "%U" /dc/edgedb-cli)\" = $USER"
34+
check "~/.config/edgedb owned by user" bash -c "test \"$(stat -c "%U" ~/.config/edgedb)\" = $(whoami)"
35+
check "/dc/edgedb-cli/config owned by user" bash -c "test \"$(stat -c "%U" /dc/edgedb-cli/config)\" = $(whoami)"
2536

2637
# Report result
2738
reportResults

test/edgedb-cli/test.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@ source dev-container-features-test-lib
77

88
# NOTE: this is an "auto-generated" test, which means it will be
99
# executed against an auto-generated devcontainer.json that
10-
# includes the 'gcloud-cli-persistence' Feature with no options.
11-
#
12-
# https://github.com/devcontainers/cli/blob/main/docs/features/test.md
13-
#
14-
# From my tests, this means the `gcloud` CLI will not be installed:
15-
# Thus, here, I only check basic directory existence
10+
# includes the feature with no options
1611

17-
# check that `~/.config/gcloud` and `/dc/gcloud-cli` exist`
18-
check "config" bash -c "ls -la ~/.local/share/ | grep 'edgedb'"
19-
check "dc" bash -c "ls -la /dc | grep 'edgedb-cli'"
20-
21-
# check that `~/.config/gcloud` is a symlink
22-
# https://unix.stackexchange.com/a/96910
23-
check "~/.local/share/edgedb is a symlink" bash -c "test -L ~/.local/share/edgedb && test -d ~/.local/share/edgedb"
24-
25-
# Report result
26-
reportResults
12+
./_default.sh

0 commit comments

Comments
 (0)