diff --git a/github/github.go b/github/github.go index d8d0acf6..6def3f50 100644 --- a/github/github.go +++ b/github/github.go @@ -51,7 +51,6 @@ type BasicAuthTransport struct { func (p BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error) { req.SetBasicAuth(p.Username, p.Password) - req.Header.Set("User-Agent", "actions-runner-controller") return http.DefaultTransport.RoundTrip(req) } @@ -136,6 +135,8 @@ func (c *Config) NewClient() (*Client, error) { } } + client.UserAgent = "actions-runner-controller" + return &Client{ Client: client, regTokens: map[string]*github.RegistrationToken{}, diff --git a/github/github_test.go b/github/github_test.go index 92383a19..f7c11f62 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -152,3 +152,10 @@ func TestCleanup(t *testing.T) { t.Errorf("expired token still exists") } } + +func TestUserAgent(t *testing.T) { + client := newTestClient() + if client.UserAgent != "actions-runner-controller" { + t.Errorf("UserAgent should be set to actions-runner-controller") + } +}