pulumi/tests/testdata/codegen/config-variables-pp/nodejs/config-variables.ts

16 lines
714 B
TypeScript
Raw Permalink Normal View History

[program-gen/go] Fix required config variables of type bool and number (#14958) # Description While covering more parts of go codegen, I've seen that config variables are broken 😓 specifically when requiring config variables using `RequireFloat` it should be `RequireFloat64` and `RequireBoolean` should be `RequireBool`. Moreover, it seems that `RequireObject` doesn't work at all since the function signature doesn't match the way it was generated (see #14957) C# has a similar issue with optional untyped objects as config variables. For now have skipped compilation for those. ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-20 13:16:37 +00:00
import * as pulumi from "@pulumi/pulumi";
const config = new pulumi.Config();
const requiredString = config.require("requiredString");
const requiredInt = config.requireNumber("requiredInt");
const requiredFloat = config.requireNumber("requiredFloat");
const requiredBool = config.requireBoolean("requiredBool");
const requiredAny = config.requireObject("requiredAny");
const optionalString = config.get("optionalString") || "defaultStringValue";
const optionalInt = config.getNumber("optionalInt") || 42;
const optionalFloat = config.getNumber("optionalFloat") || 3.14;
const optionalBool = config.getBoolean("optionalBool") || true;
const optionalAny = config.getObject("optionalAny") || {
key: "value",
};