Add tag support for push

pull/10450/head^2
Michael Thomas Lee / Intility AS 4 years ago
parent 1d11fcb5d3
commit 64d3fb1d84

@ -55,6 +55,15 @@ func NewPushWithOpts(opts ...PushOpt) *Push {
// Run executes 'helm push' against the given chart archive. // Run executes 'helm push' against the given chart archive.
func (p *Push) Run(chartRef string, remote string) (string, error) { func (p *Push) Run(chartRef string, remote string) (string, error) {
remoteSplit := strings.SplitN(remote, ":", 1)
remoteUrl := remoteSplit[0]
tag := ""
if len(remoteSplit) > 1 {
tag = remoteSplit[1]
}
var out strings.Builder var out strings.Builder
c := uploader.ChartUploader{ c := uploader.ChartUploader{
@ -63,9 +72,9 @@ func (p *Push) Run(chartRef string, remote string) (string, error) {
Options: []pusher.Option{}, Options: []pusher.Option{},
} }
if registry.IsOCI(remote) { if registry.IsOCI(remoteUrl) {
c.Options = append(c.Options, pusher.WithRegistryClient(p.cfg.RegistryClient)) c.Options = append(c.Options, pusher.WithRegistryClient(p.cfg.RegistryClient))
} }
return out.String(), c.UploadTo(chartRef, remote) return out.String(), c.UploadTo(chartRef, remoteUrl, tag)
} }

@ -39,7 +39,7 @@ type ChartUploader struct {
} }
// UploadTo uploads a chart. Depending on the settings, it may also upload a provenance file. // UploadTo uploads a chart. Depending on the settings, it may also upload a provenance file.
func (c *ChartUploader) UploadTo(ref, remote string) error { func (c *ChartUploader) UploadTo(ref, remote string, tag string) error {
u, err := url.Parse(remote) u, err := url.Parse(remote)
if err != nil { if err != nil {
return errors.Errorf("invalid chart URL format: %s", remote) return errors.Errorf("invalid chart URL format: %s", remote)
@ -54,5 +54,5 @@ func (c *ChartUploader) UploadTo(ref, remote string) error {
return err return err
} }
return p.Push(ref, u.String(), c.Options...) return p.Push(ref, fmt.Sprintf("%s:%s", u.String(), tag), c.Options...)
} }

Loading…
Cancel
Save