Skip to content

Commit

Permalink
feat: adds user-agent header with useful client info
Browse files Browse the repository at this point in the history
  • Loading branch information
mega-alex committed May 14, 2024
1 parent c6b705c commit 10fd37c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"runtime"
"strings"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand Down Expand Up @@ -218,7 +219,8 @@ func (p *megaportProvider) Configure(ctx context.Context, req provider.Configure
return
}

// TODO: potentially pipe the output of the megaport logger to the tflog package
// Build a useragent string with some useful infromation about the client
userAgent := fmt.Sprintf("Terraform/%s terraform-provider-megaport/%s go/%s (%s %s)", req.TerraformVersion, p.version, runtime.Version(), runtime.GOOS, runtime.GOARCH)

megaportClient, err := megaport.New(nil,
megaport.WithEnvironment(megaportGoEnv),
Expand All @@ -227,6 +229,7 @@ func (p *megaportProvider) Configure(ctx context.Context, req provider.Configure
megaport.WithCustomHeaders(map[string]string{
"x-app": "terraform",
}),
megaport.WithUserAgent(userAgent),
)
if err != nil {
resp.Diagnostics.AddError(
Expand Down

0 comments on commit 10fd37c

Please # to comment.