From 329b0065052242ec7674656f04f2eb37f1a9512c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Czoma?= Date: Mon, 8 Jul 2024 14:50:28 -0400 Subject: [PATCH] Release 1.0.1 (#75) fixes issue #74 * Fix provider fail if broker credentials are provided in env variables --- .github/workflows/provider-test-pipeline.yml | 7 +++++++ ci/broker_vpn_test2/test.tf | 15 +++++++++++++++ internal/broker/utilities.go | 7 ++++--- version.go | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 ci/broker_vpn_test2/test.tf diff --git a/.github/workflows/provider-test-pipeline.yml b/.github/workflows/provider-test-pipeline.yml index dc193262..70c463ae 100644 --- a/.github/workflows/provider-test-pipeline.yml +++ b/.github/workflows/provider-test-pipeline.yml @@ -69,6 +69,13 @@ jobs: terraform import solacebroker_msg_vpn.newone new popd + - name: Test provider params from env + run: | + pushd ci/broker_vpn_test2 + SOLACEBROKER_USERNAME=admin SOLACEBROKER_PASSWORD=admin terraform apply -auto-approve + SOLACEBROKER_BEARER_TOKEN=abc terraform apply -auto-approve | grep 401 + popd + - name: Test broker object attributes override run: | pushd ci/brokertest diff --git a/ci/broker_vpn_test2/test.tf b/ci/broker_vpn_test2/test.tf new file mode 100644 index 00000000..07a1c4cd --- /dev/null +++ b/ci/broker_vpn_test2/test.tf @@ -0,0 +1,15 @@ +terraform { + required_providers { + solacebroker = { + source = "registry.terraform.io/solaceproducts/solacebroker" + } + } +} + +provider solacebroker { + url = "http://localhost:8080" +} + +resource "solacebroker_msg_vpn" "test" { + msg_vpn_name = "test" +} \ No newline at end of file diff --git a/internal/broker/utilities.go b/internal/broker/utilities.go index bc4c83bc..64252268 100644 --- a/internal/broker/utilities.go +++ b/internal/broker/utilities.go @@ -149,16 +149,17 @@ func client(providerData *providerData) (*semp.Client, diag.Diagnostic) { password = providerData.Password.ValueString() bearerToken = providerData.BearerToken.ValueString() } else { + var err error // username, password and bearer token will be set to "" if not provided through env or config - username, err := stringWithDefaultFromEnv(providerData.Username, "username") + username, err = stringWithDefaultFromEnv(providerData.Username, "username") if err != nil { return nil, diag.NewErrorDiagnostic("Unable to parse provider attribute", err.Error()) } - password, err := stringWithDefaultFromEnv(providerData.Password, "password") + password, err = stringWithDefaultFromEnv(providerData.Password, "password") if err != nil { return nil, diag.NewErrorDiagnostic("Unable to parse provider attribute", err.Error()) } - bearerToken, err := stringWithDefaultFromEnv(providerData.BearerToken, "bearer_token") + bearerToken, err = stringWithDefaultFromEnv(providerData.BearerToken, "bearer_token") if err != nil { return nil, diag.NewErrorDiagnostic("Unable to parse provider attribute", err.Error()) } diff --git a/version.go b/version.go index 32b7b201..b6d02509 100644 --- a/version.go +++ b/version.go @@ -16,4 +16,4 @@ package main -const version = "1.0.0" +const version = "1.0.1"