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

Add --on-demand and more verbosity when passing env flags #74

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions docs/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ lando pull --code=none --database=dev --files=none

# Attempt a pull using a different key and secret
lando pull --key "$ACQUIA_KEY" --secret "$ACQUIA_SECRET"

# Use the on-demand flag to generate a new database copy before pulling
lando pull --on-demand
```

#### Options
Expand All @@ -41,6 +44,7 @@ lando pull --key "$ACQUIA_KEY" --secret "$ACQUIA_SECRET"
--files, -f The environment from which to pull the files
--key An Acquia API key
--secret An Acquia API secret
--on-demand Generate a fresh database export when pulling the database
```

Please consult the manual import documentation below if this command produces an error.
Expand Down
4 changes: 4 additions & 0 deletions lib/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
level: 'app',
stdio: ['inherit', 'pipe', 'pipe'],
options: {
key: {

Check failure on line 42 in lib/pull.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-22.04, 16)

Inconsistently quoted property 'key' found
describe: 'An Acquia API key',
passthrough: true,
string: true,
Expand All @@ -51,12 +51,12 @@
weight: 100,
},
},
secret: {

Check failure on line 54 in lib/pull.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-22.04, 16)

Inconsistently quoted property 'secret' found
describe: 'An Acquia API secret',
passthrough: true,
password: true,
},
code: {

Check failure on line 59 in lib/pull.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-22.04, 16)

Inconsistently quoted property 'code' found
description: 'The environment from which to pull the code',
passthrough: true,
alias: ['c'],
Expand All @@ -66,7 +66,7 @@
weight: 200,
},
},
database: {

Check failure on line 69 in lib/pull.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-22.04, 16)

Inconsistently quoted property 'database' found
description: 'The environment from which to pull the database',
passthrough: true,
alias: ['d'],
Expand All @@ -76,7 +76,7 @@
weight: 300,
},
},
files: {

Check failure on line 79 in lib/pull.js

View workflow job for this annotation

GitHub Actions / lint (ubuntu-22.04, 16)

Inconsistently quoted property 'files' found
description: 'The environment from which to pull the files',
passthrough: true,
alias: ['f'],
Expand All @@ -86,6 +86,10 @@
weight: 400,
},
},
'on-demand': {
description: 'Generate a new backup of the database when pulling',
passthrough: true,
},
},
};

Expand Down
18 changes: 17 additions & 1 deletion scripts/acquia-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ while (( "$#" )); do
fi
;;
-c|--code|--code=*)
CODEFLAG=true
if [ "${1##--code=}" != "$1" ]; then
CODE="${1##--code=}"
shift
Expand All @@ -47,6 +48,7 @@ while (( "$#" )); do
fi
;;
-d|--database|--database=*)
DATABASEFLAG=true
if [ "${1##--database=}" != "$1" ]; then
DATABASE="${1##--database=}";
shift
Expand All @@ -56,6 +58,7 @@ while (( "$#" )); do
fi
;;
-f|--files|--files=*)
FILEFLAG=true
if [ "${1##--files=}" != "$1" ]; then
FILES="${1##--files=}"
shift
Expand All @@ -72,6 +75,10 @@ while (( "$#" )); do
NO_AUTH=true
shift
;;
--on-demand)
ON_DEMAND=" --on-demand"
shift
;;
--)
shift
break
Expand All @@ -94,11 +101,17 @@ fi

# Get the codez
if [ "$CODE" != "none" ]; then
if [ $CODEFLAG ]; then
echo -n "Using the code flag supplied to pull code from $CODE."
fi
acli -n pull:code "$AH_SITE_GROUP.$CODE"
fi

# Get the database
if [ "$DATABASE" != "none" ]; then
if [ $DATABASEFLAG ]; then
echo -n "Using the database flag supplied to pull the database from $DATABASE."
fi
# Destroy existing tables
# NOTE: We do this so the source DB **EXACTLY MATCHES** the target DB
TABLES=$(mysql --user=acquia --password=acquia --database=acquia --host=database --port=3306 -e 'SHOW TABLES' | awk '{ print $1}' | grep -v '^Tables' ) || true
Expand All @@ -115,7 +128,7 @@ EOF
done

# Importing database
acli -n pull:db "$AH_SITE_GROUP.$DATABASE"
acli -n pull:db "$AH_SITE_GROUP.$DATABASE"$ON_DEMAND

# Weak check that we got tables
PULL_DB_CHECK_TABLE=${LANDO_DB_USER_TABLE:-users}
Expand All @@ -129,6 +142,9 @@ fi

# Get the files
if [ "$FILES" != "none" ]; then
if [ $FILESFLAG ]; then
echo -n "Using the files flag supplied to pull files from $FILES."
fi
# acli -n pull:files "$FILES" -> non interactive causes a broken pipe error right now
acli -n pull:files "$AH_SITE_GROUP.$FILES"
fi
Expand Down
Loading