Skip to content

Commit

Permalink
add user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVerrept committed Mar 7, 2024
1 parent ec32f6f commit e08895b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
import (
"context"
"crypto/x509"
"fmt"
"time"

"github.com/CudoVentures/terraform-provider-cudo/internal/compute/network"
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -204,16 +206,14 @@ 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) {
if a.key == "" {
return nil, nil
}
return map[string]string{
"x-terraform-version": a.version,
"authorization": "Bearer " + a.key,
"authorization": "Bearer " + a.key,
}, nil
}

Expand Down

0 comments on commit e08895b

Please sign in to comment.