Skip to content

Commit

Permalink
Merge pull request #17 from trocco-io/set-ua
Browse files Browse the repository at this point in the history
add fixed user-agent
  • Loading branch information
katamotokosuke authored Dec 2, 2024
2 parents 3679d30 + f5eefea commit 7814231
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ builds:
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
- '-s -w -X github.com/trocco-io/terraform-provider-trocco/version.ProviderVersion={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
Expand Down
2 changes: 2 additions & 0 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
version2 "terraform-provider-trocco/version"
)

const (
Expand Down Expand Up @@ -88,6 +89,7 @@ func (client *TroccoClient) do(
req.Header.Set("Authorization", "Token "+client.APIKey)
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "terraform-provider-trocco "+version2.ProviderVersion)
resp, err := client.httpClient.Do(req)
if err != nil {
return err
Expand Down
12 changes: 2 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"flag"
"log"
"terraform-provider-trocco/version"

"github.com/hashicorp/terraform-plugin-framework/providerserver"
"terraform-provider-trocco/internal/provider"
Expand All @@ -19,15 +20,6 @@ import (
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name trocco

var (
// these will be set by the goreleaser configuration
// to appropriate values for the compiled binary.
version string = "dev"

// goreleaser can pass other information to the main package, such as the specific commit
// https://goreleaser.com/cookbooks/using-main.version/
)

func main() {
var debug bool

Expand All @@ -39,7 +31,7 @@ func main() {
Debug: debug,
}

err := providerserver.Serve(context.Background(), provider.New(version), opts)
err := providerserver.Serve(context.Background(), provider.New(version.ProviderVersion), opts)

if err != nil {
log.Fatal(err.Error())
Expand Down
4 changes: 4 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package version

// Variables injected by ldflags.
var ProviderVersion string

0 comments on commit 7814231

Please sign in to comment.