'Kubernetes CRD structural schema for anyOf

I am currently using this CRD to rotate automatically deployments in k8s cluster whenever there is a change in AWS Secret Manager

https://github.com/aws-samples/aws-secret-sidecar-injector/blob/master/secret-operator/config/crd/bases/awssecretsoperator.secretoperator_secretsrotationmappings.yaml#L38-L41

          properties:
            Labels:
              additionalProperties:
                type: string
              type: object

I would like to extend this CRD to support either object with string property or array of objects where each item has string property.

I was thinking about using anyOf but then I have issues with structural schema validation. https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema

How should I modify this CRD ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source