kube-rs / kopium

Kubernetes OPenapI UnMangler
Apache License 2.0
113 stars 21 forks source link

conditionally render status line #211

Closed sebhoss closed 8 months ago

sebhoss commented 8 months ago

I was trying to get the Istio resources working which do not specify their status fields but rather use x-kubernetes-preserve-unknown-fields. Currently kopium does not generate a XyzStatus struct for that but still adds a #[kube(status = "XyzStatus")] line to the spec struct which causes compile errors. This PR changes that so that the status line is only added if we have an actual status container and that container has members. In every other case, kopium does not generate a status struct and uses a BTreeMap instead which cannot be used in the #[kube(status = ...)] line.

I'm not entirely sure if this breaks anything else down the line, however I was able to generate & cargo check every custom resource in https://github.com/metio/kube-custom-resources-rs/pull/222 with this change.