Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug causing service script loading collisions #317

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

* Fixed bug causing service script loading collisions

## v3.23.22 - [December 17, 2024](https://github.com/lando/core/releases/tag/v3.23.22)

* Added ability to customize `networkLimit` [#245](https://github.com/lando/core/pull/245)
Expand Down
23 changes: 17 additions & 6 deletions builders/_lando.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
refreshCerts = false,
remoteFiles = {},
scripts = [],
scriptsDir = '',
sport = '443',
ssl = false,
sslExpose = true,
Expand All @@ -66,16 +67,23 @@ module.exports = {
console.error(color.yellow(`${type} version ${version} is a legacy version! We recommend upgrading.`));
}

// normalize scripts dir if needed
if (!path.isAbsolute(scriptsDir)) scriptsDir = path.resolve(root, scriptsDir);

// Get some basic locations
const globalScriptsDir = path.join(userConfRoot, 'scripts');
const serviceScriptsDir = path.join(userConfRoot, 'helpers', project, type, name);
const entrypointScript = path.join(globalScriptsDir, 'lando-entrypoint.sh');
const addCertsScript = path.join(globalScriptsDir, 'add-cert.sh');
const refreshCertsScript = path.join(globalScriptsDir, 'refresh-certs.sh');

// Move our config into the userconfroot if we have some
// NOTE: we need to do this because on macOS and Windows not all host files
// are shared into the docker vm
if (fs.existsSync(confSrc)) require('../utils/move-config')(confSrc, confDest);

// Get some basic locations
const scriptsDir = path.join(userConfRoot, 'scripts');
const entrypointScript = path.join(scriptsDir, 'lando-entrypoint.sh');
const addCertsScript = path.join(scriptsDir, 'add-cert.sh');
const refreshCertsScript = path.join(scriptsDir, 'refresh-certs.sh');
// ditto for service helpers
if (fs.existsSync(scriptsDir)) require('../utils/move-config')(scriptsDir, serviceScriptsDir);

// Handle Environment
const environment = {
Expand All @@ -94,11 +102,14 @@ module.exports = {
// Handle volumes
const volumes = [
`${userConfRoot}:/lando:cached`,
`${scriptsDir}:/helpers`,
`${globalScriptsDir}:/helpers`,
`${entrypointScript}:/lando-entrypoint.sh`,
`${dataHome}:/var/www`,
];

// add in service helpers if we have them
if (fs.existsSync(serviceScriptsDir)) volumes.push(`${serviceScriptsDir}:/etc/lando/service/helpers`);

// Handle ssl
if (ssl) {
// also expose the sport
Expand Down
14 changes: 14 additions & 0 deletions examples/tooling/.lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
api: 3
type: lando
meUser: node
scriptsDir: scripts
services:
image: node:16
command: docker-entrypoint.sh tail -f /dev/null
Expand Down Expand Up @@ -261,6 +262,19 @@ tooling:
arg2:
describe: Uses arg2
type: string
sdargs:
cmd: /etc/lando/service/helpers/args.sh
service: node
positionals:
arg1:
describe: Uses arg1
type: string
choices:
- thing
- stuff
arg2:
describe: Uses arg2
type: string

plugins:
"@lando/core": "../.."
4 changes: 4 additions & 0 deletions examples/tooling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ lando everything --help | grep "lando everything \[arg1\] \[arg2\] MORETHINGS"
# Should allow for example pasthru in task definition
lando everything --help | grep "lando this is just for testing"

# Should be able to access scriptsDir from the landofile
lando exec node -- stat /etc/lando/service/helpers/args.sh
lando sdargs hello there | grep "hello there"

# Should be able to run even if options are empty
lando emptyopter

Expand Down
3 changes: 3 additions & 0 deletions examples/tooling/scripts/args.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "$1 $2"
1 change: 1 addition & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"https://docs.google.com/document",
"https://docs.google.com/forms",
"https://github.com",
"https://www.drupal.org/community/events",
"/v/"
]
skipPatterns = [
Expand Down
Loading