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

[bug] The import function vendor crd not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf' #336

Open
yyvess opened this issue Feb 4, 2024 · 1 comment

Comments

@yyvess
Copy link
Contributor

yyvess commented Feb 4, 2024

The import function vendor crd not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf'

Not sure if the bug is on Timoni or in Cue, perhaps around it https://github.com/cue-lang/cue/blob/64a117c07a084f82970596f3ac67023087952f4f/encoding/jsonschema/constraints.go#L288 ?

Command used
timoni mod vendor crd -f https://raw.githubusercontent.com/istio/istio/1.20.2/manifests/charts/base/crds/crd-all.gen.yaml

As exemple the field method declared on the Istio crd to enforce that one and only one property exact, prefix or regex is defined as is

method: {
  oneOf: [{
    not: anyOf: [ { required: ["exact"]} , { required: ["prefix"]} , { required: ["regex"]}] },
    ,{required: ["exact"]}
    ,{required: ["prefix"]}
    ,{required: ["regex"]
  }]
  properties: {
	  exact: type: "string"
	  prefix: type: "string"
	  regex: { type: "string" }
  }
  type: "object"
}

The CUE output not corresponding and don't allow to set any property on method

method?: ({} | {
	exact: _
} | {
	prefix: _
} | {
	regex: _
}) & {
	exact?:  string
	prefix?: string
	regex?: string
}

@yyvess yyvess changed the title [import] The import function for CRD is not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf' [bug] The import function for CRD is not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf' Feb 4, 2024
@yyvess yyvess changed the title [bug] The import function for CRD is not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf' [bug] The import function vendor crd not correctly converting fields that have constraints 'oneOf', 'not', and 'anyOf' Feb 4, 2024
@stefanprodan
Copy link
Owner

stefanprodan commented Feb 5, 2024

This is tracked upstream here cue-lang/cue#2686 and cue-lang/cue#3165

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

No branches or pull requests

2 participants