return errors directly, less lines of code

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
pull/9782/head
Josh Dolitsky 3 years ago
parent fc98f2e6a3
commit ec84339d44
No known key found for this signature in database
GPG Key ID: B2B93673243A65FB

@ -67,6 +67,5 @@ func (p *Push) Run(chartRef string, remote string) (string, error) {
c.Options = append(c.Options, pusher.WithRegistryClient(p.cfg.RegistryClient)) c.Options = append(c.Options, pusher.WithRegistryClient(p.cfg.RegistryClient))
} }
err := c.UploadTo(chartRef, remote) return out.String(), c.UploadTo(chartRef, remote)
return out.String(), err
} }

@ -67,11 +67,11 @@ func (pusher *OCIPusher) push(chartRef, href string) error {
var pushOpts []registry.PushOption var pushOpts []registry.PushOption
provRef := fmt.Sprintf("%s.prov", chartRef) provRef := fmt.Sprintf("%s.prov", chartRef)
if _, err := os.Stat(provRef); err == nil { if provBytes, err := ioutil.ReadFile(provRef); err != nil {
provBytes, err := ioutil.ReadFile(provRef) if err != os.ErrNotExist { // ignore error if .prov does not exist
if err != nil {
return err return err
} }
} else {
pushOpts = append(pushOpts, registry.PushOptProvData(provBytes)) pushOpts = append(pushOpts, registry.PushOptProvData(provBytes))
} }
@ -80,13 +80,9 @@ func (pusher *OCIPusher) push(chartRef, href string) error {
meta.Metadata.Version) meta.Metadata.Version)
_, err = client.Push(chartBytes, ref, pushOpts...) _, err = client.Push(chartBytes, ref, pushOpts...)
if err != nil {
return err return err
} }
return nil
}
// NewOCIPusher constructs a valid OCI client as a Pusher // NewOCIPusher constructs a valid OCI client as a Pusher
func NewOCIPusher(ops ...Option) (Pusher, error) { func NewOCIPusher(ops ...Option) (Pusher, error) {
registryClient, err := registry.NewClient() registryClient, err := registry.NewClient()

Loading…
Cancel
Save