-
Notifications
You must be signed in to change notification settings - Fork 395
Golangci lint #731
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
Golangci lint #731
Conversation
|
@bege13mot You need sign all of your PRs |
Thank you, I've signed all commits, but unfortunately, I'm not sure about rebasing. Could you please help a little bit with it? |
|
You need to rebase on the most recent commit on master. There are many ways to do that. I usually keep the upstream projects as a remote: $ git remote add upstream [email protected]:containers/image.git
$ git remote update
# now can rebase our branch on top of upstream/master
$ git pull --rebase upstream master |
|
Thank you |
|
Unfortunately, still can't pass the test: |
|
I restarted Travis. We had to update Skopeo to unblock the CI here. |
|
Commit eae61fa must be dropped from this PR. |
vrothberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use more descriptive commit messages. "Fix ABC" is not enough to describe what's going on. "Fix" is a very generic (and overused) term. "Check all errors in ABC" would be more descriptive. Good commit messages are especially important for maintenance.
A more detailed review follows in a bit.
vrothberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening the PR, @bege13mot!
As mentioned before, the commit messages must be more descriptive and also explain/justify why certain changes are okay (e.g., dead-code removal). I dropped comments where I would like some further changes (e.g., log errors instead of ignoring). Also, I found a couple of changes that seem unrelated to golangci-lint. Please make sure that those are not part of this PR. We can address them in a separate PR.
|
Hi @vrothberg , |
|
CI tests are not at all happy. |
Hi, it looks like an issue with containers/skopeo |
openshift/openshift-copies.go
Outdated
| defer clientCertFile.Close() | ||
| defer func() { | ||
| err = clientCertFile.Close() | ||
| logrus.Debugf("error closing client cert CA: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two copy&pasted errors here and below are incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not clear about these copy&pasted errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text of the 3 Debugf messages is the same (“closing client CA”), but only one of them actually closes a client CA; the other two should be updated to match what actually failed (client certificate/key file).
At a first glance, this looks like an issue in how this PR changes the environment for |
|
@bege13mot, can you rebase? We had some CI flakes that are fixed now. One thing I just noticed now is that all commits are not signed with your real name but with the GitHub user which is in conflict with the contributing policies (https://github.com/containers/image/blob/master/CONTRIBUTING.md). My apologies for noticing that late. |
|
This is now very big, and likely enough to break if any other PR is merged. Maybe it would be more practical to split it into smaller PRs? (Definitely no need to split it artificially just because I said so now — but, if the rebase happens one commit at a time, maybe separate 10 unrelated commits into a separate PR.) Ideally, of course, a rebased version would pass tests, be quickly reviewed, and immediately merged; splitting this is distinctly second best. Still, a possible option. |
|
I think something went wrong while rebasing since there are many older commits unrelated to this PR. |
|
Failures look legit: |
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
Signed-off-by: Ivan Voronchihin <[email protected]>
|
@vrothberg @mtrmac Tests pass, is this ready to merge? |
I'll do one final review now 👍 |
vrothberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just very minor nits left, and we're ready to merge. Thanks for the nice contribution and the long breath, @bege13mot !
Makefile
Outdated
|
|
||
| tools.timestamp: Makefile | ||
| @GO111MODULE="off" go get -u $(BUILDFLAGS) golang.org/x/lint/golint | ||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sudo sh -s -- -b $(go env GOPATH)/bin v1.21.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop sudo. It's not needed. We should also first check if golangci-lint isn't already installed and only install if needed. An example how to do that is in libpod: https://github.com/containers/libpod/blob/master/Makefile#L483
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it isn't help.
`install: cannot create regular file '//golangci-lint': Permission denied``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“help” or not, this project absolutely must not create files in the root directory of the user’s filesystem!
If using sudo here really has that effect, it must be removed, pretty much at any cost, up to and including not running golang-ci, if there were really no alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that. $(go env GOPATH) didn't evaluate here for some odd reason.
| // deterministic behavior which is not guaranteed by maps. | ||
| for _, reg := range config.Registries { | ||
| others, _ := regMap[reg.Location] | ||
| others := regMap[reg.Location] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @mtrmac. We should address it.
storage/storage_image.go
Outdated
| layers, err := s.imageRef.transport.store.LayersByUncompressedDigest(info.Digest) | ||
| if err != nil { | ||
| return nil, -1, "", err | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ignore the error here. It's really okay if there's an error here as we might need to lookup the compresssed digest. The log here could cause confusing noise.
Signed-off-by: bege13mot <[email protected]>
Signed-off-by: bege13mot <[email protected]>
Signed-off-by: bege13mot <[email protected]>
Signed-off-by: bege13mot <[email protected]>
vrothberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@rhatdan PTAL. Once this is merged, I'll tackle the install targets to make them consistent with Buildah, Podman etc.
|
LGTM |
sockets.DialerFromEnvironment seems to implement an all_proxy environment variable. Either way, since containers#731 the return value was ignored, making that code completely ineffective, and noone has complained for three years. So let's just drop it. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
containers#731 introduced a WaitGroup which is waited but never signaled, and a nonsensical error reporting mechanism (where errors are pushed but don't terminate future operations). Instead, rely on PipeWriter.CloseWithError() to propagate failures from the goroutine. And move all of the body of the goroutine into a separate function, so that we can use defer() to ensure CloseWithError() is _always_ called. Signed-off-by: Miloslav Trmač <[email protected]>
#730