Skip to content

Commit 154ce87

Browse files
authored
Merge pull request #121 from OpenVPN/fix/provider-crash-invalid-url
Improve error handling in CloudConnexa client
2 parents 4d5efbc + f6d98d6 commit 154ce87

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cloudconnexa/provider.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cloudconnexa
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa"
78

89
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -117,15 +118,15 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
117118
baseUrl = "https://" + cloudId + ".api.openvpn.com"
118119
}
119120
cloudConnexaClient, err := cloudconnexa.NewClient(baseUrl, clientId, clientSecret)
120-
cloudConnexaClient.UserAgent = fmt.Sprintf("terraform-provider-cloudconnexa/%v", version)
121121
var diags diag.Diagnostics
122122
if err != nil {
123123
diags = append(diags, diag.Diagnostic{
124124
Severity: diag.Error,
125-
Summary: "Unable to create client",
126-
Detail: fmt.Sprintf("Error: %v", err),
125+
Summary: "Unable to create CloudConnexa client",
126+
Detail: fmt.Sprintf("Failed to create CloudConnexa client with base URL '%s': %v", baseUrl, err),
127127
})
128128
return nil, diags
129129
}
130+
cloudConnexaClient.UserAgent = fmt.Sprintf("terraform-provider-cloudconnexa/%v", version)
130131
return cloudConnexaClient, nil
131132
}

0 commit comments

Comments
 (0)