pulumi / crd2pulumi

Generate typed CustomResources from a Kubernetes CustomResourceDefinition
Apache License 2.0
98 stars 17 forks source link

CRD for Percona Server for MongoDB Operator generates invalid typescript: #70

Closed headconnect closed 1 month ago

headconnect commented 2 years ago

Hello!

Issue details

I would like to generate typescript CRDs for Percona Server for MongoDB Operator.

Source CRD: https://github.com/percona/percona-server-mongodb-operator/blob/main/deploy/crd.yaml

Unfortunately, it generates invalid code - see generated psmdb\index.ts:

// *** WARNING: this file was generated by crd2pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

// Export sub-modules:
import * as v1 from "./v1";
import * as v1-1-0 from "./v1-1-0";
import * as v1-10-0 from "./v1-10-0";
import * as v1-11-0 from "./v1-11-0";
import * as v1-2-0 from "./v1-2-0";
import * as v1-3-0 from "./v1-3-0";
import * as v1-4-0 from "./v1-4-0";
import * as v1-5-0 from "./v1-5-0";
import * as v1-6-0 from "./v1-6-0";
import * as v1-7-0 from "./v1-7-0";
import * as v1-8-0 from "./v1-8-0";
import * as v1-9-0 from "./v1-9-0";
import * as v1alpha1 from "./v1alpha1";

export {
    v1,
    v1-1-0,
    v1-10-0,
    v1-11-0,
    v1-2-0,
    v1-3-0,
    v1-4-0,
    v1-5-0,
    v1-6-0,
    v1-7-0,
    v1-8-0,
    v1-9-0,
    v1alpha1,
};

This leads to typescript error ts(2300) with the message Duplicate identifier 'v1'

Steps to reproduce

  1. Download https://github.com/percona/percona-server-mongodb-operator/blob/main/deploy/crd.yaml
  2. execute crd2pulumi against it
  3. See typescript error

Expected:

I would expect crd2pulumi to ensure naming is valid for imports:

// This: 
import * as v1-1-0 from "./v1-1-0";
// Should be this: (replacing - with _)
import * as v1_1_0 from "./v1-1-0";

Actual: Produces invalid code.

cleverguy25 commented 2 months ago

Added to epic https://github.com/pulumi/home/issues/3431

pulumi-bot commented 2 weeks ago

This issue has been addressed in PR #143 and shipped in release v1.5.0.