fix: rewrite helm index.yaml URLs post-parse to handle relative URLs #37
Reference in New Issue
Block a user
Delete Branch "benvin/issue-33-helm-relative-url-rewrite"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #33
Summary
_merge_helm_indexesnow parses each member's raw YAML first, then rewritesurlsentries in-place via the new_rewrite_urlshelperrancher-2.13.1.tgz) are prepended with{proxy_base}/api/v1/remote/{member_name}/base_urlare rewritten to the proxy path (existing behaviour, now correct)_helm.resolve_contentraw-bytes detour from the virtual merge path;remote/helm.pyis unchanged (still used for direct remote proxying)Test plan
make test)TestRewriteUrlsclass covering relative, absolute-match, absolute-no-match, leading-slash, and multi-URL casestest_relative_urls_rewritten_to_proxyinTestMergeHelmIndexestest_first_member_wins_on_duplicate_name_and_versionto assert on proxy remote name (not upstream hostname)index.yamlrelative URLs rewritten correctly tohttp://localhost:8000/api/v1/remote/rancher-stable/rancher-2.14.1.tgzetc.helm-allvirtual (19 members) returns HTTP 200 with 395k-line merged index on cache missRaw byte replacement in _merge_helm_indexes only worked when the upstream index contained absolute URLs matching base_url. Upstreams like Rancher use relative URLs (e.g. rancher-2.13.1.tgz), which were left unrewritten, causing Helm to construct a 404-producing URL against the virtual repo. Now parses YAML first, then rewrites each entry's urls list: - relative URL → prepend {proxy_base}/api/v1/remote/{member_name}/ - absolute URL matching base_url → replace prefix with proxy remote path