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

feat(policy): Support marshalling of config #796

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

iainlane
Copy link
Contributor

@iainlane iainlane commented Jul 9, 2024

Sometimes it's convenient to generate a Policy Bot config. For example, when handling required but optional workflows, you need the config file to contain a rule for each workflow which replicates its path filters.

That job is made much easier if the Policy Bot types can be reused. But without omitempty the generated YAML contains all fields and it's hard to read/review.

Add omitempty where it's needed, and IsZero in a few places too - which is how the behaviour of omitempty can be customised.

@palantirtech
Copy link
Member

Thanks for your interest in palantir/policy-bot, @iainlane! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

Copy link
Member

@bluekeyes bluekeyes left a comment

Choose a reason for hiding this comment

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

Thanks, I think it's fine to support this for people who'd like to use it.

Note that we don't offer any guarantees about Go-level compatibility between different versions of Policy Bot. As long as the behavior of the running server is compatible, we may make breaking changes to any of the Go packages in minor/patch versions. Something to be aware of if you plan to consume this code in a tool to generate policies.

policy/common/actor.go Outdated Show resolved Hide resolved
Sometimes it's convenient to generate a Policy Bot config. For example,
when handling required but optional workflows, you need the config file to
contain a rule for each workflow which replicates its path filters.

That job is made much easier if the Policy Bot types can be reused. But
without `omitempty` the generated YAML contains all fields and it's hard
to read/review.

Add `omitempty` where it's needed, and `IsZero` in a few places too -
which is how the behaviour of `omitempty` can be customised.
@iainlane iainlane marked this pull request as ready for review September 4, 2024 12:41
@iainlane
Copy link
Contributor Author

iainlane commented Sep 4, 2024

Just remembered about this / came back to it and rebased 👍

iainlane added a commit to iainlane/policy-bot that referenced this pull request Sep 4, 2024
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.

3 participants