pulumi / crd2pulumi

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

Support for Generating Code in Directory #19

Open rawkode opened 3 years ago

rawkode commented 3 years ago

I'm using the following command to generate Pulumi types for Cluster API components.

./crd2pulumi --nodejsName capp --nodejsPath ./src/capp ./capp-components.yaml --force

This creates a utilities.{ts,js} that has code for loading the Node version from package.json.

This code fails if the code is generated into a subdirectory of the node project.

It would be cool if we could provide another flag to provide a subpath to store the generated code

leezen commented 3 years ago

Could you please clarify what you're trying to do? crd2pulumi generates a package on your behalf, which will have its own package.json and this is what utilities.{ts,js} refers to. You should have your own package.json for your application.

rawkode commented 3 years ago

I already have code in my directory / repo, and I want to generate the types into a directory of an existing project.

leezen commented 3 years ago

Looking at this further, it's awkward since the package.json generated by crd2pulumi doesn't actually have the right version information in it, so it's not really "ready" to be used out of the box via npm install ./<dir> yet at the same time, it's not really fulfilling your need of just having it in existing code. A bunch of this code generation is related to the underlying code generators for resource providers, so I think the right answer here is something along the lines of:

  1. Fix crd2pulumi so that package.json is actually meaningful.
  2. Provide an option to simply provide the code w/o trying to generate it like a package module.
ringods commented 3 years ago

@leezen I'm also in this group:

  1. Provide an option to simply provide the code w/o trying to generate it like a package module.

I want to integrate the generated files into an npm package containing our Pulumi abstractions so far.

Generating a new npm package for each CRD one wants to generate code for, forces us into setting up a build pipeline & release process for each of these npm projects.

jaxxstorm commented 3 years ago

I think this is important for some of the multi-language components we might want to build. It'll be super useful to be able to build this into the component libraries themself.

muhlba91 commented 3 years ago

same here. we are trying to integrate this into an existing package. it would be great if there's an option to disable generating an entire package or reading from package.json.