Skip to content

Commit

Permalink
Merge pull request #223 from mkmik/errorsjoin
Browse files Browse the repository at this point in the history
Switch to errors.Join
  • Loading branch information
mkmik committed Dec 14, 2023
2 parents ba874b9 + 454468a commit 6aa9be8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/knot8/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
package main

import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
"sort"

"github.com/mattn/go-isatty"
"github.com/mkmik/multierror"
"golang.org/x/text/encoding/unicode"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
Expand Down Expand Up @@ -103,7 +103,7 @@ func expandPaths(paths []string) ([]string, error) {
_ = add(p + "/*.yml")
}
if errs != nil {
return nil, multierror.Join(errs)
return nil, errors.Join(errs...)
}
sort.Strings(res)
return res, nil
Expand Down
12 changes: 6 additions & 6 deletions cmd/knot8/knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
package main

import (
"errors"
"fmt"
"sort"
"strings"

"github.com/mkmik/multierror"
"gopkg.in/yaml.v3"
"knot8.io/pkg/lensed"
)
Expand Down Expand Up @@ -53,7 +53,7 @@ func parseFields(manifests []*Manifest) (Fields, error) {
}
}
if errs != nil {
return nil, multierror.Join(errs)
return nil, errors.Join(errs...)
}
return res, nil
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func (ks Fields) Rebase(dst Manifests) error {
}
}
if errs != nil {
return multierror.Join(errs)
return errors.Join(errs...)
}
return nil
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func (k Field) GetAll() ([]FieldTarget, error) {
res = append(res, FieldTarget{ptr: p, value: v})
}
if errs != nil {
return nil, multierror.Join(errs)
return nil, errors.Join(errs...)
}
return res, nil
}
Expand Down Expand Up @@ -203,7 +203,7 @@ func (b EditBatch) Set(n, v string) error {
b.edits[file] = append(b.edits[file], lensed.Mapping{p.Abs(), v})
}
if errs != nil {
return multierror.Join(errs)
return errors.Join(errs...)
}

return nil
Expand All @@ -220,7 +220,7 @@ func (b EditBatch) Commit() error {
}
}
if errs != nil {
return multierror.Join(errs)
return errors.Join(errs...)
}
b.committed = true
return nil
Expand Down
9 changes: 4 additions & 5 deletions cmd/knot8/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/alecthomas/kong"
"github.com/hashicorp/go-getter"
"github.com/mkmik/multierror"
"gopkg.in/yaml.v3"
"knot8.io/pkg/lensed"
)
Expand Down Expand Up @@ -135,7 +134,7 @@ func (s *SetCmd) Run(ctx *Context) error {
}
}
if errs != nil {
return multierror.Join(errs)
return errors.Join(errs...)
}
if err := batch.Commit(); err != nil {
return err
Expand Down Expand Up @@ -167,7 +166,7 @@ func settersFromFiles(paths []string) ([]Setter, error) {
}
}
if errs != nil {
return nil, multierror.Join(errs)
return nil, errors.Join(errs...)
}
for k, v := range all {
res = append(res, Setter{k, v})
Expand Down Expand Up @@ -402,7 +401,7 @@ func checkFields(fields Fields) error {
}
}
if errs != nil {
return errNotUniqueValue{multierror.Join(errs)}
return errNotUniqueValue{errors.Join(errs...)}
}
return nil
}
Expand Down Expand Up @@ -462,7 +461,7 @@ func openFields(paths []string, schema string) (*ManifestSet, error) {
}
}
if errs != nil {
return nil, multierror.Join(errs)
return nil, errors.Join(errs...)
}

fields, err = parseFields(manifests)
Expand Down
4 changes: 2 additions & 2 deletions cmd/knot8/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"strings"

"github.com/mkmik/multierror"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -112,7 +112,7 @@ func (ms Manifests) Commit() error {
}

if errs != nil {
return multierror.Join(errs)
return errors.Join(errs...)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/lensed/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strconv"
"strings"

"github.com/vmware-labs/go-yaml-edit"
yamled "github.com/vmware-labs/go-yaml-edit"
"github.com/vmware-labs/go-yaml-edit/splice"
yptr "github.com/vmware-labs/yaml-jsonpointer"
"golang.org/x/text/transform"
Expand Down

0 comments on commit 6aa9be8

Please sign in to comment.