Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(github): use different graphql path in enterprise version #7541

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions backend/plugins/github_graphql/impl/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,18 @@ func (p GithubGraphql) PrepareTaskData(taskCtx plugin.TaskContext, options map[s
}

httpClient := oauth2.NewClient(oauthContext, src)
endpoint, err := errors.Convert01(url.JoinPath(connection.Endpoint, `graphql`))
endpoint, err := errors.Convert01(url.Parse(connection.Endpoint))
if err != nil {
return nil, errors.BadInput.Wrap(err, fmt.Sprintf("malformed connection endpoint supplied: %s", connection.Endpoint))
}
client := graphql.NewClient(endpoint, httpClient)

// github.com and github enterprise have different graphql endpoints
endpoint.Path = "/graphql" // see https://docs.github.com/en/graphql/guides/forming-calls-with-graphql
if endpoint.Hostname() != "api.github.com" {
// see https://docs.github.com/en/enterprise-server@3.11/graphql/guides/forming-calls-with-graphql
endpoint.Path = "/api/graphql"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall.
I just want to make sure that all On-premise GitHub deployments are Enterprise Edition? Or in other words, do they all follow this URL-forming pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @klesh ,
Is the question directed to me or you mean you are checking it in the background?
From my side it is hard to know if all on-premise instances use this pattern as I only know the instance we use. Besides from that I double checked with Renovate source code and they also have custom handling for Github Enterprise, see https://github.com/renovatebot/renovate/blob/main/lib/util/github/graphql/datasource-fetcher.ts#L85.

So I would consider it safe to assume that this is the standard for on-premise instances.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the information, very informative.

}
client := graphql.NewClient(endpoint.String(), httpClient)
graphqlClient, err := helper.CreateAsyncGraphqlClient(taskCtx, client, taskCtx.GetLogger(),
func(ctx context.Context, client *graphql.Client, logger log.Logger) (rateRemaining int, resetAt *time.Time, err errors.Error) {
var query GraphQueryRateLimit
Expand Down
Loading