krisnova / naml

Convert Kubernetes YAML to Golang
Apache License 2.0
1.26k stars 38 forks source link

codify: replace valast.Addr(v).(*T) with k8s.io/utils/pointer equivalents? #83

Open dnwe opened 2 years ago

dnwe commented 2 years ago

👋🏻 Firstly, thank you so much for naml — it is wonderful!


It would be great if the codify-generated code could avoid the runtime dependency on valast by using the k8s.io/utils/pointer package for getting pointers to a primitive:

e.g.,

-valast.Addr(false).(*bool)
+pointer.Bool(false)
-valast.Addr(int64(65534)).(*int64)
+pointer.Int64(65534)

etc.

This also produces more readable code.

Obviously there's no built-in support in valast for customising the generated ast so it would have to be a post-processing task done in codify itself

krisnova commented 2 years ago

interested in opening a PR for this?

this change seems reasonable to me