-
Notifications
You must be signed in to change notification settings - Fork 17
Description
What happened?
I’m trying to generate code for the IngressRoute and Middleware CRDs from the Traefik Helm Chart. Based on the usage described in the README, it seems like you can only point crd2pulumi to a single file. My approach has been to generate code for each CRD yml file and then move the generated code into separate directories. If I import just one of the generated classes, my program works as expected. When I import both of the generated classes into the same Pulumi program, the planning step fails with the following error:
TypeError: Invalid Version:
at new SemVer (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/pulumi/node_modules/semver/semver.js:332:11)
at compare (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/pulumi/node_modules/semver/semver.js:647:10)
at Object.eq (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/pulumi/node_modules/semver/semver.js:693:10)
at sameVersion (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/runtime/rpc.ts:701:57)
at register (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/runtime/rpc.ts:716:17)
at Object.registerResourceModule (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/runtime/rpc.ts:810:5)
at Object.<anonymous> (/Users/blaisebradley/Code/rollout-embedded-poc/pulumi-crd/helm/middlewares/traefik/v1alpha1/index.ts:25:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module.m._compile (/Users/blaisebradley/Code/rollout-embedded-poc/node_modules/@pulumi/pulumi/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
My best guess is that there is some kind of conflict since we are trying to register the "resource module" traefik.containo.us/v1alpha1 twice with the same version number.
Expected Behavior
It's possible to import and use both classes in the same program.
Steps to reproduce
-
Run
crd2pulumiagainst two Traefik CRD files such as ingressroute.yaml and middlewares.yaml. -
Put the generated code in sibling directories. A screenshot of my directory structure is below:

-
Import both classes in the same Pulumi program:
import { IngressRoute as TraefikIngressRoute } from "../pulumi-crd/traefik/ingress-route/traefik/v1alpha1";
import { Middleware as TraefikMiddleware } from "../pulumi-crd/traefik/middlewares/traefik/v1alpha1";
- Attempt to create an instance of each resource:
const traefikMiddleware = new TraefikMiddleware(
"traefik-dashboard-auth",
{
apiVersion: "traefik.containo.us/v1alpha1",
kind: "Middleware",
metadata: {
name: "basic-auth",
namespace: traefikNamespace.metadata.name,
},
spec: {
basicAuth: { secret: traefikDashboardCreds.metadata.name },
},
},
{ provider: k8sProvider }
);
new TraefikIngressRoute(
"traefik-dashboard-route",
{
metadata: {
name: "dashboard",
namespace: traefikNamespace.metadata.name,
},
spec: {
entryPoints: ["web"],
routes: [
{
match:
"PathPrefix(`/dashboard`, `/dashboard/`) || PathPrefix(`/api`, `/api/`)",
kind: "Rule",
services: [{ name: "api@internal", kind: "TraefikService" }],
middlewares: [
{
name: traefikMiddleware.metadata.name as Output<string>,
namespace: traefikNamespace.metadata.name,
},
],
},
],
},
},
{ provider: k8sProvider }
);
Output of pulumi about
CLI
Version 3.60.1
Go Version go1.20.2
Go Compiler gc
Plugins
NAME VERSION
nodejs unknown
random 4.12.1
Host
OS darwin
Version 12.4
Arch arm64
This project is written in nodejs: executable='/Users/blaisebradley/.nvm/versions/node/v18.12.1/bin/node' version='v18.12.1'
Backend
Name pulumi.com
URL https://app.pulumi.com/blaiseb
User blaiseb
Organizations blaiseb, rollout
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).