Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/go_modules-f09ae0e873
Browse files Browse the repository at this point in the history
  • Loading branch information
rshade authored Jan 8, 2025
2 parents f5ce79c + d77b74b commit b02e567
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CHANGELOG

## Unreleased
## 1.5.4 (2024-11-13)

- NodeJS now uses correct input/output types for object metadata. (https://github.com/pulumi/crd2pulumi/issues/158)

## 1.5.3 (2024-09-30)

Expand Down
2 changes: 1 addition & 1 deletion pkg/codegen/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type ObjectMetaPatch = k8s.types.input.meta.v1.ObjectMetaPatch;
`

func GenerateNodeJS(pg *PackageGenerator, name string) (map[string]*bytes.Buffer, error) {
pkg := pg.SchemaPackage()
pkg := pg.SchemaPackageWithObjectMetaType()
oldName := pkg.Name
pkg.Name = name

Expand Down
23 changes: 23 additions & 0 deletions tests/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,29 @@ func TestKubernetesVersionNodeJs(t *testing.T) {
execCrd2Pulumi(t, "nodejs", "crds/k8sversion/mock_crd.yaml", validateVersion)
}

func TestNodeJsObjectMeta(t *testing.T) {
validateVersion := func(t *testing.T, path string) {
// enter and build the generated package
withDir(t, path, func() {
runRequireNoError(t, exec.Command("npm", "install"))
runRequireNoError(t, exec.Command("npm", "run", "build"))

filename := filepath.Join(path, "k8sversion", "test", "testResource.ts")
t.Logf("validating objectmeta type in %s", filename)

testResource, err := os.ReadFile(filename)
if err != nil {
t.Fatalf("expected to read generated NodeJS code: %s", err)
}

assert.Contains(t, string(testResource), "public readonly metadata!: pulumi.Output<outputs.meta.v1.ObjectMeta>;", "expected metadata output type")
assert.Contains(t, string(testResource), "metadata?: pulumi.Input<inputs.meta.v1.ObjectMeta>;", "expected metadata input type")
})
}

execCrd2Pulumi(t, "nodejs", "crds/k8sversion/mock_crd.yaml", validateVersion)
}

func withDir(t *testing.T, dir string, f func()) {
pwd, err := os.Getwd()
require.NoError(t, err)
Expand Down

0 comments on commit b02e567

Please sign in to comment.