Skip to content

Commit

Permalink
Fix the p-k provider to v4.18.0 for Python packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rquitales committed Sep 16, 2024
1 parent ba0c77c commit 45bf185
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pkg/codegen/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ func GenerateNodeJS(pg *PackageGenerator, name string) (map[string]*bytes.Buffer
}
files["utilities.ts"] = bytes.ReplaceAll(utilities,
[]byte("export function getVersion(): string {"),
[]byte(`export const getVersion: () => string = () => "4.18.0"
[]byte(fmt.Sprintf(`export const getVersion: () => string = () => "%s"
function unusedGetVersion(): string {`),
)
function unusedGetVersion(): string {`, KubernetesProviderVersion)))

// Create a helper `meta/v1.ts` script that exports the ObjectMeta class from the SDK. If there happens to already
// be a `meta/v1.ts` file, then just append the script.
Expand Down
4 changes: 4 additions & 0 deletions pkg/codegen/packagegenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

const (
KubernetesProviderVersion string = "4.18.0"
)

// PackageGenerator generates code for multiple CustomResources
type PackageGenerator struct {
// CustomResourceGenerators contains a slice of all CustomResourceGenerators
Expand Down
3 changes: 3 additions & 0 deletions pkg/codegen/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func GeneratePython(pg *PackageGenerator, name string) (map[string]*bytes.Buffer

buffers := map[string]*bytes.Buffer{}
for name, code := range files {
if name == "pyproject.toml" {
code = bytes.ReplaceAll(code, []byte(`0.0.0+dev`), []byte(KubernetesProviderVersion))
}
buffers[name] = bytes.NewBuffer(code)
}
return buffers, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/codegen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func genPackage(version string, crgenerators []CustomResourceGenerator, includeO
// This will only currently work for Go and Python as they have the correct annotations to serialize/deserialize
// the hyphenated fields to their non-hyphenated equivalents.
// See: https://github.com/pulumi/crd2pulumi/issues/43
pkgSpec := gen.PulumiSchema(unstructuredOpenAPISchema, gen.WithAllowHyphens(true), gen.WithPulumiKubernetesDependency("4.18.0"))
pkgSpec := gen.PulumiSchema(unstructuredOpenAPISchema, gen.WithAllowHyphens(true), gen.WithPulumiKubernetesDependency(KubernetesProviderVersion))

// Populate the package spec with information used in previous versions of crd2pulumi to maintain consistency
// with older versions.
Expand Down
3 changes: 2 additions & 1 deletion tests/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"

"github.com/pulumi/crd2pulumi/cmd"
"github.com/pulumi/crd2pulumi/pkg/codegen"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -243,7 +244,7 @@ func TestKubernetesVersionNodeJs(t *testing.T) {

version, err := exec.Command("node", "bin/index.js").Output()
require.NoError(t, err)
assert.Equal(t, "4.18.0\n", string(version))
assert.Equal(t, codegen.KubernetesProviderVersion+"\n", string(version))
})
}

Expand Down

0 comments on commit 45bf185

Please sign in to comment.