diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index f5972a65..21f80723 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -74,14 +74,14 @@ jobs: # language=bash run: | CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_AGENT_VERSION=$(juju show-controller | yq .$CONTROLLER.details.agent-version |tr -d '"')" >> $GITHUB_ENV - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + + cat << EOF >> $GITHUB_ENV + JUJU_AGENT_VERSION=$(juju show-controller | yq -r .$CONTROLLER.details.\"agent-version\") + JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.\"api-endpoints\" | yq -r '. | join(",")') + JUJU_USERNAME=$(juju show-controller | yq -r .$CONTROLLER.account.user) + JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq -r .controllers.$CONTROLLER.password) + JUJU_CA_CERT=$(juju show-controller | yq -r .$CONTROLLER.details.\"ca-cert\") + EOF - env: TF_ACC: "1" TEST_CLOUD: ${{ matrix.cloud }} diff --git a/.github/workflows/test_add_machine.yml b/.github/workflows/test_add_machine.yml index b6d06295..6b1b0f61 100644 --- a/.github/workflows/test_add_machine.yml +++ b/.github/workflows/test_add_machine.yml @@ -78,14 +78,14 @@ jobs: # language=bash run: | CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_AGENT_VERSION=$(juju show-controller | yq .$CONTROLLER.details.agent-version |tr -d '"')" >> $GITHUB_ENV - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + + cat << EOF >> $GITHUB_ENV + JUJU_AGENT_VERSION=$(juju show-controller | yq -r .$CONTROLLER.details.\"agent-version\") + JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.\"api-endpoints\" | yq -r '. | join(",")') + JUJU_USERNAME=$(juju show-controller | yq -r .$CONTROLLER.account.user) + JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq -r .controllers.$CONTROLLER.password) + JUJU_CA_CERT=$(juju show-controller | yq -r .$CONTROLLER.details.\"ca-cert\") + EOF - run: go mod download - name: Create a new machine on lxd run: | diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml index 317397b2..1bfd1e6c 100644 --- a/.github/workflows/test_integration.yml +++ b/.github/workflows/test_integration.yml @@ -85,18 +85,21 @@ jobs: sudo lxc network create public-br ipv4.address=10.170.80.1/24 ipv4.nat=true ipv6.address=none ipv6.nat=false - name: "Set environment to configure provider" # language=bash - run: | + run: | CONTROLLER=$(juju whoami --format yaml | yq .controller) + + cat << EOF >> $GITHUB_ENV + JUJU_AGENT_VERSION=$(juju show-controller | yq -r .$CONTROLLER.details.\"agent-version\") + JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.\"api-endpoints\" | yq -r '. | join(",")') + JUJU_USERNAME=$(juju show-controller | yq -r .$CONTROLLER.account.user) + JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq -r .controllers.$CONTROLLER.password) + JUJU_CA_CERT=$(juju show-controller | yq -r .$CONTROLLER.details.\"ca-cert\") + + TEST_MANAGEMENT_BR=10.150.40.0/24 + TEST_PUBLIC_BR=10.170.80.0/24 + EOF + - echo "JUJU_AGENT_VERSION=$(juju show-controller | yq .$CONTROLLER.details.agent-version |tr -d '"')" >> $GITHUB_ENV - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - echo "TEST_MANAGEMENT_BR=10.150.40.0/24" >> $GITHUB_ENV - echo "TEST_PUBLIC_BR=10.170.80.0/24" >> $GITHUB_ENV - name: "Set additional environment for LXD" if: ${{ matrix.action-operator.cloud == 'lxd' }} # language=bash diff --git a/.github/workflows/test_integration_jaas.yaml b/.github/workflows/test_integration_jaas.yaml index 6209005c..971acf21 100644 --- a/.github/workflows/test_integration_jaas.yaml +++ b/.github/workflows/test_integration_jaas.yaml @@ -83,16 +83,23 @@ jobs: run: | CONTROLLER=$(juju whoami --format yaml | yq .controller) - echo "IS_JAAS=true" >> $GITHUB_ENV - echo "JUJU_AGENT_VERSION=$(juju show-controller | yq .$CONTROLLER.details.agent-version |tr -d '"')" >> $GITHUB_ENV - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_CLIENT_ID=${{ steps.jaas.outputs.client-id }}" >> $GITHUB_ENV - echo "JUJU_CLIENT_SECRET=${{ steps.jaas.outputs.client-secret }}" >> $GITHUB_ENV + cat << EOF >> $GITHUB_ENV + IS_JAAS=true + + JUJU_AGENT_VERSION=$(juju show-controller | yq -r .$CONTROLLER.details.\"agent-version\") + JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.\"api-endpoints\" | yq -r '. | join(",")') + JUJU_USERNAME=$(juju show-controller | yq -r .$CONTROLLER.account.user) + JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq -r .controllers.$CONTROLLER.password) + JUJU_CLIENT_ID=${{ steps.jaas.outputs.client-id }} + JUJU_CLIENT_SECRET=${{ steps.jaas.outputs.client-secret }} + + TEST_MANAGEMENT_BR=10.150.40.0/24 + TEST_PUBLIC_BR=10.170.80.0/24 + EOF + echo "JUJU_CA_CERT<> $GITHUB_ENV echo "${{ steps.jaas.outputs.ca-cert }}" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - echo "TEST_MANAGEMENT_BR=10.150.40.0/24" >> $GITHUB_ENV - echo "TEST_PUBLIC_BR=10.170.80.0/24" >> $GITHUB_ENV - run: go mod download - env: TF_ACC: "1" diff --git a/docs/index.md b/docs/index.md index 7ec2656e..e9dcf2fd 100644 --- a/docs/index.md +++ b/docs/index.md @@ -74,11 +74,11 @@ provider "juju" { Define the Juju controller credentials in the provider definition via environment variables. These can be set up as follows: ```shell -export CONTROLLER=$(juju whoami | yq .Controller) -export JUJU_CONTROLLER_ADDRESSES="$(juju show-controller | yq '.[$CONTROLLER]'.details.\"api-endpoints\" | tr -d "[]' "|tr -d '"'|tr -d '\n')" -export JUJU_USERNAME="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.user|tr -d '"')" -export JUJU_PASSWORD="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password|tr -d '"')" -export JUJU_CA_CERT="$(juju show-controller $(echo $CONTROLLER|tr -d '"') | yq '.[$CONTROLLER]'.details.\"ca-cert\"|tr -d '"'|sed 's/\\n/\n/g')" +export CONTROLLER=$(juju whoami --format yaml | yq .controller) +export JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.\"api-endpoints\" | yq -r '. | join(",")') +export JUJU_USERNAME=$(juju show-controller | yq -r .$CONTROLLER.account.user) +export JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq -r .controllers.$CONTROLLER.password) +export JUJU_CA_CERT=$(juju show-controller | yq -r .$CONTROLLER.details.\"ca-cert\") ``` ### Populated by the provider via the juju CLI client. diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index a98b9a50..89e9ccb8 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -74,11 +74,11 @@ provider "juju" { Define the Juju controller credentials in the provider definition via environment variables. These can be set up as follows: ```shell -export CONTROLLER=$(juju whoami | yq .Controller) -export JUJU_CONTROLLER_ADDRESSES="$(juju show-controller | yq '.[$CONTROLLER]'.details.\"api-endpoints\" | tr -d "[]' "|tr -d '"'|tr -d '\n')" -export JUJU_USERNAME="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.user|tr -d '"')" -export JUJU_PASSWORD="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password|tr -d '"')" -export JUJU_CA_CERT="$(juju show-controller $(echo $CONTROLLER|tr -d '"') | yq '.[$CONTROLLER]'.details.\"ca-cert\"|tr -d '"'|sed 's/\\n/\n/g')" +export CONTROLLER=$(juju whoami --format yaml | yq .controller) +export JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.\"api-endpoints\" | yq -r '. | join(",")') +export JUJU_USERNAME=$(juju show-controller | yq -r .$CONTROLLER.account.user) +export JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq -r .controllers.$CONTROLLER.password) +export JUJU_CA_CERT=$(juju show-controller | yq -r .$CONTROLLER.details.\"ca-cert\") ``` ### Populated by the provider via the juju CLI client.