Skip to content

Commit 8d1e81f

Browse files
authored
Merge pull request #13 from jetstack/user-agent
Client: add the user-agent header
2 parents eb28ec9 + 610f9e6 commit 8d1e81f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (p *tlspcProvider) Configure(ctx context.Context, req provider.ConfigureReq
7474
endpoint = config.Endpoint.ValueString()
7575
}
7676

77-
client, _ := tlspc.NewClient(apikey, endpoint)
77+
client, _ := tlspc.NewClient(apikey, endpoint, p.version)
7878

7979
resp.DataSourceData = client
8080
resp.ResourceData = client

internal/tlspc/tlspc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ const DefaultEndpoint = "https://api.venafi.cloud"
1717
type Client struct {
1818
apikey string
1919
endpoint string
20+
version string
2021
}
2122

22-
func NewClient(apikey, endpoint string) (*Client, error) {
23+
func NewClient(apikey, endpoint, version string) (*Client, error) {
2324
if endpoint == "" {
2425
endpoint = DefaultEndpoint
2526
}
2627

2728
return &Client{
2829
apikey: apikey,
2930
endpoint: endpoint,
31+
version: version,
3032
}, nil
3133
}
3234

@@ -37,6 +39,7 @@ func (c *Client) doRequest(method, path string, body []byte) (*http.Response, er
3739
}
3840
req.Header.Set("Content-Type", "application/json")
3941
req.Header.Set("tppl-api-key", c.apikey)
42+
req.Header.Set("User-Agent", "terraform-provider-tlspc/"+c.version)
4043

4144
client := http.Client{}
4245
return client.Do(req)

0 commit comments

Comments
 (0)