From bbb3235d854f96d4006a9891c3098d74991ff460 Mon Sep 17 00:00:00 2001 From: Zhang Hua Date: Thu, 19 Sep 2024 11:07:47 +0800 Subject: [PATCH] The command 'juju show-cloud' does not support JSON format The PR #228 [1] changed to use jq instead of sed to parse yaml when relocating two lines. However, yaml format is not supported in versions prior to juju 3.x. $ juju show-cloud localhost --format json ERROR invalid value "json" for option --format: unknown format "json" Therefore, we need to revert back to the previous two lines to support both juju 2.x and juju 3.x simultaneously. [1] https://github.com/canonical/stsstack-bundles/pull/228 --- common/helpers | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/helpers b/common/helpers index de79b015..d3b7aa80 100644 --- a/common/helpers +++ b/common/helpers @@ -45,8 +45,8 @@ list_overlays () get_cloud_type () { - local cloud=$(juju show-model --format json |jq -r '[.[].cloud] | unique[]') - local type=$(juju show-cloud $cloud --format json | jq -r '[.[].type] | unique[]') + local cloud=`juju show-model| sed -rn 's/.+cloud:\s*(.+).*/\1/p'| uniq` + local type=`juju show-cloud $cloud| sed -rn 's/^type:\s*(.+).*/\1/p'| uniq` echo "$type" }