ci: optimize dependency management by using module cache instead of vendor directory #645
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 optimizes the client code generation process in
hack/update-client.shby replacinggo mod vendorwithgo mod downloadand leveraging Go's module cache directly.Changes Made
go mod vendorwithgo mod downloadto avoid creating a temporary vendor directoryk8s.io/code-generatorfrom the Go module cache usinggo list -m -f '{{.Dir}}'rm -r vendorcleanup step as vendor directory is no longer createdPerformance Benefits
This change brings performance improvements to CI pipelines:
Faster Execution: Eliminates the overhead of copying dependencies to a vendor directory.
go mod downloadonly ensures dependencies are in the module cache, whilego mod vendorrequires creating and populating an entire vendor tree.Reduced I/O Operations: Avoids unnecessary file system operations (creating, copying, and deleting vendor directory with potentially hundreds of files).
Better Cache Utilization: Leverages Go's built-in module cache (
$GOMODCACHE), which is typically already populated in CI environments, further reducing download time on subsequent runs.Disk Space Efficiency: No temporary vendor directory is created and removed during the process, reducing disk I/O pressure.
In local testing, the script executes successfully and generates the same client code as before, confirming functional equivalence with improved efficiency.
Related Issues
N/A
Checklist
Breaking Changes
None. This is an internal optimization to the build process with no impact on generated code or public APIs.
Additional Notes
Verification
The modified script has been tested and successfully generates client code:
git statusconfirms no vendor directory artifacts left behindModern Go Best Practices
This change aligns with modern Go module practices where the module cache is the preferred source of dependencies rather than vendoring, especially for build-time tools.