canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #03486
[Merge] ~hyask/autopkgtest-cloud:skia/yaml-dump into autopkgtest-cloud:master
Skia has proposed merging ~hyask/autopkgtest-cloud:skia/yaml-dump into autopkgtest-cloud:master.
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
Related bugs:
Bug #2058558 in Auto Package Testing: "dump-lxd-remotes does not produce a usable yaml file"
https://bugs.launchpad.net/auto-package-testing/+bug/2058558
For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/462858
Fixes `dump-lxd-remotes` by introducing a generic `yaml-dump` that produces valid output.
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/yaml-dump into autopkgtest-cloud:master.
diff --git a/mojo/dump-lxd-remotes b/mojo/dump-lxd-remotes
index e0f1a56..0ef7a9c 100755
--- a/mojo/dump-lxd-remotes
+++ b/mojo/dump-lxd-remotes
@@ -1,5 +1,3 @@
#!/usr/bin/bash
-echo '# Use this like that:' > ~/lxd-remotes.yaml
-echo '# juju config autopkgtest-lxd-worker --file=~/lxd-remotes.yaml' >> ~/lxd-remotes.yaml
-juju config autopkgtest-lxd-worker lxd-remotes >> ~/lxd-remotes.yaml
+"$(dirname "$0")/yaml-dump" autopkgtest-lxd-worker lxd-remotes
diff --git a/mojo/yaml-dump b/mojo/yaml-dump
new file mode 100755
index 0000000..c03ecfa
--- /dev/null
+++ b/mojo/yaml-dump
@@ -0,0 +1,27 @@
+#!/usr/bin/bash
+
+set -e
+
+APP_NAME="$1"
+CONFIG_KEY="$2"
+
+if [ "$APP_NAME" = "" ] || [ "$CONFIG_KEY" = "" ]; then
+ echo "Usage: $0 <juju_appname> <app_config_key>"
+ exit 2
+fi
+
+OUTPUT_FILE=~/"${APP_NAME}_${CONFIG_KEY}.yaml"
+
+if ! juju config "$APP_NAME" "$CONFIG_KEY" >/dev/null; then
+ echo "Bad juju app name or config key"
+ exit 1
+fi
+
+{
+ echo "# Use this like that:"
+ echo "# juju config $APP_NAME --file=$OUTPUT_FILE"
+ echo "$APP_NAME:"
+ echo " $CONFIG_KEY: |-"
+
+ juju config "$APP_NAME" "$CONFIG_KEY" | sed 's/^/ /'
+} > "$OUTPUT_FILE"