From af61fd66e79e1d416c2ff31a4b85dde70542c374 Mon Sep 17 00:00:00 2001 From: Oded Ben Ozer Date: Tue, 6 Jun 2023 10:44:04 +0200 Subject: [PATCH] Fix wrong URL for GH enterprise server graphQL endpoint issue (#70) --- internal/pkg/githubapi/clients.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/pkg/githubapi/clients.go b/internal/pkg/githubapi/clients.go index 46f98634..3276f95b 100644 --- a/internal/pkg/githubapi/clients.go +++ b/internal/pkg/githubapi/clients.go @@ -98,16 +98,16 @@ func CreateGithubRestClient(githubOauthToken string, githubRestAltURL string, ct return client } -func createGithubAppGraphQlClient(githubAppPrivateKeyPath string, githubAppId int64, githubAppInstallationId int64, githubGraphqlAltURL string, githubRestAltURL string, ctx context.Context) *githubv4.Client { +func createGithubAppGraphQlClient(githubAppPrivateKeyPath string, githubAppId int64, githubAppInstallationId int64, githubGraphqlAltURL string, ctx context.Context) *githubv4.Client { itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, githubAppId, githubAppInstallationId, githubAppPrivateKeyPath) if err != nil { log.Fatal(err) } var client *githubv4.Client - if githubRestAltURL != "" { - itr.BaseURL = githubRestAltURL - client = githubv4.NewEnterpriseClient(githubRestAltURL, &http.Client{Transport: itr}) + if githubGraphqlAltURL != "" { + itr.BaseURL = githubGraphqlAltURL + client = githubv4.NewEnterpriseClient(githubGraphqlAltURL, &http.Client{Transport: itr}) } else { client = githubv4.NewClient(&http.Client{Transport: itr}) } @@ -157,7 +157,7 @@ func CreateAllClients(ctx context.Context) (*github.Client, *githubv4.Client, *g } mainGithubClient = createGithubAppRestClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubRestAltURL, ctx) - githubGraphQlClient = createGithubAppGraphQlClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubGraphqlAltURL, githubRestAltURL, ctx) + githubGraphQlClient = createGithubAppGraphQlClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubGraphqlAltURL, ctx) } else { mainGithubClient = CreateGithubRestClient(getCrucialEnv("GITHUB_OAUTH_TOKEN"), githubRestAltURL, ctx) githubGraphQlClient = createGithubGraphQlClient(getCrucialEnv("GITHUB_OAUTH_TOKEN"), githubGraphqlAltURL)