From e08895be012e7b219279210cbf83375e1aafbbb8 Mon Sep 17 00:00:00 2001 From: ArthurVerrept Date: Thu, 7 Mar 2024 13:33:35 +0000 Subject: [PATCH] add user agent --- internal/provider/provider.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 5c6fd24..e5550d5 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -3,6 +3,7 @@ package provider import ( "context" "crypto/x509" + "fmt" "time" "github.com/CudoVentures/terraform-provider-cudo/internal/compute/network" @@ -143,10 +144,11 @@ func (p *CudoProvider) Configure(ctx context.Context, req provider.ConfigureRequ grpc.WithPerRPCCredentials(&apiKeyCallOption{ disableTransportSecurity: config.DisableTLS.ValueBool(), key: apiKey, - version: p.version, }), ) + dialOptions = append(dialOptions, grpc.WithUserAgent(fmt.Sprintf("cudo-terraform-client/%s", p.version))) + dialTimeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() @@ -204,7 +206,6 @@ func New(version string, defaultRemoteAddr string) func() provider.Provider { type apiKeyCallOption struct { key string disableTransportSecurity bool - version string } func (a *apiKeyCallOption) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { @@ -212,8 +213,7 @@ func (a *apiKeyCallOption) GetRequestMetadata(ctx context.Context, uri ...string return nil, nil } return map[string]string{ - "x-terraform-version": a.version, - "authorization": "Bearer " + a.key, + "authorization": "Bearer " + a.key, }, nil }