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

Refactor: Unexport all methods defined on private receivers in the lxc package. #13543

Merged
merged 9 commits into from
Jun 4, 2024

Conversation

markylaing
Copy link
Contributor

The current linting rules are flagging all Run and Command methods in the lxc package as requiring a comment. These methods are following a pattern that was established years ago. None of the methods are imported elsewhere in the codebase and should be exported (the receivers are private and do not implement any interfaces). This PR unexports all methods defined on private receivers in the lxc package, then fixes any remaining linter errors that surfaced as a result.

See #13504 (comment) and #13540 (comment)

@markylaing markylaing self-assigned this Jun 4, 2024
lxc/file.go Outdated Show resolved Hide resolved
lxc/image.go Outdated Show resolved Hide resolved
The "checkPrivateReceivers" argument to the "exported" rule of the
"revive" linter flags all of these methods. This rule was added to
enforce comments e.g. exported methods for interface implementations
where the implementing struct is kept private. The `Run` and `Command`
methods are not called outside of the `lxc` package, so the rule is
correctly indicating that these methods should not be exported.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
The `io.ReadCloser` returned by the `fileGetWrapper` was captured by
reference. As it was a named return value, this meant that the value of
`buf` could change if the call to `GetInstanceFile` returned after the
user signaled to cancel. This commit removes the named returns so that
the value of `buf` cannot change after the function returns.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Thanks!

@tomponline tomponline merged commit 4fc8b64 into canonical:main Jun 4, 2024
27 checks passed
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.

2 participants