fix(gitlab): add support for nested groups/subgroups#729
Open
wescrow wants to merge 1 commit intokubero-dev:mainfrom
Open
fix(gitlab): add support for nested groups/subgroups#729wescrow wants to merge 1 commit intokubero-dev:mainfrom
wescrow wants to merge 1 commit intokubero-dev:mainfrom
Conversation
GitLab allows repositories to be organized in nested group structures (e.g., owner/subgroup/repo). The existing code only handled top-level groups (owner/repo), causing 404 errors when accessing nested repos. Changes: - Extract full project path from parsed git URL instead of just owner/repo - Add encodeProjectPath helper to properly encode all path segments - Update getRepository, addWebhook, addDeployKey, getBranches, and getReferences methods to use the helper for correct API paths Example: For git@gitlab.com:owner/subgroup/repo.git - Before: projects/owner%2Frepo (404 error) - After: projects/owner%2Fsubgroup%2Frepo (success) Fixes kubero-dev#728
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for GitLab repositories organized in nested group structures (e.g.,
owner/subgroup/repo).Summary
The existing GitLab integration only handled top-level groups (
owner/repo), causing 404 errors when attempting toconnect repositories in nested groups. This was due to incomplete project path encoding in the GitLab API calls.
Changes
encodeProjectPath()helper method to properly URL-encode all path segments in project pathsgetRepository()method to extract the full project path from git URLs instead of just owner/repoaddWebhook()- webhook creation and listingaddDeployKey()- deploy key creationgetBranches()- branch listinggetReferences()- branch, tag, and commit listingExample
For a repository like
git@gitlab.com:owner/subgroup/repo.git:Before: API call to
projects/owner/subgroup%2Frepo→ 404 errorAfter: API call to
projects/owner%2Fsubgroup%2Frepo→ successThe issue was that forward slashes in the owner path (from nested groups) weren't being encoded, resulting in
malformed API paths.
Fixes #728
Type of change
How Has This Been Tested?
Tested extensively in a production Kubernetes environment:
wescrow/kubero:fix-gitlab-nested-groupsThe fix has been running in production for several hours without issues.
Test Configuration:
wescrow/kubero:fix-gitlab-nested-groups(available on Docker Hub)Checklist: