cdk8s-team / cdk8s-cli

Apache License 2.0
37 stars 23 forks source link

CRDs with enums of type `array` cannot be imported #2335

Open ameyp opened 1 year ago

ameyp commented 1 year ago

Description of the bug:

If I attempt to import a CRD with an enum of type array, I get the following error:

Error: only enums with string or number values are supported

The specific CRD it's having trouble with is https://doc.crds.dev/github.com/redhat-cop/vault-config-operator/redhatcop.redhat.io/PKISecretEngineRole/v1alpha1@v0.3.1

Reproduction Steps:

cdk8s import https://doc.crds.dev/raw/github.com/redhat-cop/vault-config-operator@v0.3.1

Error Log:

Importing resources, this may take a few moments...
redhatcop.redhat.io
  redhatcop.redhat.io/authenginemount
  redhatcop.redhat.io/databasesecretengineconfig
  redhatcop.redhat.io/databasesecretenginerole
  redhatcop.redhat.io/githubsecretengineconfig
  redhatcop.redhat.io/githubsecretenginerole
  redhatcop.redhat.io/kubernetesauthengineconfig
  redhatcop.redhat.io/kubernetesauthenginerole
  redhatcop.redhat.io/passwordpolicy
  redhatcop.redhat.io/pkisecretengineconfig
  redhatcop.redhat.io/pkisecretenginerole
Error: only enums with string or number values are supported
    at TypeGenerator.emitTypeInternal (/usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:157:23)
    at TypeGenerator.typeForProperty (/usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:385:21)
    at TypeGenerator.emitProperty (/usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:324:35)
    at /usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:304:22
    at typesToEmit.<computed> (/usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:204:28)
    at TypeGenerator.renderToCode (/usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:238:33)
    at TypeGenerator.render (/usr/lib/node_modules/cdk8s-cli/node_modules/json2jsii/lib/type-generator.js:226:14)
    at CustomResourceDefinition.generateTypeScript (/usr/lib/node_modules/cdk8s-cli/lib/import/crd.js:87:29)
    at ImportCustomResourceDefinition.generateTypeScript (/usr/lib/node_modules/cdk8s-cli/lib/import/crd.js:130:23)
    at async ImportCustomResourceDefinition.import (/usr/lib/node_modules/cdk8s-cli/lib/import/base.js:71:13)

Environment:

Other:


This is :bug: Bug Report

ameyp commented 1 year ago

Looks like a duplicate of https://github.com/cdk8s-team/cdk8s-cli/issues/971