Skip to content

Conversation

Piskoo
Copy link
Collaborator

@Piskoo Piskoo commented Aug 5, 2025

This PR changes policy evaluation and linting output to support proper redirection (e.g., chainloop policy devel eval {flags} > results.json).

Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
@Piskoo Piskoo requested a review from javirln August 5, 2025 10:38
@Piskoo Piskoo marked this pull request as ready for review August 5, 2025 10:38
@Piskoo Piskoo requested review from migmartri and jiparis August 5, 2025 10:38
return nil
}

fmt.Fprintf(os.Stdout, "Found %d issues:\n", len(result.Errors))
Copy link
Member

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
Copy link
Member

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?

Copy link
Collaborator Author

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

Piskoo added 2 commits August 5, 2025 14:19
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)
Copy link
Member

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?

Copy link
Collaborator Author

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
   }
]

Copy link
Member

Choose a reason for hiding this comment

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

awesome, please merge :)

@Piskoo Piskoo merged commit d47485e into chainloop-dev:main Aug 5, 2025
13 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