diff --git a/pkg/pusher/ocipusher.go b/pkg/pusher/ocipusher.go index 94154d389..405efb58f 100644 --- a/pkg/pusher/ocipusher.go +++ b/pkg/pusher/ocipusher.go @@ -23,7 +23,7 @@ import ( "path" "strings" "time" - + "net/url" "github.com/pkg/errors" "helm.sh/helm/v3/internal/tlsutil" @@ -45,6 +45,14 @@ func (pusher *OCIPusher) Push(chartRef, href string, options ...Option) error { } func (pusher *OCIPusher) push(chartRef, href string) error { + + // See: https://github.com/helm/helm/issues/12728 + u, _ := url.Parse(href) + hrefPath := strings.SplitN(u.Path, ":", 2) + if len(hrefPath) > 1 { + return fmt.Errorf("Version tag \"%s\" need not be passed for remote", hrefPath[1]) + } + stat, err := os.Stat(chartRef) if err != nil { if os.IsNotExist(err) { diff --git a/pkg/uploader/chart_uploader.go b/pkg/uploader/chart_uploader.go index 1ed68d83c..d7e940406 100644 --- a/pkg/uploader/chart_uploader.go +++ b/pkg/uploader/chart_uploader.go @@ -24,7 +24,6 @@ import ( "helm.sh/helm/v3/pkg/pusher" "helm.sh/helm/v3/pkg/registry" - "strings" ) // ChartUploader handles uploading a chart. @@ -50,12 +49,6 @@ func (c *ChartUploader) UploadTo(ref, remote string) error { return fmt.Errorf("scheme prefix missing from remote (e.g. \"%s://\")", registry.OCIScheme) } - // See: https://github.com/helm/helm/issues/12728 - path := strings.SplitN(u.Path, ":", 2) - if len(path) > 1 { - return fmt.Errorf("Version tag \"%s\" need not be passed for remote", path[1]) - } - p, err := c.Pushers.ByScheme(u.Scheme) if err != nil { return err