Skip to content

kcl import --mode crd generates invalid KCL syntax from CRDs with multiple x-kubernetes-validations #2018

@czqrny

Description

@czqrny

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. create following file test.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tests.example.com
spec:
  group: example.com
  names:
    kind: Test
    listKind: TestList
    plural: tests
    singular: test
  scope: Namespaced
  versions:
  - deprecated: true
    name: v1
    schema:
      openAPIV3Schema:
        description: "test"
        properties:
          apiVersion:
            description: "test"
            type: string
          kind:
            description: "test"
            type: string
          metadata:
            type: object
          spec:
            description: "test"
            properties:
              test:
                description: test
                items:
                  description: test
                  items:
                    maxLength: 512
                    minLength: 1
                    type: string
                  maxItems: 100
                  minItems: 1
                  type: array
                maxItems: 100
                minItems: 1
                type: array
                x-kubernetes-list-type: atomic
            type: object
        type: object
    served: false
    storage: false
  1. Import this file wit crd mode to kcl
kcl import --mode crd test.yaml -o test
  1. invastigate generated file test/models/v1/example_com_v1_test_swagger.k the last check in schema

2. What did you expect to see? (Required)

This line should not contain an error and should look similar to this code:

        all n in test {len(test) <= 512 and len(test) >= 1 }  if test not in [None, Undefined]

3. What did you see instead (Required)

        all n in test {len(test) <= 512 if test not in [None, Undefined]len(test) >= 1 if test not in [None, Undefined] } if test

4. What is your KCL components version? (Required)

> kcl --version 
kcl version 0.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions