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

removal of github.com/pkg/errors and commitment to go 1.13 errors #1107

Merged
merged 3 commits into from
Nov 27, 2019

Conversation

kensipe
Copy link
Member

@kensipe kensipe commented Nov 26, 2019

What this PR does / why we need it:
Removes a dependency

Because... reasons...

Fixes #

Copy link
Member

@jbarrick-mesosphere jbarrick-mesosphere left a comment

Choose a reason for hiding this comment

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

As good a reasoning as any :)

@gerred
Copy link
Member

gerred commented Nov 26, 2019

@kensipe perfect now if you could remove the dependency on Kubernetes that'd be great. 😂

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

Good effort! One nit on errors.New and let's clarify wrapping of errors with %w.

@@ -75,12 +73,12 @@ func (k *KustomizeEnhancer) Apply(templates map[string]string, metadata Metadata

yamlBytes, err := yaml.Marshal(kustomization)
if err != nil {
return nil, errors.Wrapf(err, "error marshalling kustomize yaml")
return nil, fmt.Errorf("error marshalling kustomize yaml: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have an agreement on when we expose the underlying error with %w and when not?

To quote Go 1.13 errors blog post:

In other words, wrapping an error makes that error part of your API. If you don't want to 
commit to supporting that error as part of your API in the future, you shouldn't wrap the error.

It’s important to remember that whether you wrap or not, the error text will be the same. A 
person trying to understand the error will have the same information either way; the choice to 
wrap is about whether to give programs additional information so they can make more informed 
decisions, or to withhold that information to preserve an abstraction layer.

I believe, in this particular case, it doesn't make a difference since our yaml.Marshal method already wraps underlying errors. Personally, I'm leaning towards:

  • Using %v by default to preserve abstractions boundaries
  • Using %w intentionally when exposing the underlying error type is necessary

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we're already having this discussion in this PR. I x-posted my comment there.

Copy link
Member Author

Choose a reason for hiding this comment

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

great thoughts. The wrapping is because we wrapped it before... I'm not aware if this was incidental or intentional. It is worth pausing.. I definitely like your personally leanings and will take them on as well.

pkg/kudoctl/cmd/update.go Outdated Show resolved Hide resolved
@kensipe kensipe requested a review from nfnt as a code owner November 27, 2019 13:47
@kensipe
Copy link
Member Author

kensipe commented Nov 27, 2019

merging as the required approvals are there... updates / changes have been made and I will be on PTO for an extended weekend

@kensipe kensipe merged commit a324d13 into master Nov 27, 2019
@kensipe kensipe deleted the ken/gh-errors-removal branch November 27, 2019 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants