Skip to content

Commit

Permalink
return errors directly, less lines of code
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
  • Loading branch information
jdolitsky committed Jul 1, 2021
1 parent fc98f2e commit ec84339
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions internal/experimental/action/push.go
Expand Up @@ -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)
}
12 changes: 4 additions & 8 deletions internal/experimental/pusher/ocipusher.go
Expand Up @@ -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))
}

Expand All @@ -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
Expand Down

0 comments on commit ec84339

Please sign in to comment.