diff --git a/builders/lando-v4.js b/builders/lando-v4.js index 31e229d3..ab30cb7f 100644 --- a/builders/lando-v4.js +++ b/builders/lando-v4.js @@ -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'} = {}) { @@ -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 { diff --git a/examples/storage/.lando.yml b/examples/storage/.lando.yml index 09982beb..08278224 100644 --- a/examples/storage/.lando.yml +++ b/examples/storage/.lando.yml @@ -1,4 +1,6 @@ name: lando-storage +volumes: + my-data: services: db: api: 4 @@ -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 @@ -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 @@ -70,7 +79,7 @@ services: image: alpine:3.20 command: sleep infinity user: me - persistent-storage: + storage: - destination: /someplace owner: games - destination: /someplace-secret diff --git a/examples/storage/README.md b/examples/storage/README.md index 831f38da..daed23c5 100644 --- a/examples/storage/README.md +++ b/examples/storage/README.md @@ -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