kubewarden / policy-sdk-rust

Kubewarden Policy SDK for the Rust programming language
https://kubewarden.io
Apache License 2.0
8 stars 6 forks source link

Create a template to scaffold new policy projects #9

Closed flavio closed 3 years ago

flavio commented 3 years ago

Use cargo-generate to provide an easy way to create a new Kubewarden Rust based policy.

This lowers the barrier to begin writing new policies.

ereslibre commented 3 years ago

Created https://github.com/kubewarden/policy-rust-template. Still WIP. Will ping here when can be reviewed.

ereslibre commented 3 years ago

Done, you can try it like:

ereslibre@desktop ~/test> cargo-generate generate --git https://github.com/kubewarden/policy-rust-template.git
🤷   Project Name : my-policy
🔧   Creating project called `my-policy`...
✨   Done! New project created /home/ereslibre/test/my-policy

Then:

ereslibre@desktop ~/test> cd my-policy/
ereslibre@desktop ~/test> make

fmt and clippy should be happy with the default project. The given example is extremely simple and only tries to demarshal a Pod and check its name. If the pod name is invalid-pod-name it will be rejected, in any other case (other name, or cannot be unmarshaled to a pod, so it's any other type of resource), the request will be accepted.