-
Notifications
You must be signed in to change notification settings - Fork 37
feat(policy): add policy develop init #2229
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
func newPolicyDevelopCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "develop", | ||
Aliases: []string{"dev"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aliases: []string{"dev"}, | |
Aliases: []string{"devel"}, |
this sounds a little bit better to me since it might represent a verb
chainloop policy develop init | ||
# Initialize in specific directory with embedded format | ||
chainloop policy develop init ./policies --embedded`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing that we do not do in any command in chainloop is to use arguments, we always use flags. The reason being that they are more flexible and easier to change in the future.
cmd := &cobra.Command{ | ||
Use: "develop", | ||
Aliases: []string{"dev"}, | ||
Short: "Tools for policy development", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, it might make sense to add this link https://docs.chainloop.dev/guides/custom-policies
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package policy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might be able to simplify a little this package structure, I do not think you need to levels.
I'd just make
`internal/policy-devel`
and inside you can have an init.go
file, same package but organized by functionality, would that work?
} | ||
|
||
// Add custom template functions | ||
func executeTemplate(content string, data *TemplateData) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind adding some unit tests?
@@ -0,0 +1,20 @@ | |||
apiVersion: policy.chainloop.dev/v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add some headers indicating that this is generated by the CLI, the link to the docs, etc, at the top
Other than that this is nice
This PR adds
policy develop init
commandUsage:
Flags:
--name
: Policy name--description
: Policy description--embedded
: Generate single-file policy with embedded rego script--force
,-f
: Overwrite existing filesPart of #1108