Configurable package namespaces/prefixes#247
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for configurable package namespaces/prefixes across language generators.
- Switches codegen entrypoints to accept CodegenSettings and propagates PackageNamespace.
- Adjusts output paths/names for Java, .NET, NodeJS, and Python based on namespace.
- Adds CLI flags to pass per-language namespaces/prefixes.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/codegen/python.go | Accepts CodegenSettings, sets pkg.Name/Namespace, and derives Python package dir from namespace/name. |
| pkg/codegen/nodejs.go | Accepts CodegenSettings and sets pkg.Name/Namespace for NodeJS codegen. |
| pkg/codegen/language.go | Introduces PackageNamespace setting. |
| pkg/codegen/java.go | Accepts CodegenSettings, sets pkg.Name/Namespace, computes namespace-based paths; minor debug prints and error handling changes. |
| pkg/codegen/golang.go | Accepts CodegenSettings; continues to set pkg.Name for Go. |
| pkg/codegen/dotnet.go | Accepts CodegenSettings, sets pkg.Name/Namespace; updates generated namespace handling for C#. |
| pkg/codegen/codegen.go | Updates GenerateFunc signature and call site to pass CodegenSettings. |
| cmd/root.go | Adds CLI flags for per-language namespace/prefix configuration. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Refactor to pass full CodegenSettings to GenerateFunc
Reviewed `crd2pulumi/pkg/codegen/java.go` and `pulumi-java` codegen sources. Found in `pulumi-java` `GeneratePackage` path: `generateModuleContextMap` sets `BasePackage` to "com." + sanitizeImport(p.Namespace()) + "." when `BasePackage` is empty and `pkg.Namespace` is non-empty. Since `crd2pulumi` sets `pkg.Namespace` to "com.pulumiverse", pulumi-java prepends its own "com." producing "com.com.pulumiverse" → double com in output paths. Fix is to explicitly set the Java PackageInfo BasePackage to the provided PackageNamespace so the pulumi-java defaulting logic doesn’t add an extra "com.".
7c03541 to
2223242
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #247 +/- ##
==========================================
+ Coverage 75.98% 76.03% +0.04%
==========================================
Files 17 17
Lines 966 993 +27
==========================================
+ Hits 734 755 +21
- Misses 163 167 +4
- Partials 69 71 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Fixes: #246
Implemented according to the proposal I posted in #246.
Tested manually with the CertManager CRDs, with and without the new CLI option, for
nodejs,python,dotnetandjava. As it needs to be, without the namespace/prefix option, I could verify the default value was still used. With the new namespace/prefix option, the value was integrated correctly in the generated files.