kubewarden / policy-sdk-go

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

Unmarshal policy Settings via `encoding/json` #12

Open flavio opened 3 years ago

flavio commented 3 years ago

Old versions of TinyGo didn't support the encoding/json package, because of that the task of extracting the policy settings was pretty painful.

This can be seen here.

The purpose of this card is to evaluate if, thanks to the recent changes inside of TinyGo, policy authors can now unmarshall the bytes holding the Settings objects straight into a native Go structure.

For example, in go-policy-template, this would mean changing the following block and defining a struct that contains your settings. Then, unmarshall the payload in validateSettings and validate the settings in the go native struct. This may also mean removing calls to gjson such as this one.

Acceptance criteria