feat(policy): add policy develop init#2229
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.
| 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.
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.
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.
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) { |
| @@ -0,0 +1,20 @@ | |||
| apiVersion: policy.chainloop.dev/v1 | |||
There was a problem hiding this comment.
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
…ackage structure Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
|
@javirln ptal once you have a sec |
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
This PR adds
policy develop initcommandUsage:
Flags:
--name: Policy name--description: Policy description--embedded: Generate single-file policy with embedded rego script--force,-f: Overwrite existing filesPart of #1108