uselagoon / lagoon-sync

Apache License 2.0
7 stars 5 forks source link

Reduce verbosity of output #106

Open rocketeerbkw opened 1 year ago

rocketeerbkw commented 1 year ago

A sync command will, by default, print out a lot of information that is not strictly necessary:

Project: amazeeio-example - you are about to sync mariadb from main to local, is this correct: y
[INFO]  2023/09/30 22:12:58 Running prerequisite checks on main
[INFO]  2023/09/30 22:12:58 Running the following prerequisite command ssh -tt -o LogLevel=FATAL -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 32222 amazeeio-example-main@ssh.lagoon.amazeeio.cloud service=cli '/usr/local/bin/lagoon-sync config || true'
[INFO]  2023/09/30 22:13:07 Beginning export on source environment main
[INFO]  2023/09/30 22:13:07 Running the following for source ssh -tt -o LogLevel=FATAL -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 32222 amazeeio-example-main@ssh.lagoon.amazeeio.cloud service=cli 'mysqldump --max-allowed-packet=500M --quick --add-locks --no-autocommit --single-transaction -h${MARIADB_HOST:-mariadb} -u${MARIADB_USERNAME:-drupal} -p${MARIADB_PASSWORD:-drupal} -P${MARIADB_PORT:-3306}  ${MARIADB_DATABASE:-drupal} > /tmp/lagoon_sync_mariadb_1696111977136711577.sql'
[INFO]  2023/09/30 22:13:17 Running the following for source ssh -tt -o LogLevel=FATAL -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 32222 amazeeio-example-main@ssh.lagoon.amazeeio.cloud service=cli 'gzip /tmp/lagoon_sync_mariadb_1696111977136711577.sql'
[INFO]  2023/09/30 22:13:26 Running prerequisite checks on local
[INFO]  2023/09/30 22:13:26 Running the following prerequisite command /usr/local/bin/lagoon-sync config || true
[INFO]  2023/09/30 22:13:26 Beginning file transfer logic
[INFO]  2023/09/30 22:13:26 Running the following for target (local) /usr/bin/rsync --omit-dir-times --no-perms --no-group --no-owner --chmod=ugo=rwX --recursive --compress --rsync-path=/usr/bin/rsync  -e "ssh -o LogLevel=FATAL -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 32222 -l amazeeio-example-main ssh.lagoon.amazeeio.cloud service=cli"   :/tmp/lagoon_sync_mariadb_1696111977136711577.sql.gz /tmp/lagoon_sync_mariadb_1696111977136711577.sql.gz
[INFO]  2023/09/30 22:13:37 Beginning import on target environment local
[INFO]  2023/09/30 22:13:37 Running the following for target (local) gunzip /tmp/lagoon_sync_mariadb_1696111977136711577.sql.gz
[INFO]  2023/09/30 22:13:37 Running the following for target (local) mysql -h${MARIADB_HOST:-mariadb} -u${MARIADB_USERNAME:-drupal} -p${MARIADB_PASSWORD:-drupal} -P${MARIADB_PORT:-3306} ${MARIADB_DATABASE:-drupal} < /tmp/lagoon_sync_mariadb_1696111977136711577.sql
[INFO]  2023/09/30 22:13:38 Beginning resource cleanup on main
[INFO]  2023/09/30 22:13:38 Running the following ssh -tt -o LogLevel=FATAL -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 32222 amazeeio-example-main@ssh.lagoon.amazeeio.cloud service=cli 'rm -r /tmp/lagoon_sync_mariadb_1696111977136711577.sql.gz || true'
[INFO]  2023/09/30 22:13:47 Running the following ssh -tt -o LogLevel=FATAL -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 32222 amazeeio-example-main@ssh.lagoon.amazeeio.cloud service=cli 'rm -r /tmp/lagoon_sync_mariadb_1696111977136711577.sql || true'
[INFO]  2023/09/30 22:13:55 Beginning resource cleanup on local
[INFO]  2023/09/30 22:13:55 Running the following rm -r /tmp/lagoon_sync_mariadb_1696111977136711577.sql.gz || true
[INFO]  2023/09/30 22:13:55 Running the following rm -r /tmp/lagoon_sync_mariadb_1696111977136711577.sql || true
2023/09/30 22:13:55 
------
Successful sync of mariadb from amazeeio-example-main to amazeeio-example-local
------

There are two use cases to consider: 1) A normal user running this manually and 2) An integration that runs this automatically. In case (1) a user probably doesn't need so much information but the basic "starting > done/fail". In case (2) there should be a --quiet option for just errors (or maybe that applies in the --no-interaction case?

Some prior art is having a -v flag where each additional v increases the verbosity.