From cd595fb8f6a9e1b08a19bef45c894dbdcfe73d2d Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Mon, 14 Aug 2023 11:12:46 +0100 Subject: [PATCH] Replace hashicorp/go-multierror with kerrors Signed-off-by: killianmuldoon --- hack/tools/conversion-verifier/main.go | 17 ++++++++++------- hack/tools/go.mod | 2 -- hack/tools/go.sum | 4 ---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/hack/tools/conversion-verifier/main.go b/hack/tools/conversion-verifier/main.go index 02272b2e6d56..ab1109014d3f 100644 --- a/hack/tools/conversion-verifier/main.go +++ b/hack/tools/conversion-verifier/main.go @@ -17,11 +17,11 @@ limitations under the License. package main import ( + "fmt" "go/types" "path" "strings" - "github.com/hashicorp/go-multierror" "github.com/pkg/errors" "k8s.io/klog/v2" crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers" @@ -70,7 +70,7 @@ func (s *storageVersionType) IsHub() bool { } func main() { - var result error + var errs []error // Define the marker collector. col := &markers.Collector{ @@ -118,7 +118,7 @@ func main() { return } if _, ok := storageVersionTypes[info.Name]; ok { - result = multierror.Append(result, + errs = append(errs, errors.Errorf("type %q has a redeclared storage version in package %q", info.Name, pkg.PkgPath), ) return @@ -197,21 +197,24 @@ func main() { } if !storageType.IsHub() { - result = multierror.Append(result, + errs = append(errs, errors.Errorf("type %q in package %q marked as storage version but it's not convertible, missing Hub() method", name, storageType.pkg.PkgPath), ) } for _, decl := range storageType.otherDecls { if !decl.IsConvertible() { - result = multierror.Append(result, + errs = append(errs, errors.Errorf("type %q in package %q it's not convertible, missing ConvertFrom() and ConvertTo() methods", name, decl.pkg.PkgPath), ) } } } - if result != nil { - klog.Exit(result.Error()) + if len(errs) > 0 { + fmt.Printf("%d errors occurred:\n", len(errs)) + for _, err := range errs { + fmt.Printf("\t* %s\n", err) + } } } diff --git a/hack/tools/go.mod b/hack/tools/go.mod index 9952d89785ea..fd3cea0fdbfe 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -9,7 +9,6 @@ replace sigs.k8s.io/cluster-api/test => ../../test require ( cloud.google.com/go/storage v1.31.0 github.com/blang/semver v3.5.1+incompatible - github.com/hashicorp/go-multierror v1.1.1 github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 github.com/valyala/fastjson v1.6.4 @@ -80,7 +79,6 @@ require ( github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.13 // indirect diff --git a/hack/tools/go.sum b/hack/tools/go.sum index 424b1a675060..cba73fc71d89 100644 --- a/hack/tools/go.sum +++ b/hack/tools/go.sum @@ -279,14 +279,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=