diff --git a/internal/experimental/action/push.go b/internal/experimental/action/push.go index 5cd83624b..b125ae1f4 100644 --- a/internal/experimental/action/push.go +++ b/internal/experimental/action/push.go @@ -67,6 +67,5 @@ func (p *Push) Run(chartRef string, remote string) (string, error) { c.Options = append(c.Options, pusher.WithRegistryClient(p.cfg.RegistryClient)) } - err := c.UploadTo(chartRef, remote) - return out.String(), err + return out.String(), c.UploadTo(chartRef, remote) } diff --git a/internal/experimental/pusher/ocipusher.go b/internal/experimental/pusher/ocipusher.go index 67a0153c3..ec7764a41 100644 --- a/internal/experimental/pusher/ocipusher.go +++ b/internal/experimental/pusher/ocipusher.go @@ -67,11 +67,11 @@ func (pusher *OCIPusher) push(chartRef, href string) error { var pushOpts []registry.PushOption provRef := fmt.Sprintf("%s.prov", chartRef) - if _, err := os.Stat(provRef); err == nil { - provBytes, err := ioutil.ReadFile(provRef) - if err != nil { + if provBytes, err := ioutil.ReadFile(provRef); err != nil { + if err != os.ErrNotExist { // ignore error if .prov does not exist return err } + } else { pushOpts = append(pushOpts, registry.PushOptProvData(provBytes)) } @@ -80,11 +80,7 @@ func (pusher *OCIPusher) push(chartRef, href string) error { meta.Metadata.Version) _, err = client.Push(chartBytes, ref, pushOpts...) - if err != nil { - return err - } - - return nil + return err } // NewOCIPusher constructs a valid OCI client as a Pusher