stefanprodan / timoni

Timoni is a package manager for Kubernetes, powered by CUE and inspired by Helm.
https://timoni.sh
Apache License 2.0
1.53k stars 68 forks source link

Schema error on object type from imported CRD #353

Open markphillips100 opened 7 months ago

markphillips100 commented 7 months ago

Pretty new to timoni and cue so still learning. I've a validation issue that occurs from running timoni mod vet related to the following setup. Whilst it is a schema error, I am uncertain if the CRD itself is at fault or the underlying cue generation.

The Problem I see pretty much exactly what is described in issue #278 . Generated properties for type "object" result in a {} rather than {...} being assigned. I only conclude this as I'm using this repo as a reference and its generated object properties are using the latter syntax with no schema errors. Example here

My Setup timoni version: api: timoni.sh/v1alpha1 client: 0.19.0 cue: 0.7.0

  1. Fetch Crossplane master
  2. Import CRD yaml: timoni mod vendor crds -f <repo>\cluster\crds\apiextensions.crossplane.io_composition.yaml
  3. Define a minimal schema to use a Composition schema from api "apiextensions.crossplane.io/composition/v1". Relevant CRD and schema code below. The error is related to a property defined as input?: {} in the generated schema.

CRD defines "input" as:

input:
   description: |-
      Input is an optional, arbitrary Kubernetes resource (i.e. a resource
      with an apiVersion and kind) that will be passed to the Composition
      Function as the 'input' of its RunFunctionRequest.
   type: object
   x-kubernetes-embedded-resource: true
   x-kubernetes-preserve-unknown-fields: true

Minimal schema to reproduce error:

package templates

import (
    crossplane "apiextensions.crossplane.io/composition/v1"
)

#SampleComposition: crossplane.#Composition & {
    spec: {
        pipeline: [
            {
                input: {
                    apiVersion: "pt.fn.crossplane.io/v1beta1"
                }
            }
        ]
    }
}
markphillips100 commented 7 months ago

Not sure if this is related but I also don't see an actual schema defined when a Crossplane CompositeResourceDefinition CRD is imported either. The CRD defines openAPIV3Schema as shown here and yet the cue type produces openApiV3Schema?: {} which again causes mod validation errors.