-
Notifications
You must be signed in to change notification settings - Fork 38
feat(policy): change devel commands return to stdout #2308
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
feat(policy): change devel commands return to stdout #2308
Conversation
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
app/cli/cmd/policy_develop_lint.go
Outdated
return nil | ||
} | ||
|
||
fmt.Fprintf(os.Stdout, "Found %d issues:\n", len(result.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.
fmt.Sprintf
*action.AttestationStatusMaterial | | ||
*action.ListMembershipResult | ||
*action.ListMembershipResult | | ||
*action.PolicyEvalResult |
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.
does this mean that now we support json output?
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.
Correct, the text version didn't follow any structure so it would cause problems later on
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
logger.Error().Msg(err) | ||
} | ||
return fmt.Errorf("policy validation failed with %d issues", len(result.Errors)) | ||
return encodeResult(result) |
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.
what's the output when we do not have any violations? Do we return an empty violations array?
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.
Yes, here's the output
[
{
"violations": [],
"skip_reasons": [],
"skipped": false
}
]
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.
awesome, please merge :)
This PR changes policy evaluation and linting output to support proper redirection (e.g.,
chainloop policy devel eval {flags} > results.json
).