Skip to content

feat(policy): change devel commands return to stdout#2308

Merged
Piskoo merged 3 commits into
chainloop-dev:mainfrom
Piskoo:feat-policy-change-devel-commands-return-to-stdout
Aug 5, 2025
Merged

feat(policy): change devel commands return to stdout#2308
Piskoo merged 3 commits into
chainloop-dev:mainfrom
Piskoo:feat-policy-change-devel-commands-return-to-stdout

Conversation

@Piskoo

@Piskoo Piskoo commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

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 jiparis and migmartri August 5, 2025 10:38
Comment thread app/cli/cmd/policy_develop_lint.go Outdated
return nil
}

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fmt.Sprintf

Comment thread app/cli/cmd/output.go
*action.AttestationStatusMaterial |
*action.ListMembershipResult
*action.ListMembershipResult |
*action.PolicyEvalResult

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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