Repository navigation
Conversation
351a9f9 to
f6f9cff
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the git resolver’s API-mode SCM integration to stop depending on github.com/jenkins-x/go-scm by introducing a new internal pkg/internal/scmclient package that implements a lightweight SCMClient interface (GetFileContent / GetCommitSHA / GetCloneURL) and wiring the resolver(s) to use it.
Changes:
- Added
pkg/internal/scmclientwith HTTP-based clients (GitHub/GitLab/Gitea) behind a small interface plus a fake for unit tests. - Updated both in-tree git resolvers to construct SCM clients via
scmclient.Newinstead ofgo-scm/factory.NewClient. - Expanded/adjusted e2e tests to validate API mode for additional providers (GitHub/GitLab) and refactored Gitea API-mode tests.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
test/resolvers_git_test.go |
E2E updates: adds GitHub/GitLab API-mode tests and refactors Gitea API-mode tests/config handling. |
pkg/resolution/resolver/git/resolver.go |
Switches API-mode resolution to use pkg/internal/scmclient instead of go-scm. |
pkg/resolution/resolver/git/resolver_test.go |
Updates unit tests to mock via scmclient.FakeSCMClient and adjusts expected errors. |
pkg/remoteresolution/resolver/git/resolver.go |
Switches remoteresolution git resolver to use pkg/internal/scmclient. |
pkg/remoteresolution/resolver/git/resolver_test.go |
Updates remoteresolution unit tests to mock via scmclient.FakeSCMClient. |
pkg/internal/scmclient/client.go |
Adds SCMClient interface and provider factory. |
pkg/internal/scmclient/http.go |
Adds a small HTTP helper for request/response handling. |
pkg/internal/scmclient/github.go / github_test.go |
Adds GitHub REST client + unit tests. |
pkg/internal/scmclient/gitlab.go / gitlab_test.go |
Adds GitLab REST client + unit tests. |
pkg/internal/scmclient/gitea.go / gitea_test.go |
Adds Gitea REST client + unit tests. |
pkg/internal/scmclient/fake.go |
Adds a fake implementation for resolver unit tests. |
pkg/internal/scmclient/bitbucketcloud.go |
Placeholder Bitbucket Cloud client (currently panics). |
pkg/internal/scmclient/bitbucketserver.go |
Placeholder Bitbucket Server client (currently panics). |
pkg/internal/scmclient/azure.go |
Placeholder Azure DevOps client (currently panics). |
pkg/internal/scmclient/client_test.go |
Tests factory behavior for supported provider keys. |
Comments suppressed due to low confidence (1)
test/resolvers_git_test.go:558
- This test verification request places the auth token in the URL query (
...&token=...) and useshttp.Getwithout a context. Tokens in query strings are easily leaked via logs/proxies, and omitting context can cause the call to hang beyond the test deadline. Prefer sending the token viaAuthorizationheader and usinghttp.NewRequestWithContext.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8f43882 to
3e7d091
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 15 comments.
Comments suppressed due to low confidence (1)
test/resolvers_git_test.go:619
- The verification request puts the Gitea token into the query string and uses http.Get without context. Tokens in URLs can leak via logs/proxies, and the request won’t be canceled if the test context is canceled. Prefer an Authorization header with a context-aware request, and ensure the response body is closed via defer.
8afdeef to
7d12375
Compare
7d12375 to
d9b6985
Compare
ba8b481 to
44d7a56
Compare
|
@ary82 can you rebase the PR ? Sorry for the delay on the review.. Summer can be a bit challenging 😛 |
vdemeester
left a comment
There was a problem hiding this comment.
SGTM, but defenitely needs more eyes on it 👼🏼
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No worries :D I'll push a rebase to main today |
0dd5bdc to
807a369
Compare
|
@ary82 I have a couple of concerns:
|
807a369 to
4415c5b
Compare
4415c5b to
09a6a0c
Compare
Thanks for the review @wbrefvem!
|
09a6a0c to
77422cb
Compare
|
Normalization added for GitHub Enterprise and Bitbucket Cloud |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10208 +/- ##
==========================================
- Coverage 90.74% 90.63% -0.12%
==========================================
Files 298 307 +9
Lines 22603 23058 +455
==========================================
+ Hits 20512 20898 +386
- Misses 2089 2158 +69
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
waveywaves
left a comment
There was a problem hiding this comment.
The replacement looks good overall, but the Azure client has two blocking compatibility issues.
| return "", err | ||
| } | ||
| rawURL := fmt.Sprintf("%s/%s/%s/_apis/git/repositories/%s/commits/%s?api-version=7.1", | ||
| c.baseURL, organization, project, repo, url.PathEscape(ref)) |
There was a problem hiding this comment.
Blocking: this endpoint requires a commit ID, but this method receives branch and tag revisions such as main. Azure API mode will fail for normal named refs. Please resolve the ref to a commit SHA before calling this endpoint.
There was a problem hiding this comment.
Thanks for the review @waveywaves
I've updated it so that full SHAs still use commits/{id}, but branch and tag names resolve to a commit SHA through the Refs API first. Also added tests for branches, tags and missing refs.
| // Handles refs/heads/, refs/tags/, and bare branch/tag names or commit SHAs. | ||
| func generateVersionDescriptor(ref string) string { | ||
| if branch, ok := strings.CutPrefix(ref, "refs/heads/"); ok { | ||
| return fmt.Sprintf("versionDescriptor.version=%s&versionDescriptor.versionType=branch", branch) |
There was a problem hiding this comment.
Blocking: the ref is added to the query without escaping. A valid branch such as feature/a&x=y becomes feature/a plus a separate x=y parameter. Please encode the query value before building the URL.
There was a problem hiding this comment.
Fixed, the version is now query-escaped so refs like feature/a&x=y stay a single value.
77422cb to
118d204
Compare
befe178 to
9a44518
Compare
The git resolver's API depended on `github.com/jenkins-x/go-scm` for fetching file content from SCM providers, causing a heavy dependency and ongoing maintenance pain. This change introduces the `scmclient` internal package, which defines lightweight implementations of the SCM providers according to the `SCMClient` interface. It has three methods (GetFileContent, GetCommitSHA, GetCloneURL). Implementations include github, gitlab, gitea, bitbucketcloud, bitbucketserver and azure Signed-off-by: Aryan Goyal <mail@ary82.dev>
9a44518 to
37564e6
Compare
Closes #9989
Changes
The git resolver's API depended on
github.com/jenkins-x/go-scmfor fetching file content from SCM providers, causing a heavy dependency and ongoing maintenance pain.This change introduces the
scmclientinternal package, which defines lightweight implementations of the SCM providers according to theSCMClientinterface. It has three methods (GetFileContent, GetCommitSHA, GetCloneURL)/kind cleanup
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes