Skip to content

Commit

Permalink
fix: handle trailing slash at end of API endpoint
Browse files Browse the repository at this point in the history
Updated the code that builds the URL for the GraphQL API to handle the situation where the `api_key_endpoint` setting includes a trailing `/`.
  • Loading branch information
akmal-spacelift authored and adamconnelly committed Sep 23, 2024
1 parent bf3e9c1 commit cfca310
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spacelift/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit cfca310

Please sign in to comment.