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

simplify --fail-on-lint-warning and fix error message #747

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

imjasonh
Copy link
Member

This uses errors.Join to collect multiple lint findings and report on them (or not) all at once, instead of failing on the first one when there may be more to find.

This also removes the warn callback pattern and just has LintPackageFs return any Joined errors, or nil if none are found. In this change, BuildPackage is responsible for erroring or warning when lint errors are found, instead of burying that deep inside LintPackageFs.

This PR originally started as an attempt to fix a malformed error output when linting produced errors:

make LINT=yes package/curl-rustls
...
2023/10/10 20:40:01 error during command execution: failed to build package: package linter warning: %!w(<nil>)

Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Comment on lines -338 to -341
if linter.FailOnError {
return fmt.Errorf("Linter %s failed; suggest: %s", linterName, linter.Explain)
}
warn(err)
Copy link
Member

Choose a reason for hiding this comment

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

This eliminates the ability to have individual linters be fatal.

Copy link
Member

Choose a reason for hiding this comment

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

Basically: we need a way to introduce a linter as just a warning, get it clean, and then make it fatal.

If we land this then we can't make anything required without making everything required and it will become a requirement to get linters clean across Wolfi before landing any of its logic, which I don't think we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

WDYT about having --fail-on-lint-warning=empty,setuidgid,foo,bar which selects which ones will be considered fatal?

Copy link
Member

Choose a reason for hiding this comment

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

That seems fine, but I still think linters should be able to have defaults. This could be through the flag defaults, I have no preference here.

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.

None yet

2 participants