diff --git a/pkg/sources/github/connector.go b/pkg/sources/github/connector.go index bd4932511..9e99e4e1f 100644 --- a/pkg/sources/github/connector.go +++ b/pkg/sources/github/connector.go @@ -117,7 +117,7 @@ func newConnector(ctx context.Context, source *Source) (Connector, error) { switch cred := source.conn.GetCredential().(type) { case *sourcespb.GitHub_GithubApp: log.RedactGlobally(cred.GithubApp.GetPrivateKey()) - return NewAppConnector(ctx, apiEndpoint, cred.GithubApp, source.conn.GetScanAllInstallations()) + return NewAppConnector(apiEndpoint, cred.GithubApp, source.conn.GetScanAllInstallations()) case *sourcespb.GitHub_BasicAuth: log.RedactGlobally(cred.BasicAuth.GetPassword()) return NewBasicAuthConnector(ctx, apiEndpoint, source.conn.GetClonePath(), cred.BasicAuth) diff --git a/pkg/sources/github/connector_app.go b/pkg/sources/github/connector_app.go index bffcedc3a..a1e9aa335 100644 --- a/pkg/sources/github/connector_app.go +++ b/pkg/sources/github/connector_app.go @@ -46,7 +46,7 @@ var _ Connector = (*appConnector)(nil) const githubHTTPTimeoutSeconds = 60 -func NewAppConnector(ctx context.Context, apiEndpoint string, app *credentialspb.GitHubApp, scanAllInstallations bool) (Connector, error) { +func NewAppConnector(apiEndpoint string, app *credentialspb.GitHubApp, scanAllInstallations bool) (Connector, error) { var installationID int64 var err error @@ -130,10 +130,10 @@ func (c *appConnector) APIClientForRepo(repoURL string) (*github.Client, error) func (c *appConnector) GraphQLClientForRepo(ctx context.Context, repoURL string) (*githubv4.Client, error) { installID, _ := c.installationIDForRepo(repoURL) - return c.graphqlClientForInstallation(ctx, installID) + return c.graphqlClientForInstallation(installID) } -func (c *appConnector) graphqlClientForInstallation(ctx context.Context, installID int64) (*githubv4.Client, error) { +func (c *appConnector) graphqlClientForInstallation(installID int64) (*githubv4.Client, error) { clients, err := c.clientsForInstallation(installID) if err != nil { return nil, err @@ -238,7 +238,7 @@ func (c *appConnector) setRepoInstallationForWiki(repoURL string, installationID // installation, lazily creating it if needed. See APIClient for why this // cannot simply return nil when no default installation is configured. func (c *appConnector) GraphQLClient() *githubv4.Client { - client, err := c.graphqlClientForInstallation(context.Background(), c.installationID) + client, err := c.graphqlClientForInstallation(c.installationID) if err != nil { return nil } diff --git a/pkg/sources/github/connector_app_test.go b/pkg/sources/github/connector_app_test.go index d0bd479d7..ff19d6ceb 100644 --- a/pkg/sources/github/connector_app_test.go +++ b/pkg/sources/github/connector_app_test.go @@ -148,7 +148,7 @@ func TestNewAppConnectorDefaultAPIClientUsesConfiguredInstallation(t *testing.T) })) defer server.Close() - connector, err := NewAppConnector(trContext.Background(), server.URL, &credentialspb.GitHubApp{ + connector, err := NewAppConnector(server.URL, &credentialspb.GitHubApp{ PrivateKey: string(privKey), InstallationId: "4242", AppId: "12345", @@ -184,7 +184,7 @@ func TestNewAppConnectorInstallationIDOptionalWithScanAllInstallations(t *testin defer server.Close() // scanAllInstallations=true with no installationId configured should succeed. - connector, err := NewAppConnector(trContext.Background(), server.URL, &credentialspb.GitHubApp{ + connector, err := NewAppConnector(server.URL, &credentialspb.GitHubApp{ PrivateKey: string(privKey), AppId: "12345", }, true) @@ -192,7 +192,7 @@ func TestNewAppConnectorInstallationIDOptionalWithScanAllInstallations(t *testin require.NotNil(t, connector) // Without scanAllInstallations, installationId is still required. - _, err = NewAppConnector(trContext.Background(), server.URL, &credentialspb.GitHubApp{ + _, err = NewAppConnector(server.URL, &credentialspb.GitHubApp{ PrivateKey: string(privKey), AppId: "12345", }, false) @@ -215,7 +215,7 @@ func TestAPIClientAndGraphQLClientNonNilWithoutDefaultInstallation(t *testing.T) })) defer server.Close() - connector, err := NewAppConnector(trContext.Background(), server.URL, &credentialspb.GitHubApp{ + connector, err := NewAppConnector(server.URL, &credentialspb.GitHubApp{ PrivateKey: string(privKey), AppId: "12345", }, true) diff --git a/pkg/sources/github/github_test.go b/pkg/sources/github/github_test.go index 9a0d2e6ff..29911c078 100644 --- a/pkg/sources/github/github_test.go +++ b/pkg/sources/github/github_test.go @@ -375,15 +375,11 @@ func TestAppConnector_EnterpriseBaseURL(t *testing.T) { privateKey := createPrivateKey() enterpriseEndpoint := "https://api.example.ghe.com" - connector, err := NewAppConnector( - context.Background(), - enterpriseEndpoint, - &credentialspb.GitHubApp{ - PrivateKey: privateKey, - InstallationId: "1337", - AppId: "4141", - }, - false) + connector, err := NewAppConnector(enterpriseEndpoint, &credentialspb.GitHubApp{ + PrivateKey: privateKey, + InstallationId: "1337", + AppId: "4141", + }, false) require.NoError(t, err) appConn, ok := connector.(*appConnector)