Skip to content

Commit

Permalink
Release 1.0.1 (#75) fixes issue #74
Browse files Browse the repository at this point in the history
* Fix provider fail if broker credentials are provided in env variables
  • Loading branch information
bczoma authored Jul 8, 2024
1 parent c33ca33 commit 329b006
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/provider-test-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions ci/broker_vpn_test2/test.tf
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 4 additions & 3 deletions internal/broker/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

package main

const version = "1.0.0"
const version = "1.0.1"

0 comments on commit 329b006

Please sign in to comment.