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

docs: readme about autoattach #6

Merged
merged 3 commits into from
Dec 8, 2024
Merged

docs: readme about autoattach #6

merged 3 commits into from
Dec 8, 2024

Conversation

oycyc
Copy link
Contributor

@oycyc oycyc commented Dec 6, 2024

what

  • Add info and example on how to auto attach policies and also the OPA action

references

Markdown preview

Tip

Attaching Policies to Spacelift Stacks

Spacelift Policies can be attached to Spacelift Stacks via labels! See the official Spacelift documentation that shows how policies with the label autoattach:* attaches to all stacks and autoattach:label_here attaches to all stacks with the label_here label.


Tip

Testing your Spacelift OPA Rego Policies

Spacelift Policies use the Open Policy Agent (OPA) Rego language. You can test your policies using the Rego Playground.

Masterpoint has an open-source GitHub Action to automate the testing of OPA Rego policies. It is also showcased on OPA Ecosystem's Integrations page.

Summary by CodeRabbit

  • Documentation
    • Added sections on attaching policies to Spacelift stacks and testing OPA Rego policies.
    • Updated labels for the "approval-role-based" policy to improve clarity on functionality.

@oycyc oycyc requested a review from a team as a code owner December 6, 2024 20:43
Copy link

coderabbitai bot commented Dec 6, 2024

Walkthrough

The changes in this pull request focus on enhancements to the README.md file, introducing new sections that provide guidance on attaching policies to Spacelift stacks and testing OPA Rego policies. Additionally, the policy configuration for the "approval-role-based" policy has been updated to include a new label, clarifying its functionality. These updates aim to improve documentation clarity and usability for users.

Changes

File Change Summary
README.md Added sections on "Attaching Policies to Spacelift Stacks" and "Testing your Spacelift OPA Rego Policies". Updated "approval-role-based" policy labels from ["env:prod"] to ["env:prod", "autoattach:needs-approvers"].

Poem

In the README, knowledge flows,
With tips on policies, as everyone knows.
Labels updated, clarity shines bright,
Testing with OPA, a guiding light!
Spacelift stacks, now easier to steer,
Documentation's magic brings us all cheer! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
README.md (3)

9-13: Consider enhancing the policy attachment section with examples

The section provides good information but could be more actionable with practical examples. Consider adding:

 > ## Attaching Policies to Spacelift Stacks
 >
 > Spacelift Policies can be attached to Spacelift Stacks via labels! [See the official Spacelift documentation](https://docs.spacelift.io/concepts/policy#automatically) that shows how policies with the label `autoattach:*` attaches to all stacks and `autoattach:label_here` attaches to all stacks with the `label_here` label.
+>
+> ### Examples:
+> - `autoattach:*` - Attaches to all stacks
+> - `autoattach:prod` - Attaches to stacks labeled with `prod`
+> - `autoattach:needs-approval` - Attaches to stacks labeled with `needs-approval`

50-50: Consider clarifying multiple label behavior

The example effectively shows the autoattach label usage. Consider adding a note about how multiple labels interact:

-      labels      = ["env:prod", "autoattach:needs-approvers"] # This policy will be auto-attached to stacks with the 'needs-approvers' label.
+      labels      = ["env:prod", "autoattach:needs-approvers"] # This policy will be auto-attached to stacks with the 'needs-approvers' label. The 'env:prod' label is used for policy organization.

56-62: Consider adding a basic test example

The testing section provides excellent resources. Consider enhancing it with a basic test case example:

 > ### Testing your Spacelift OPA Rego Policies
 >
 > Spacelift Policies use the Open Policy Agent (OPA) Rego language. You can test your policies using the [Rego Playground](https://play.openpolicyagent.org/).
 >
 > Masterpoint has an [open-source GitHub Action to automate the testing of OPA Rego policies](https://github.com/masterpointio/github-action-opa-rego-test). It is also showcased on [OPA Ecosystem's Integrations page](https://www.openpolicyagent.org/integrations/github-action-opa-rego-test/).
+>
+> #### Example Test Case:
+> ```rego
+> test_allow {
+>     allow with input as {"user": {"role": "admin"}}
+> }
+> ```
+>
+> You can also test policies locally using the OPA CLI:
+> ```bash
+> opa test . -v
+> ```
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc58db and 293d726.

📒 Files selected for processing (1)
  • README.md (2 hunks)

>
> Spacelift Policies use the Open Policy Agent (OPA) Rego language. You can test your policies using the [Rego Playground](https://play.openpolicyagent.org/).
>
> Masterpoint has an [open-source GitHub Action to automate the testing of OPA Rego policies](https://github.com/masterpointio/github-action-opa-rego-test). It is also showcased on [OPA Ecosystem's Integrations page](https://www.openpolicyagent.org/integrations/github-action-opa-rego-test/).
Copy link
Member

Choose a reason for hiding this comment

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

🙌 🙌 🙌

Copy link
Member

@Gowiem Gowiem left a comment

Choose a reason for hiding this comment

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

:shipit: !

@oycyc oycyc merged commit 3a54401 into main Dec 8, 2024
2 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