Skip to content

Conversation

@kyounghunJang
Copy link
Contributor

@kyounghunJang kyounghunJang commented Sep 2, 2025

Summary

Add submodule support to git-clone step

Related Issue

fixes #4755

Description

Currently, the git-clone step does not support submodules.
Users must manually checkout submodules in separate steps and parse .gitmodules,
which introduces unnecessary complexity.

This PR adds support for initializing submodules directly within git-clone.

Proposed Changes

  • Added a new boolean config option recurseSubmodules (default: false)

@kyounghunJang kyounghunJang requested a review from a team as a code owner September 2, 2025 14:15
@netlify
Copy link

netlify bot commented Sep 2, 2025

Deploy Preview for docs-kargo-io canceled.

Name Link
🔨 Latest commit e2a4cbe
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/68f71faa60a0a00008582572

@codecov
Copy link

codecov bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.43%. Comparing base (d6b2774) to head (e2a4cbe).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/git/work_tree.go 0.00% 5 Missing ⚠️
pkg/promotion/runner/builtin/git_cloner.go 33.33% 3 Missing and 1 partial ⚠️
pkg/controller/git/mock_repo.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4974      +/-   ##
==========================================
- Coverage   55.44%   55.43%   -0.02%     
==========================================
  Files         404      404              
  Lines       36426    36450      +24     
==========================================
+ Hits        20198    20206       +8     
- Misses      15265    15279      +14     
- Partials      963      965       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hiddeco
Copy link
Contributor

hiddeco commented Sep 2, 2025

I think additional changes would be required to ensure credentials are properly passed, especially when each Git repository requires a different set of credentials. Which is a hypothetical possibility.

@kyounghunJang
Copy link
Contributor Author

@hiddeco
Hello, thank you for the feedback.

Currently, this PR is designed to only allow cloning submodules that share the same credentials as the main repository. I fully recognize and agree with the need to support multiple sets of credentials.
If we were to support multiple authentications, I think the following changes would be required.

  1. Currently, buildGitCommand handles HTTP using GIT_ASKPASS and GIT_PASSWORD. This is expected to only work for a single set of credentials. Therefore, I think this should be changed to use the .git-credentials mechanism instead.

  2. To obtain the submodule RepoUrl, we need to perform a bare clone, then parse the .modules file, and store that information into the ClientOptions struct under a Credentials field (or SubCredentials). After that, we should fetch the correct credentials from the secret database.

  3. I believe we also need a module that writes the retrieved secret information into .git-credentials.

Please let me know if my thoughts and design approach are correct. Thanks!

@krancour krancour added kind/enhancement An entirely new feature priority/low Low commitment from maintainers; progress is likely to be community-driven area/controller Affects the (main) controller labels Sep 4, 2025
@krancour
Copy link
Member

krancour commented Sep 4, 2025

fwiw, I think doing this with the limitation of only using the same credentials as the main repository seems like it might be a reasonable first step. I say might because the devil's always in the details and I have not looked at this very closely.

Currently, buildGitCommand handles HTTP using GIT_ASKPASS and GIT_PASSWORD. This is expected to only work for a single set of credentials. Therefore, I think this should be changed to use the .git-credentials mechanism instead.

Only a word of caution that messing with any of that shouldn't be undertaken lightly and I would prefer something like that be done by a maintainer. There are a lot of esoteric reasons that git auth in Kargo is implemented as it is. There are certain approaches that don't work within a container based on a distroless image, and admittedly, I have a pipe dream of one day not even including a shell in that image, and that further restricts which approaches are viable. I definitely do not want us to fall down this particular rabbit hole at this time.

@kyounghunJang
Copy link
Contributor Author

@krancour
Hello, thank you for your feedback.
If modifying the logic is too complex, I also believe that, as reflected in the current PR, it would be preferable to allow submodules to be fetched when they share the same authentication as the main repository. I have completed testing to confirm that submodules can be fetched successfully in cases where the authentication matches the main repository.

@etetar
Copy link

etetar commented Oct 1, 2025

@krancour @kyounghunJang Hi! Thank you for working on this. Any chance this will make it into 1.7.6 or 1.8.0?

@kyounghunJang kyounghunJang force-pushed the main branch 2 times, most recently from 54bc08e to 399aeda Compare October 19, 2025 07:18
Signed-off-by: Kyounghoon Jang <matkimchi_@naver.com>
@kyounghunJang kyounghunJang force-pushed the main branch 2 times, most recently from 26abcb5 to 067e37b Compare October 21, 2025 04:56
Signed-off-by: Kyounghoon Jang <matkimchi_@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/controller Affects the (main) controller kind/enhancement An entirely new feature priority/low Low commitment from maintainers; progress is likely to be community-driven

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support submodules in git-clone

4 participants