Skip to content

Commit

Permalink
Set version for cloud User-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
deferred committed Jan 21, 2025
1 parent c82d04f commit 38f2454
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ builds:
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
- '-s -w -X github.com/terraform-providers/terraform-provider-gcore/gcore.AppVersion={{ .Version }}'
goos:
- windows
- linux
Expand Down
4 changes: 4 additions & 0 deletions gcore/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ const (
ProviderOptPermanentToken = "permanent_api_token"
ProviderOptSkipCredsAuthErr = "ignore_creds_auth_error"
ProviderOptSingleApiEndpoint = "api_endpoint"
DefaultCloudUserAgent = "cloud-api-terraform/%s"

lifecyclePolicyResource = "gcore_lifecyclepolicy"
)

var AppVersion = "dev"

func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -275,6 +278,7 @@ func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{},
provider = &gcorecloud.ProviderClient{}
log.Printf("[ERROR] init auth client: %s\n", err)
}
provider.UserAgent.Prepend(fmt.Sprintf(DefaultCloudUserAgent, AppVersion))

cdnProvider := gcdnProvider.NewClient(cdnAPI, gcdnProvider.WithSignerFunc(func(req *http.Request) error {
for k, v := range provider.AuthenticatedHeaders() {
Expand Down

0 comments on commit 38f2454

Please sign in to comment.