gravitational / predicate-lang

Predicate - Access Control System
Apache License 2.0
3 stars 2 forks source link

Add a "new -p" command to create policy file using template #57

Closed flyinghermit closed 1 year ago

flyinghermit commented 1 year ago

This PR aims to help create a new policy file using a default template. See #47 for more details. While it only creates a new policy file based on a default template, we can extend this feature to create more custom policies in future.

Details:

A new CLI command new -p (--policy) is added that creates a base python file (inside "policies' directory) with policy template and commented test codes. The templating is done using jinja2 (added as a new dependency).

This workflow will create policy file (python file) based on user input. The input is used to create a python file name, class name, policy name and test name. Since the current code assumes a class name to be "Teleport", I have also added a simple function to retrieve class name using ast. Existing export, deploy and test commands are updated to support this change.