pulumi/tests/testdata/codegen/config-variables-pp/dotnet/config-variables.cs

23 lines
836 B
C#
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
using System.Collections.Generic;
using System.Linq;
using Pulumi;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var requiredString = config.Require("requiredString");
var requiredInt = config.RequireInt32("requiredInt");
var requiredFloat = config.RequireDouble("requiredFloat");
var requiredBool = config.RequireBoolean("requiredBool");
var requiredAny = config.RequireObject<dynamic>("requiredAny");
var optionalString = config.Get("optionalString") ?? "defaultStringValue";
var optionalInt = config.GetInt32("optionalInt") ?? 42;
var optionalFloat = config.GetDouble("optionalFloat") ?? 3.14;
var optionalBool = config.GetBoolean("optionalBool") ?? true;
var optionalAny = config.GetObject<dynamic>("optionalAny") ??
{
{ "key", "value" },
};
});