847eeb839f
## Problem Helm charts like Intel device plugins have download URLs on `github.com` but the chart index is served from `intel.github.io`. The merger rewrites all URLs through the proxy, constructing: ``` https://artifactapi/api/v1/remote/intel-helm/intel/helm-charts/releases/download/... ``` Which proxies to `https://intel.github.io/helm-charts/intel/helm-charts/releases/download/...` — a 404. ## Fix Compare the download URL host against the remote's base URL host. If they differ, leave the URL as-is so helm downloads directly from the source. Same-host URLs are still rewritten through the proxy. Also adds `BaseURL` to `MemberIndex` so the merger has the context it needs, and uses the correct `/local/` vs `/remote/` route prefix. Reviewed-on: #56 Co-authored-by: Ben Vincent <ben@unkin.net> Co-committed-by: Ben Vincent <ben@unkin.net>
33 lines
621 B
Go
33 lines
621 B
Go
package virtual
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.unkin.net/unkin/artifactapi/pkg/models"
|
|
)
|
|
|
|
type MemberIndex struct {
|
|
RemoteName string
|
|
RepoType models.RepoType
|
|
BaseURL string
|
|
Body []byte
|
|
}
|
|
|
|
type IndexMerger interface {
|
|
MergeIndexes(members []MemberIndex, proxyBaseURL string) ([]byte, error)
|
|
}
|
|
|
|
var mergers = map[models.PackageType]IndexMerger{}
|
|
|
|
func RegisterMerger(pt models.PackageType, m IndexMerger) {
|
|
mergers[pt] = m
|
|
}
|
|
|
|
func GetMerger(pt models.PackageType) (IndexMerger, error) {
|
|
m, ok := mergers[pt]
|
|
if !ok {
|
|
return nil, fmt.Errorf("no merger registered for package type %q", pt)
|
|
}
|
|
return m, nil
|
|
}
|