Fix devfile registry resource download to work with any registry#5946
Open
vrubezhny wants to merge 1 commit into
Open
Fix devfile registry resource download to work with any registry#5946vrubezhny wants to merge 1 commit into
vrubezhny wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5946 +/- ##
===========================================
+ Coverage 32.37% 49.22% +16.85%
===========================================
Files 85 111 +26
Lines 6505 10153 +3648
Branches 1349 2293 +944
===========================================
+ Hits 2106 4998 +2892
- Misses 4399 5150 +751
- Partials 0 5 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5c097b7 to
fbb9ab1
Compare
This commit fixes resource downloading to work with any devfile registry (not just hard-coded GitHub URLs) and implements proper URI resolution matching the behavior of the devfile/library Go implementation. **Problem:** - Resources were downloaded using hard-coded GitHub URLs - Parent devfile resources were resolved against wrong source URLs - Resources downloaded AFTER merging, losing parent URL context - No support for both downloadResources (save to disk) and inlineResources modes **Solution:** 1. **DevfileUriResolver** (new file) - Implements proper URI resolution matching Go devfile/library - Handles: absolute HTTP URLs, relative to file, relative to registry URL - Example: "kubernetes/deploy.yaml" + "https://registry.devfile.io/devfiles/go/2.6.0" → "https://registry.devfile.io/devfiles/go/2.6.0/kubernetes/deploy.yaml" - Includes retry with exponential backoff for HTTP 429 (Too Many Requests) 2. **DevfileResolver refactoring** - Added DevfileResolveOptions interface: - downloadResources: Save resources to disk (for odo init) - inlineResources: Inline content into devfile (for odo deploy/dev) - resourcesBasePath: Where to save downloaded files - Changed resolveParentChain() to return DevfileWithSource[] tracking source URL - Process resources BEFORE merging to preserve URL context - Each devfile in parent chain keeps its source URL for correct URI resolution 3. **DevfileRegistryWrapper update** - downloadFromRegistryRepo() now accepts registryUrl parameter - Uses DevfileUriResolver instead of hard-coded GitHub URLs - Works with any devfile registry endpoint 4. **Init component integration** - Removed separate downloadStackExtraFiles() function - Resource downloading now integrated into resolve() process - Properly handles both parent and child resources with correct URLs **Key architectural changes:** - Two-phase approach: resolveParentChain() returns DevfileWithSource[] - Resources processed BEFORE merging (not after) - Source URL tracked through entire parent chain - URI resolution happens at the correct context (per devfile, not once at end) **Testing:** - 11 unit tests for DevfileUriResolver (URI resolution logic) - 7 unit tests for DevfileResolver (resource processing with mocked data) - 3 integration tests using real go-basic devfile from registry.devfile.io: - downloadResources mode (saves to disk) - inlineResources mode (inlines into devfile) - no options mode (URIs unchanged) Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com> Assisted-By: Claude Sonnet 4.5 <noreply@anthropic.com>
fbb9ab1 to
0e5c8a8
Compare
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.
This commit fixes resource downloading to work with any devfile registry (not just hard-coded GitHub URLs) and implements proper URI resolution matching the behavior of the devfile/library Go implementation.
Problem:
Solution:
DevfileUriResolver (new file)
DevfileResolver refactoring
DevfileRegistryWrapper update
Init component integration
Key architectural changes:
Testing:
Assisted-By: Claude Sonnet 4.5 noreply@anthropic.com