Add static user agent field (#54)
This commit is contained in:
@@ -126,9 +126,9 @@ type ProxyFunc func(req *http.Request) (*url.URL, error)
|
|||||||
type SystemInfo struct {
|
type SystemInfo struct {
|
||||||
// System is the name of the scale set implementation
|
// System is the name of the scale set implementation
|
||||||
System string `json:"system"`
|
System string `json:"system"`
|
||||||
// Version is the version of the controller
|
// Version is the version of the client
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
// CommitSHA is the git commit SHA of the controller
|
// CommitSHA is the git commit SHA of the client
|
||||||
CommitSHA string `json:"commit_sha"`
|
CommitSHA string `json:"commit_sha"`
|
||||||
// ScaleSetID is the ID of the scale set
|
// ScaleSetID is the ID of the scale set
|
||||||
ScaleSetID int `json:"scale_set_id"`
|
ScaleSetID int `json:"scale_set_id"`
|
||||||
@@ -222,6 +222,7 @@ type userAgent struct {
|
|||||||
SystemInfo
|
SystemInfo
|
||||||
BuildVersion string `json:"build_version"`
|
BuildVersion string `json:"build_version"`
|
||||||
BuildCommitSHA string `json:"build_commit_sha"`
|
BuildCommitSHA string `json:"build_commit_sha"`
|
||||||
|
Kind string `json:"kind"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) newGitHubAPIRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) {
|
func (c *Client) newGitHubAPIRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) {
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ func (c *commonClient) setUserAgent() {
|
|||||||
SystemInfo: c.systemInfo,
|
SystemInfo: c.systemInfo,
|
||||||
BuildVersion: buildInfo.version,
|
BuildVersion: buildInfo.version,
|
||||||
BuildCommitSHA: buildInfo.commitSHA,
|
BuildCommitSHA: buildInfo.commitSHA,
|
||||||
|
Kind: "scaleset",
|
||||||
})
|
})
|
||||||
c.userAgent = string(b)
|
c.userAgent = string(b)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ func TestUserAgent(t *testing.T) {
|
|||||||
SystemInfo: testSystemInfo,
|
SystemInfo: testSystemInfo,
|
||||||
BuildCommitSHA: sha,
|
BuildCommitSHA: sha,
|
||||||
BuildVersion: version,
|
BuildVersion: version,
|
||||||
|
Kind: "scaleset",
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(wantInfo)
|
b, err := json.Marshal(wantInfo)
|
||||||
require.NoError(t, err, "failed to marshal expected user agent")
|
require.NoError(t, err, "failed to marshal expected user agent")
|
||||||
@@ -144,6 +145,7 @@ func TestUserAgent(t *testing.T) {
|
|||||||
SystemInfo: userAgentInfo,
|
SystemInfo: userAgentInfo,
|
||||||
BuildCommitSHA: sha,
|
BuildCommitSHA: sha,
|
||||||
BuildVersion: version,
|
BuildVersion: version,
|
||||||
|
Kind: "scaleset",
|
||||||
}
|
}
|
||||||
b, err = json.Marshal(wantInfo)
|
b, err = json.Marshal(wantInfo)
|
||||||
require.NoError(t, err, "failed to marshal expected user agent after SetSystemInfo")
|
require.NoError(t, err, "failed to marshal expected user agent after SetSystemInfo")
|
||||||
|
|||||||
Reference in New Issue
Block a user