Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn "preserve-unknown-fields" into serde_json::Value for more cases #76

Merged
merged 1 commit into from
Aug 2, 2022
Merged

Turn "preserve-unknown-fields" into serde_json::Value for more cases #76

merged 1 commit into from
Aug 2, 2022

Conversation

felipesere
Copy link
Contributor

While converting a FluxV2 Kustomization CRD into Rust I hit these cases of x-kubernetes-preserve-unknown-fields.

Signed-off-by: Felipe Sere <felipe.sere@truelayer.com>
@clux
Copy link
Member

clux commented Jul 28, 2022

hey, thanks a lot for fixing this, this is a great starting point for one of the many cases mentioned in #31

I am happy to merge this as is, but I am thinking we should probably change the default thing to use here should really be a HashMap<String, Value> rather than a Value direct for reasons outlined in kube-rs/kube#844

@clux
Copy link
Member

clux commented Aug 2, 2022

This definitely fixes parts of the flux crds which gave the following error

$ kopium kustomizations.kustomize.toolkit.fluxcd.io
Error: unsupported recursive array type for patchesStrategicMerge

where

              patchesStrategicMerge:
                description: Strategic merge patches, defined as inline YAML objects.
                items:
                  x-kubernetes-preserve-unknown-fields: true
                type: array

was part of the schema.

can see that this is meant to be a vector of some arbitrary data as per their docs:

        patchesStrategicMerge:
          - kind: Deployment
            apiVersion: apps/v1
            metadata:
              name: metrics-server
            spec:
              template:
                spec:
                  tolerations:
                    - key: "workload-type"
                      operator: "Equal"
                      value: "cluster-services"
                      effect: "NoSchedule"

and we are now (with this change) generating:

pub patchesStrategicMerge: Option<Vec<serde_json::Value>>

i think this should be generated as Option<Vec<HashMap<String, Value>>> rather than what we currently have since it's an array which has the items key implying a vec of objects.

Going to merge this and clean it up with a test case for a flux crd.
Thanks a lot for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants