Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Replace hashicorp/go-multierror with kerrors #9175

Merged

Conversation

killianmuldoon
Copy link
Contributor

Replace hashicorp/go-multierror with kerrors. This bring the conversion-verifier in line with what's being done across the rest of the codebase.

Related to cncf/foundation#617 which investigates license changes in hashicorp repos. This is the only direct dependency on a hashicorp repo in the CAPI codebase. AFAICT this repo won't be impacted by the licensing changes, but it's a low impact change which drops a dependency and makes the code more consistent.

/area dependency

@k8s-ci-robot k8s-ci-robot added area/dependency Issues or PRs related to dependency changes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 14, 2023
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 14, 2023
if result != nil {
klog.Exit(result.Error())
if errs != nil {
klog.Exit(kerrors.NewAggregate(errs).Error())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a downgrade in UX here from:

F0814 11:16:57.464635   80425 main.go:214] 2 errors occurred:
        * type "cluster.x-k8s.io/MachineDeployment" in package "sigs.k8s.io/cluster-api/api/v1beta1" marked as storage version but it's not convertible, missing Hub() method
        * type "cluster.x-k8s.io/MachineSetList" in package "sigs.k8s.io/cluster-api/api/v1beta1" marked as storage version but it's not convertible, missing Hub() method

to:

[type "cluster.x-k8s.io/MachineDeploymentList" in package "sigs.k8s.io/cluster-api/api/v1beta1" marked as storage version but it's not convertible, missing Hub() method, type "cluster.x-k8s.io/MachineHealthCheck" in package "sigs.k8s.io/cluster-api/api/v1beta1" marked as storage version but it's not convertible, missing Hub() method, type "cluster.x-k8s.io/MachineDeployment" in package "sigs.k8s.io/cluster-api/api/v1beta1" marked as storage version but it's not convertible, missing Hub() method]
make: *** [Makefile:628: verify-conversions] Error 1

But I'm fine with that as this tool is pretty low impact and isn't really user facing. We could implement our own string function to compensate thoug if needed.

Copy link
Member

@sbueringer sbueringer Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a simple for loop over errors with fmt.Println + os.Exit at the end?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also len(errs) > 0 seems more idiomatic vs != nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - the current version now looks very similar to the old output using go-multi-error

@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indirect dep is brought in by viper

> go mod why -m github.com/hashicorp/hcl

# github.com/hashicorp/hcl
sigs.k8s.io/cluster-api/cmd/clusterctl/client/config
github.com/spf13/viper
github.com/spf13/viper/internal/encoding/hcl
github.com/hashicorp/hcl

We have a number of other indirect hashicorp dependencies in our go.sum - but I think all of them are going to remain at MPL for now.

@killianmuldoon killianmuldoon force-pushed the pr-replace-go-multierror branch 2 times, most recently from 4176cc2 to 93d11ed Compare August 14, 2023 10:32
@killianmuldoon killianmuldoon force-pushed the pr-replace-go-multierror branch from 93d11ed to cd595fb Compare August 14, 2023 10:35
@sbueringer
Copy link
Member

Thank you very much!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 8506d74605880914d166ffc72405711c4179a140

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 14, 2023
@k8s-ci-robot k8s-ci-robot merged commit 9903654 into kubernetes-sigs:main Aug 14, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/dependency Issues or PRs related to dependency changes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants