From 38719d8312d55616d7ee3627ef60bed0dace01db Mon Sep 17 00:00:00 2001 From: amyxia Date: Tue, 14 Nov 2023 19:08:50 +0800 Subject: [PATCH] fix: wrong crd api version info (#68) Signed-off-by: amy --- pkg/kube_resource/generator/generator.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/kube_resource/generator/generator.go b/pkg/kube_resource/generator/generator.go index 40026dc..52d21ce 100644 --- a/pkg/kube_resource/generator/generator.go +++ b/pkg/kube_resource/generator/generator.go @@ -150,7 +150,12 @@ func buildSwagger(crd *apiextensions.CustomResourceDefinition) (*spec.Swagger, e if err != nil { return nil, err } - version := crd.Spec.Version + var version string + if len(crd.Spec.Versions) >= 0 { + version = crd.Spec.Versions[0].Name + } else { + version = crd.Spec.Version + } setKubeNative(&schema, group, version, kind) name := fmt.Sprintf("%s.%s.%s", group, version, kind) schemas[name] = schema