Skip to content

Commit 9903654

Browse files
authored
Merge pull request #9175 from killianmuldoon/pr-replace-go-multierror
🌱 Replace hashicorp/go-multierror with kerrors
2 parents c3a2e86 + cd595fb commit 9903654

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

hack/tools/conversion-verifier/main.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"fmt"
2021
"go/types"
2122
"path"
2223
"strings"
2324

24-
"github.com/hashicorp/go-multierror"
2525
"github.com/pkg/errors"
2626
"k8s.io/klog/v2"
2727
crdmarkers "sigs.k8s.io/controller-tools/pkg/crd/markers"
@@ -70,7 +70,7 @@ func (s *storageVersionType) IsHub() bool {
7070
}
7171

7272
func main() {
73-
var result error
73+
var errs []error
7474

7575
// Define the marker collector.
7676
col := &markers.Collector{
@@ -118,7 +118,7 @@ func main() {
118118
return
119119
}
120120
if _, ok := storageVersionTypes[info.Name]; ok {
121-
result = multierror.Append(result,
121+
errs = append(errs,
122122
errors.Errorf("type %q has a redeclared storage version in package %q", info.Name, pkg.PkgPath),
123123
)
124124
return
@@ -197,21 +197,24 @@ func main() {
197197
}
198198

199199
if !storageType.IsHub() {
200-
result = multierror.Append(result,
200+
errs = append(errs,
201201
errors.Errorf("type %q in package %q marked as storage version but it's not convertible, missing Hub() method", name, storageType.pkg.PkgPath),
202202
)
203203
}
204204
for _, decl := range storageType.otherDecls {
205205
if !decl.IsConvertible() {
206-
result = multierror.Append(result,
206+
errs = append(errs,
207207
errors.Errorf("type %q in package %q it's not convertible, missing ConvertFrom() and ConvertTo() methods", name, decl.pkg.PkgPath),
208208
)
209209
}
210210
}
211211
}
212212

213-
if result != nil {
214-
klog.Exit(result.Error())
213+
if len(errs) > 0 {
214+
fmt.Printf("%d errors occurred:\n", len(errs))
215+
for _, err := range errs {
216+
fmt.Printf("\t* %s\n", err)
217+
}
215218
}
216219
}
217220

hack/tools/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ replace sigs.k8s.io/cluster-api/test => ../../test
99
require (
1010
cloud.google.com/go/storage v1.31.0
1111
github.com/blang/semver v3.5.1+incompatible
12-
github.com/hashicorp/go-multierror v1.1.1
1312
github.com/pkg/errors v0.9.1
1413
github.com/spf13/pflag v1.0.5
1514
github.com/valyala/fastjson v1.6.4
@@ -80,7 +79,6 @@ require (
8079
github.com/google/uuid v1.3.0 // indirect
8180
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
8281
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
83-
github.com/hashicorp/errwrap v1.1.0 // indirect
8482
github.com/hashicorp/hcl v1.0.0 // indirect
8583
github.com/huandu/xstrings v1.3.3 // indirect
8684
github.com/imdario/mergo v0.3.13 // indirect

hack/tools/go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb
279279
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
280280
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
281281
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
282-
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
283-
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
284282
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
285283
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
286284
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
287285
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
288-
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
289-
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
290286
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
291287
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
292288
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=

0 commit comments

Comments
 (0)