Skip to content

Configurable package namespaces/prefixes#247

Merged
ringods merged 12 commits intomasterfrom
configurable-package-names
Oct 21, 2025
Merged

Configurable package namespaces/prefixes#247
ringods merged 12 commits intomasterfrom
configurable-package-names

Conversation

@ringods
Copy link
Member

@ringods ringods commented Oct 16, 2025

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, dotnet and java. 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@EronWright EronWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far

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.".
@ringods ringods force-pushed the configurable-package-names branch from 7c03541 to 2223242 Compare October 17, 2025 07:10
@ringods ringods marked this pull request as ready for review October 17, 2025 07:55
@ringods ringods requested a review from EronWright October 17, 2025 07:59
@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 86.27451% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.03%. Comparing base (beb9734) to head (bec27a5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/codegen/java.go 61.11% 5 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EronWright EronWright requested a review from Copilot October 17, 2025 16:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ringods ringods requested a review from EronWright October 21, 2025 20:19
@ringods ringods merged commit 87b0ef5 into master Oct 21, 2025
5 checks passed
@ringods ringods deleted the configurable-package-names branch October 21, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to have fully configurable package names

3 participants