-
Notifications
You must be signed in to change notification settings - Fork 153
Closed
kcl-lang/kcl-openapi
#120Description
Bug Report
1. Minimal reproduce step (Required)
- Create a file named
crds.yamlwith the following content:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: foo.example.com
spec:
group: example.com
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
field1:
type: string
scope: Namespaced
names:
plural: foo
singular: foo
kind: Foo
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: bar.example.com
spec:
group: example.com
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
field2:
type: string
scope: Namespaced
names:
plural: bar
singular: bar
kind: Bar- Run the following command:
kcl import -m crd -s crds.yaml
2. What did you expect to see? (Required)
The models directory should be generated with the following structure:
models
├── k8s
│ └── apimachinery
│ └── pkg
│ └── apis
│ └── meta
│ └── v1
│ ├── managed_fields_entry.k
│ ├── object_meta.k
│ └── owner_reference.k
├── kcl.mod
├── kcl.mod.lock
└── v1
├── example_com_v1_bar.k
└── example_com_v1_foo.k
3. What did you see instead (Required)
The command produces the following error:
2024/08/23 10:44:49 import.go:82: [ERROR] could not generate swagger spec: crds.yaml, err: couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }
The models directory is generated, but it's incomplete.
4. What is your KCL components version? (Required)
0.10.0-beta.2
Additional Information:
- If the
crds.yamlfile contains only one CRD without the---separator, the import works correctly. - Even with a single CRD, if the
---separator is present, the same error occurs. - This issue prevents users from easily importing multiple CRDs from a single file, which is a common format provided by CRD repositories and APIs. For example, it hinders the ability to directly import CRDs from sources like https://doc.crds.dev/raw/github.com/crossplane/crossplane, which returns multiple CRDs separated by
---.
Metadata
Metadata
Assignees
Labels
No labels