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

cmd/validate: print the validation errors #163

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

marquiz
Copy link
Contributor

@marquiz marquiz commented Sep 26, 2023

Print out any errors encountered during validation, as suggested by the command help.

Copy link
Contributor

@elezar elezar left a comment

Choose a reason for hiding this comment

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

One minor comment. Not a blocker though.

for path, specErrors := range cdiErrors {
fmt.Printf("Spec file %s:\n", path)
for idx, err := range specErrors {
fmt.Printf(" %d: %v\n", idx, strings.TrimRight(err.Error(), "\n"))
Copy link
Contributor

Choose a reason for hiding this comment

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

What about just:

Suggested change
fmt.Printf(" %d: %v\n", idx, strings.TrimRight(err.Error(), "\n"))
fmt.Printf(" %d: %v\n", idx, strings.Trim(err.Error()))

We should be ok to just ignore all leading and trailing whitespace in error messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Changed it to strings.TrimSpace()

@marquiz marquiz force-pushed the devel/validate-fix branch 2 times, most recently from 374b1d9 to e2171b1 Compare September 27, 2023 08:07
Copy link
Contributor

@elezar elezar left a comment

Choose a reason for hiding this comment

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

minor nit but not a blocker.

for path, specErrors := range cdiErrors {
fmt.Printf("Spec file %s:\n", path)
for idx, err := range specErrors {
fmt.Printf(" %d: %v\n", idx, strings.TrimSpace(err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the update. As a matter of interest, do we want to use tabs instead of spaces here so that the columns are aligned? This really isn't a blocker though, and I'm happy to approve as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of using tabs I now changed this to %3d so it will reserve 3 chars for the idx. Will get unaligned if there are more than 999 errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, that would be 999 errors per spec. I changed it to %2d so it will get unaligned after 99 errors per spec

@elezar elezar self-requested a review September 27, 2023 08:50
Print out any errors encountered during validation, as suggested by the
command help.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
@elezar elezar merged commit f161fa4 into cncf-tags:main Sep 27, 2023
7 checks passed
@marquiz marquiz deleted the devel/validate-fix branch September 27, 2023 09:41
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