feat: gitlab scm#4345
Conversation
Signed-off-by: Mark Phelps <[email protected]>
|
The latest Buf updates on your PR. Results from workflow Proto / proto-lint (pull_request).
|
Signed-off-by: Mark Phelps <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v2 #4345 +/- ##
==========================================
+ Coverage 50.65% 53.46% +2.81%
==========================================
Files 122 118 -4
Lines 13200 12425 -775
==========================================
- Hits 6686 6643 -43
+ Misses 5950 5297 -653
+ Partials 564 485 -79
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
|
I tested in a gitlab project that this successfully creates a Merge Request (their PRs) and puts it in draft mode via the title I will look into and fix the potential bug with it not pushing the default namespace in another PR |
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
Signed-off-by: Mark Phelps <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
Adds GitLab as a supported SCM for environment storage, refactors URL parsing, and unifies authentication handling across providers.
- Introduce
gitlabin SCM types, configuration schemas, and environment gRPC messages. - Refactor URL parsing to a generic
ParseGitURLand update the factory to branch on GitLab. - Implement GitLab SCM client with authentication options, tests, and mocks; update credentials to normalize token auth across Git, GitHub, GitLab, and Gitea.
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/storage/environments/git/store.go | Expose new Scm field on EnvironmentConfiguration. |
| internal/storage/environments/environments.go | Handle GitLabSCMType in the EnvironmentFactory switch. |
| internal/storage/environments/environments_test.go | Remove outdated Gitea URL parsing tests. |
| internal/server/analytics/prometheus/prometheus_mock.go | Alias Prometheus import for mock. |
| internal/enterprise/storage/environments/git/url.go | Add ParseGitURL with SSH fallback. |
| internal/enterprise/storage/environments/git/url_test.go | Add tests covering ParseGitURL. |
| internal/enterprise/storage/environments/git/gitlab/gitlab.go | Implement GitLab SCM client, auth setup, and logging. |
| internal/enterprise/storage/environments/git/gitlab/gitlab_test.go | Add comprehensive GitLab SCM client tests. |
| internal/enterprise/storage/environments/git/gitlab/gitlab_mock.go | Generate mocks for GitLab services. |
| internal/enterprise/storage/environments/git/github/github.go | Update GitHub SCM to use unified options and token auth. |
| internal/enterprise/storage/environments/git/github/github_test.go | Remove now-irrelevant SCM field checks. |
| internal/enterprise/storage/environments/git/gitea/gitea.go | Update Gitea SCM client, unify auth options, add logging. |
| internal/enterprise/storage/environments/git/gitea/gitea_test.go | Remove obsolete SCM field checks and add logger injection. |
| internal/credentials/credentials.go | Consolidate GitAuthentication and APIAuthentication methods. |
| internal/credentials/credentials_test.go | Update credential tests for Git and API auth. |
| internal/config/environments.go | Add GitLabSCMType and extend validation. |
| config/flipt.schema.json | Extend JSON schema with "gitlab" in SCM enum. |
| config/flipt.schema.cue | Extend CUE schema with "gitlab" in SCM type. |
| go.mod | Add GitLab API client dependency and bump misc. modules. |
| .mockery.yml | Include GitLab interfaces for mock generation. |
Comments suppressed due to low confidence (4)
internal/enterprise/storage/environments/git/gitea/gitea.go:126
- Typo in variable name
comparition; consider renaming tocomparisonfor clarity and consistency.
comparition, _, err := s.client.CompareCommits(s.repoOwner, s.repoName, req.Base, req.Head)
internal/storage/environments/git/store.go:133
- The new
Scmfield is added toEnvironmentConfigurationbut there are no unit tests covering its value—consider adding tests for GitHub, GitLab, and Gitea scenarios.
Scm: scm,
internal/credentials/credentials.go:123
- [nitpick] Returning an empty
APIAuthfor SSH credentials may silently disable API authentication; consider returning an explicit error or clearly documenting that SSH is unsupported for API calls.
return &APIAuth{
internal/enterprise/storage/environments/git/gitlab/gitlab.go:11
- Importing "iter" without a full module path will fail to resolve; please correct the import to the actual package path (e.g., "go.flipt.io/flipt/internal/iter").
"iter"
Signed-off-by: Mark Phelps <[email protected]>
Config
TODO
Might be due to how we're reusing the auth (basic) for the clone and API which might not be supported for GitLabWe also need to document that you can use one set of auth creds for git operations (like cloning) when configuring storage and another set when integrating with the SCM API (like access token)^ This was the case. Now we convert the credential to the correct format expected by both Git and the SCM API
So now you can configure your creds for GitHub/GitLab (and probably Gitea) as
access_tokenand this will work for both vanilla git operations (fetch/branch/push) as well as in the SCM clients themselves for creating PRs/etc