Skip to content

Commit

Permalink
Merge pull request #18 from Mattias-/ref-user-agent
Browse files Browse the repository at this point in the history
Move user agent to provider
  • Loading branch information
Mattias Appelgren authored Dec 3, 2020
2 parents d46f355 + af18e23 commit f8a4a32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 2 additions & 5 deletions buildkite/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ import (

"github.com/machinebox/graphql"
"github.com/pkg/errors"

"github.com/tink-ab/terraform-provider-buildkite/buildkite/version"
)

const (
defaultBaseURL = "https://api.buildkite.com/"
defaultGraphQLUrl = "https://graphql.buildkite.com/v1"
userAgent = "terraform-provider-buildkite/"
applicationJsonContentType = "application/json"
)

Expand All @@ -32,8 +29,8 @@ type Client struct {
apiToken string
}

func NewClient(orgSlug string, apiToken string) *Client {
var authTransport http.RoundTripper = NewAuthTransport(apiToken, userAgent+version.Version, nil)
func NewClient(orgSlug string, apiToken string, userAgent string) *Client {
var authTransport http.RoundTripper = NewAuthTransport(apiToken, userAgent, nil)
baseURL, _ := url.Parse(defaultBaseURL)

return &Client{
Expand Down
6 changes: 5 additions & 1 deletion buildkite/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"github.com/tink-ab/terraform-provider-buildkite/buildkite/version"
)

const (
userAgent = "terraform-provider-buildkite/"
)

func Provider() *schema.Provider {
log.Printf("[DEBUG] Buildkite provider version %s", version.Version)
return &schema.Provider{
Expand Down Expand Up @@ -45,5 +49,5 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
orgName := d.Get("organization").(string)
apiToken := d.Get("api_token").(string)

return client.NewClient(orgName, apiToken), nil
return client.NewClient(orgName, apiToken, userAgent+version.Version), nil
}

0 comments on commit f8a4a32

Please sign in to comment.