Skip to content

Commit

Permalink
chore: replaces errlist implementation with hashicorp/multi-error
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Jan 19, 2023
1 parent 1008119 commit 94eac58
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 109 deletions.
1 change: 1 addition & 0 deletions api/client/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1alpha1

// TypeMeta contains type metadata.
// This structure is equivalent to k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta
type TypeMeta struct {
Kind string `json:"kind,omitempty"`
APIVersion string `json:"apiVersion,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/buger/jsonparser v1.1.1
github.com/emporous/collection-spec v0.0.0-20230112181029-9df787e68bce
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/hashicorp/go-multierror v1.1.1
github.com/nsf/jsondiff v0.0.0-20210926074059-1e845ec5d249
github.com/sigstore/cosign v1.13.1
)
Expand Down Expand Up @@ -176,7 +177,6 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
Expand Down
16 changes: 9 additions & 7 deletions nodes/descriptor/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (

"github.com/buger/jsonparser"
empspec "github.com/emporous/collection-spec/specs-go/v1alpha1"
"github.com/hashicorp/go-multierror"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"

"github.com/emporous/emporous-go/attributes"
"github.com/emporous/emporous-go/model"
"github.com/emporous/emporous-go/util/errlist"
)

var _ model.AttributeSet = &Properties{}
Expand Down Expand Up @@ -207,41 +207,43 @@ func Parse(in map[string]json.RawMessage) (*Properties, error) {
var out Properties
other := map[string]model.AttributeSet{}

var result *multierror.Error

var errs []error
for key, prop := range in {
switch key {
case TypeLink:
var l empspec.LinkAttributes
if err := json.Unmarshal(prop, &l); err != nil {
errs = append(errs, ParseError{Key: key, Err: err})
multierror.Append(result, ParseError{Key: key, Err: err})
continue
}
out.Link = &l
case TypeDescriptor:
var d empspec.DescriptorAttributes
if err := json.Unmarshal(prop, &d); err != nil {
errs = append(errs, ParseError{Key: key, Err: err})
multierror.Append(result, ParseError{Key: key, Err: err})
continue
}
out.Descriptor = &d
case TypeSchema:
var s empspec.SchemaAttributes
if err := json.Unmarshal(prop, &s); err != nil {
errs = append(errs, ParseError{Key: key, Err: err})
multierror.Append(result, ParseError{Key: key, Err: err})
continue
}
out.Schema = &s
case TypeRuntime:
var r ocispec.ImageConfig
if err := json.Unmarshal(prop, &r); err != nil {
errs = append(errs, ParseError{Key: key, Err: err})
multierror.Append(result, ParseError{Key: key, Err: err})
continue
}
out.Runtime = &r
case TypeFile:
var f empspec.File
if err := json.Unmarshal(prop, &f); err != nil {
errs = append(errs, ParseError{Key: key, Err: err})
multierror.Append(result, ParseError{Key: key, Err: err})
continue
}
out.File = &f
Expand Down Expand Up @@ -285,5 +287,5 @@ func Parse(in map[string]json.RawMessage) (*Properties, error) {
}
}
out.Others = other
return &out, errlist.NewErrList(errs)
return &out, result.ErrorOrNil()
}
101 changes: 0 additions & 101 deletions util/errlist/errlist.go

This file was deleted.

0 comments on commit 94eac58

Please sign in to comment.