Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid lists of enums in .NET #16084

Open
thomas11 opened this issue Apr 29, 2024 · 0 comments
Open

Invalid lists of enums in .NET #16084

thomas11 opened this issue Apr 29, 2024 · 0 comments
Labels
area/codegen SDK-gen, program-gen, convert kind/bug Some behavior is incorrect or out of spec language/dotnet

Comments

@thomas11
Copy link
Contributor

What happened?

This is an upstream issue for pulumi/pulumi-azure-native#1180. Codegen for dotnet generates code that doesn't compile for some Azure examples. Unfortunately, among them are some of the important Azure Key Vault examples.

Example

The azure-native provider generates this HCL, pretty-printed from a github.com/pulumi/pulumi/pkg/v3/codegen/hcl2/model:Body.

resource vault "azure-native:keyvault:Vault" {
	location = "westus"
	properties = {
		accessPolicies = [{
			objectId = "00000000-0000-0000-0000-000000000000",
			permissions = {
				certificates = [
					"get",
					"list",
					"delete",
					"create",
					"import",
					"update",
					"managecontacts",
					"getissuers",
					"listissuers",
					"setissuers",
					"deleteissuers",
					"manageissuers",
					"recover",
					"purge"
				],
				keys = [
					"encrypt",
					"decrypt",
					"wrapKey",
					"unwrapKey",
					"sign",
					"verify",
					"get",
					"list",
					"create",
					"update",
					"import",
					"delete",
					"backup",
					"restore",
					"recover",
					"purge"
				],
				secrets = [
					"get",
					"list",
					"set",
					"delete",
					"backup",
					"restore",
					"recover",
					"purge"
				]
			},
			tenantId = "00000000-0000-0000-0000-000000000000"
		}],
		enabledForDeployment = true,
		enabledForDiskEncryption = true,
		enabledForTemplateDeployment = true,
		publicNetworkAccess = "Enabled",
		sku = {
			family = "A",
			name = "standard"
		},
		tenantId = "00000000-0000-0000-0000-000000000000"
	}
	resourceGroupName = "sample-resource-group"
	vaultName = "sample-vault"
}

The permissions are translated to C# like this (full program attached createVault.json.cs.txt):

                        Keys = new[]
                        {
                            AzureNative.KeyVault.KeyPermissions.Encrypt,
                            AzureNative.KeyVault.KeyPermissions.Decrypt,
...

Correct would be a union:

Secrets = {Union<string, AzureNative.KeyVault.SecretPermissions>.FromT1(AzureNative.KeyVault.SecretPermissions.All)}

Output of pulumi about

Still occurs with pulumi v3.113.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@thomas11 thomas11 added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Apr 29, 2024
@justinvp justinvp added area/codegen SDK-gen, program-gen, convert language/dotnet and removed needs-triage Needs attention from the triage team labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen SDK-gen, program-gen, convert kind/bug Some behavior is incorrect or out of spec language/dotnet
Projects
None yet
Development

No branches or pull requests

2 participants