Skip to content

Commit

Permalink
storage tests 6
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Jul 30, 2024
1 parent e28e009 commit 611e0a9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
7 changes: 5 additions & 2 deletions builders/lando-v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ module.exports = {
});

// add any overrides on top
this.addLandoServiceData(config.overrides);
// @NOTE: should this be addLandoServiceData?
// @NOTE: does it make sense to have a way to override both LandoServiceData and regular ServiceData?
this.addServiceData(config.overrides);
}

addHookFile(file, {id = undefined, hook = 'boot', stage = 'image', priority = '100'} = {}) {
Expand Down Expand Up @@ -429,7 +431,8 @@ module.exports = {
// find any volumes we might need to create
const cstorage = this.storage
.filter(volume => volume.type === 'volume')
.filter(volume => !estorage.includes(volume.source));
.filter(volume => !estorage.includes(volume.source))
.filter(volume => volume?.labels?.['dev.lando.storage-volume'] === 'TRUE');

await Promise.all(cstorage.map(async volume => {
try {
Expand Down
13 changes: 11 additions & 2 deletions examples/storage/.lando.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: lando-storage
volumes:
my-data:
services:
db:
api: 4
Expand All @@ -7,6 +9,14 @@ services:
user: mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
# below goes through addLandoServiceData which will add an extra volume "my-data" without context during appBuild
# volumes:
# - my-data:/my-data
# so we want to use "overrides" which uses addServiceData and will not to additional processing and not create
# the extra volumes
overrides:
volumes:
- my-data:/my-data
storage:
# short form single service scoped volume at /var/lib/mysql
- /var/lib/mysql
Expand Down Expand Up @@ -42,7 +52,6 @@ services:
# remount for fun?
- source: landostorage-db-var-lib-mysql
target: /var/lib/mysql-backup

alpine:
api: 4
image: alpine:3.20
Expand Down Expand Up @@ -70,7 +79,7 @@ services:
image: alpine:3.20
command: sleep infinity
user: me
persistent-storage:
storage:
- destination: /someplace
owner: games
- destination: /someplace-secret
Expand Down
7 changes: 7 additions & 0 deletions examples/storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ lando exec owners -- stat /someplace-secret/root
lando exec owners -- stat /someplace-free | grep Access: | grep "0777"
lando exec owners -- touch /someplace-free/me
lando exec owners -- stat /someplace-free/me

# Should allow for top level volumes to still be used with overrides.volumes
docker volume inspect my-data || echo "$?" | grep 1
docker volume inspect landostorage_my-data
docker volume inspect landostorage_my-data | grep com.docker.compose.project | grep landostorage
docker volume inspect landostorage_my-data | grep com.docker.compose.volume | grep my-data
lando exec --user root db -- touch /my-data/thing
```

## Destroy tests
Expand Down

0 comments on commit 611e0a9

Please sign in to comment.