Giter VIP home page Giter VIP logo

spacelift-policies-example-library's Introduction

Spacelift Policies Example Library

This repository contains a collection of Spacelift Policy examples that can be re-purposed (if needed), and used with Spacelift. Spacelift Policies use the Open Policy Agent, which are written in the rego language. As you'll find in this repository, there are various types of Spacelift Policies - which allow for a lot of flexibility and customization. For more information on Spacelift Policies please refer to the documentation.

Useful resources

  • Spacelift Policies: You can find information about all available Spacelift Policy types here.
  • Open Policy Agent: Spacelift Policies utilize the Open Policy Agent, which uses the Rego language.
  • Spacelift Policy Workbench: Use the Spacelift Policy Workbench to debug your policies using sample policy inputs.
  • Testing Policies: Learn about creating test cases for your Spacelift Policies.

Policy Examples by Type

Policy Types Currently In This Library are below. Feel free to click on a given policy type to be taken to examples for that policy type.

Policy Type Description
ACCESS (Deprecated) Define who gets to access individual Stacks and with what level of access.
APPROVAL Define who can approve or reject a run/task and how a run/task can be approved.
LOGIN Define who gets to login to your Spacelift account and with what level of access.
PLAN Define which changes can be applied.
PUSH Define how git push events are interpreted.
TRIGGER Define what happens when blocking runs terminate.

All Policy Examples

Access Policy

Access policies have been deprecated. Please read this for details.

Approval Policy

Login Policy

Notification Policy

Plan Policy

Push Policy

Trigger Policy

Policy Tests

Tests can be added for policies using the convention <policy_filename>_test.rego. For example if you have a policy called plan.rego, you can create a test file called plan_test.rego.

You can use the following command to run all policy tests:

./run_policy_tests.sh

spacelift-policies-example-library's People

Contributors

adamconnelly avatar anderseknert avatar cdhesse avatar datfinesoul avatar eminalemdar avatar flaviuscdinu avatar jmfontaine avatar jwenz723 avatar nitrocode avatar spitzzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spacelift-policies-example-library's Issues

Need sample access policy for multiple teams with same level of access

We encountered an issue where one team did not have access when we had two teams with the same level of (admin) access. That turned out to be a syntax issue fixed by adding separate admin stanzas for each team. Looks like I can't push a branch or I would create the PR myself, so here's example code derived from the existing login/access-levels-within-an-organization.rego policy.

package spacelift

# This login policy gives everyone in the organization access to Spacelift
# and makes all members of both the "DevOps" team AND the "Superuser" team 
# admins.
#
# You can read more about login policies here:
# https://docs.spacelift.io/concepts/policy/login-policy

admin {
	input.session.teams[_] == "DevOps"
}

admin {
	input.session.teams[_] == "Superuser"
}

allow {
	input.session.member
}

deny {
	not allow
}

# Learn more about sampling policy evaluations here:
# https://docs.spacelift.io/concepts/policy#sampling-policy-inputs
sample = true

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.