diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 24b142f..7d03460 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -158,7 +158,14 @@ func (p *PlanetScaleProvider) Configure(ctx context.Context, req provider.Config return } - client := planetscale.NewClient(&http.Client{Transport: rt}, baseURL) + client := planetscale.NewClient( + &http.Client{ + Transport: roundTripperFunc(func(r *http.Request) (*http.Response, error) { + r.Header.Set("User-Agent", "PlanetScale_Terraform_Provider/"+p.version+" (Terraform "+req.TerraformVersion+")") + return rt.RoundTrip(r) + }), + }, baseURL, + ) resp.DataSourceData = client resp.ResourceData = client diff --git a/main.go b/main.go index a4edf76..7867d5f 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "context" "flag" "log" + "os" "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/planetscale/terraform-provider-planetscale/internal/provider" @@ -44,7 +45,8 @@ func main() { Debug: debug, } - err := providerserver.Serve(context.Background(), provider.New(version, debug), opts) + debugProvider := os.Getenv("TF_PS_PROVIDER_DEBUG") != "" + err := providerserver.Serve(context.Background(), provider.New(version, debug || debugProvider), opts) if err != nil { log.Fatal(err.Error())