refactor: remove unused context

This commit is contained in:
Meredith Howard
2026-09-18 10:52:43 -05:00
parent 8c1d04adf8
commit 86ef983975
4 changed files with 14 additions and 18 deletions
+1 -1
View File
@@ -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)
+4 -4
View File
@@ -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
}
+4 -4
View File
@@ -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)
+2 -6
View File
@@ -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{
connector, err := NewAppConnector(enterpriseEndpoint, &credentialspb.GitHubApp{
PrivateKey: privateKey,
InstallationId: "1337",
AppId: "4141",
},
false)
}, false)
require.NoError(t, err)
appConn, ok := connector.(*appConnector)