From a88127a0ba3dd2dadf2be2518b88f3d5ea119f16 Mon Sep 17 00:00:00 2001 From: akmal-spacelift <164946548+akmal-spacelift@users.noreply.github.com> Date: Tue, 17 Sep 2024 18:41:41 -0700 Subject: [PATCH] fix: handle trailing slash at end of API endpoint Updated the code that builds the URL for the GraphQL API to handle the situation where the `api_key_endpoint` setting includes a trailing `/`. --- spacelift/provider.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spacelift/provider.go b/spacelift/provider.go index f67a3544..98094334 100644 --- a/spacelift/provider.go +++ b/spacelift/provider.go @@ -225,7 +225,11 @@ func buildClientFromToken(token string) (*internal.Client, error) { func buildClientFromAPIKeyData(d *schema.ResourceData) (*internal.Client, error) { // Since validation runs first, we can safely assume that the data is there. - endpoint := fmt.Sprintf("%s/graphql", d.Get("api_key_endpoint").(string)) + + // Handle / at api_key_endpoint + endpoint := strings.TrimSuffix(d.Get("api_key_endpoint").(string), "/") + endpoint = fmt.Sprintf("%s/graphql", endpoint) + apiKeyID := d.Get("api_key_id").(string) apiKeySecret := d.Get("api_key_secret").(string)