feat(envctx): refactor LazyLoad; use PartialCloneClusterRepo - #486
feat(envctx): refactor LazyLoad; use PartialCloneClusterRepo#486GavinPJK wants to merge 6 commits into
Conversation
|
Hi @GavinPJK. Thanks for your PR. I'm waiting for a jenkins-x-plugins member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/ok-to-test |
There was a problem hiding this comment.
Pull request overview
This PR refactors pkg/envctx.EnvironmentContext.LazyLoad into smaller helper methods to reduce complexity, and switches version-stream loading to use requirements.PartialCloneClusterRepo (sparse/shallow with fallback) instead of a full gitclient.CloneToDir.
Changes:
- Split
LazyLoadinto focused helpers (loadDevEnv,loadRequirements,overrideDevGitURL,loadVersionResolver, plus supporting helpers). - Use
requirements.PartialCloneClusterRepoto fetch onlyversionStream/for the version resolver. - Add unit tests covering the new helper behaviors and orchestration no-op behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/envctx/load.go | Refactors LazyLoad into helper methods and updates version resolver cloning to partial/sparse clone. |
| pkg/envctx/load_test.go | Adds unit tests for the new helper methods and LazyLoad orchestration behavior. |
Comments suppressed due to low confidence (1)
pkg/envctx/load.go:168
- If PartialCloneClusterRepo returns an empty directory path, the current error message says "to dir %s" but prints an empty string, and also repeats
gitCloneURL(which may contain credentials). Use a clearer message and avoid including the credentialed URL.
if cloneDir == "" {
return "", fmt.Errorf("failed to clone URL %s to dir %s", gitCloneURL, cloneDir)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes
envctx.LazyLoadby breaking it up into smaller helpers (loadDevEnv,loadRequirements,overrideDevGitURL,loadVersionResolver)gitclient.CloneToDirwithrequirements.PartialCloneClusterRepowhen loading the version resolverContext
LazyLoadis overly-complex, so it's now split up into helpers - loadDevEnv,loadRequirements,overrideDevGitURLandloadVersionResolver`.loadVersionResolveralso uses new helpers -resolveGitCredentials,cloneDevEnvRepoandensureVersionStreamDir.The version resolver only requires
versionStreamfrom the dev env repo and doesn't require a detailed git history. The full repository clone (gitclient.CloneToDir, fromjx-helpers) is replaced with a partial and shallow clone (requirements.PartialCloneClusterRepo, also fromjx-helpers), that falls-back to a full clone if these features aren't supported by the upstream git server.Done as part of jenkins-x/jx#8240. The clone setup in
pkg/environments/gitops.gois more complex so should be dealt with separately.