diff --git a/sdk/dotnet/Authorization/Assignment.cs b/sdk/dotnet/Authorization/Assignment.cs index 826c9a12d1..81389c387b 100644 --- a/sdk/dotnet/Authorization/Assignment.cs +++ b/sdk/dotnet/Authorization/Assignment.cs @@ -287,7 +287,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:role/assignment:Assignment"}, + new global::Pulumi.Alias { Type = "azure:role/assignment:Assignment" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Authorization/RoleDefinition.cs b/sdk/dotnet/Authorization/RoleDefinition.cs index 88eed7f791..f15fd09f40 100644 --- a/sdk/dotnet/Authorization/RoleDefinition.cs +++ b/sdk/dotnet/Authorization/RoleDefinition.cs @@ -128,7 +128,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:role/definition:Definition"}, + new global::Pulumi.Alias { Type = "azure:role/definition:Definition" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Authorization/UserAssignedIdentity.cs b/sdk/dotnet/Authorization/UserAssignedIdentity.cs index d4b03a35ea..5d294f1ee2 100644 --- a/sdk/dotnet/Authorization/UserAssignedIdentity.cs +++ b/sdk/dotnet/Authorization/UserAssignedIdentity.cs @@ -118,7 +118,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:msi/userAssignedIdentity:UserAssignedIdentity"}, + new global::Pulumi.Alias { Type = "azure:msi/userAssignedIdentity:UserAssignedIdentity" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Cdn/FrontdoorCustomDomain.cs b/sdk/dotnet/Cdn/FrontdoorCustomDomain.cs index b729103de3..d0c62fa10f 100644 --- a/sdk/dotnet/Cdn/FrontdoorCustomDomain.cs +++ b/sdk/dotnet/Cdn/FrontdoorCustomDomain.cs @@ -162,7 +162,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:cdn/frontdoorCustomEndpoint:FrontdoorCustomEndpoint"}, + new global::Pulumi.Alias { Type = "azure:cdn/frontdoorCustomEndpoint:FrontdoorCustomEndpoint" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/ContainerService/RegistryWebhook.cs b/sdk/dotnet/ContainerService/RegistryWebhook.cs index 7f087054eb..0668a1ac19 100644 --- a/sdk/dotnet/ContainerService/RegistryWebhook.cs +++ b/sdk/dotnet/ContainerService/RegistryWebhook.cs @@ -152,7 +152,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:containerservice/registryWebook:RegistryWebook"}, + new global::Pulumi.Alias { Type = "azure:containerservice/registryWebook:RegistryWebook" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/EventGrid/Domain.cs b/sdk/dotnet/EventGrid/Domain.cs index 215b5b77f1..a1450845f8 100644 --- a/sdk/dotnet/EventGrid/Domain.cs +++ b/sdk/dotnet/EventGrid/Domain.cs @@ -172,7 +172,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/domain:Domain"}, + new global::Pulumi.Alias { Type = "azure:eventhub/domain:Domain" }, }, AdditionalSecretOutputs = { diff --git a/sdk/dotnet/EventGrid/EventSubscription.cs b/sdk/dotnet/EventGrid/EventSubscription.cs index a1e9ed6fb5..a8a6b8be4c 100644 --- a/sdk/dotnet/EventGrid/EventSubscription.cs +++ b/sdk/dotnet/EventGrid/EventSubscription.cs @@ -223,7 +223,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/eventSubscription:EventSubscription"}, + new global::Pulumi.Alias { Type = "azure:eventhub/eventSubscription:EventSubscription" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/EventGrid/Topic.cs b/sdk/dotnet/EventGrid/Topic.cs index dd6cbddb4c..4d6316f516 100644 --- a/sdk/dotnet/EventGrid/Topic.cs +++ b/sdk/dotnet/EventGrid/Topic.cs @@ -162,7 +162,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/eventGridTopic:EventGridTopic"}, + new global::Pulumi.Alias { Type = "azure:eventhub/eventGridTopic:EventGridTopic" }, }, AdditionalSecretOutputs = { diff --git a/sdk/dotnet/EventHub/AuthorizationRule.cs b/sdk/dotnet/EventHub/AuthorizationRule.cs index 052ba9f143..4a43c53acd 100644 --- a/sdk/dotnet/EventHub/AuthorizationRule.cs +++ b/sdk/dotnet/EventHub/AuthorizationRule.cs @@ -176,7 +176,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/eventHubAuthorizationRule:EventHubAuthorizationRule"}, + new global::Pulumi.Alias { Type = "azure:eventhub/eventHubAuthorizationRule:EventHubAuthorizationRule" }, }, AdditionalSecretOutputs = { diff --git a/sdk/dotnet/EventHub/ConsumerGroup.cs b/sdk/dotnet/EventHub/ConsumerGroup.cs index 0d3b33da58..f068a74bf9 100644 --- a/sdk/dotnet/EventHub/ConsumerGroup.cs +++ b/sdk/dotnet/EventHub/ConsumerGroup.cs @@ -124,7 +124,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/eventHubConsumerGroup:EventHubConsumerGroup"}, + new global::Pulumi.Alias { Type = "azure:eventhub/eventHubConsumerGroup:EventHubConsumerGroup" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/KeyVault/Certificate.cs b/sdk/dotnet/KeyVault/Certificate.cs index 17523fc962..9df3727270 100644 --- a/sdk/dotnet/KeyVault/Certificate.cs +++ b/sdk/dotnet/KeyVault/Certificate.cs @@ -390,7 +390,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:keyvault/certifiate:Certifiate"}, + new global::Pulumi.Alias { Type = "azure:keyvault/certifiate:Certifiate" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Management/Group.cs b/sdk/dotnet/Management/Group.cs index cb2faafc42..f4083a97bc 100644 --- a/sdk/dotnet/Management/Group.cs +++ b/sdk/dotnet/Management/Group.cs @@ -111,7 +111,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:managementgroups/managementGroup:ManagementGroup"}, + new global::Pulumi.Alias { Type = "azure:managementgroups/managementGroup:ManagementGroup" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Management/Lock.cs b/sdk/dotnet/Management/Lock.cs index 2b6ce1adf3..5d33023aa4 100644 --- a/sdk/dotnet/Management/Lock.cs +++ b/sdk/dotnet/Management/Lock.cs @@ -153,7 +153,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:managementresource/manangementLock:ManangementLock"}, + new global::Pulumi.Alias { Type = "azure:managementresource/manangementLock:ManangementLock" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Media/ServiceAccount.cs b/sdk/dotnet/Media/ServiceAccount.cs index 3da07360d3..730c0bfd13 100644 --- a/sdk/dotnet/Media/ServiceAccount.cs +++ b/sdk/dotnet/Media/ServiceAccount.cs @@ -148,7 +148,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:mediaservices/account:Account"}, + new global::Pulumi.Alias { Type = "azure:mediaservices/account:Account" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/MySql/FlexibleServerActiveDirectoryAdministratory.cs b/sdk/dotnet/MySql/FlexibleServerActiveDirectoryAdministratory.cs index 1a58aeb80a..6b84838e1d 100644 --- a/sdk/dotnet/MySql/FlexibleServerActiveDirectoryAdministratory.cs +++ b/sdk/dotnet/MySql/FlexibleServerActiveDirectoryAdministratory.cs @@ -52,7 +52,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:mysql/flexibleServerActiveDirectoryAdministrator:FlexibleServerActiveDirectoryAdministrator"}, + new global::Pulumi.Alias { Type = "azure:mysql/flexibleServerActiveDirectoryAdministrator:FlexibleServerActiveDirectoryAdministrator" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Network/TrafficManagerProfile.cs b/sdk/dotnet/Network/TrafficManagerProfile.cs index 3ca46a9113..6be98d6ebf 100644 --- a/sdk/dotnet/Network/TrafficManagerProfile.cs +++ b/sdk/dotnet/Network/TrafficManagerProfile.cs @@ -162,7 +162,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:trafficmanager/profile:Profile"}, + new global::Pulumi.Alias { Type = "azure:trafficmanager/profile:Profile" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Portal/Dashboard.cs b/sdk/dotnet/Portal/Dashboard.cs index ccf50c63c4..6a151eb295 100644 --- a/sdk/dotnet/Portal/Dashboard.cs +++ b/sdk/dotnet/Portal/Dashboard.cs @@ -229,7 +229,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:dashboard/dashboard:Dashboard"}, + new global::Pulumi.Alias { Type = "azure:dashboard/dashboard:Dashboard" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/Sentinel/AutomationRule.cs b/sdk/dotnet/Sentinel/AutomationRule.cs index 6bfa66158e..15f24bc2a9 100644 --- a/sdk/dotnet/Sentinel/AutomationRule.cs +++ b/sdk/dotnet/Sentinel/AutomationRule.cs @@ -169,7 +169,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:sentinel/authomationRule:AuthomationRule"}, + new global::Pulumi.Alias { Type = "azure:sentinel/authomationRule:AuthomationRule" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/ServiceBus/Namespace.cs b/sdk/dotnet/ServiceBus/Namespace.cs index b33a3eac7c..3ff5eec99c 100644 --- a/sdk/dotnet/ServiceBus/Namespace.cs +++ b/sdk/dotnet/ServiceBus/Namespace.cs @@ -186,7 +186,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/namespace:Namespace"}, + new global::Pulumi.Alias { Type = "azure:eventhub/namespace:Namespace" }, }, AdditionalSecretOutputs = { diff --git a/sdk/dotnet/ServiceBus/NamespaceAuthorizationRule.cs b/sdk/dotnet/ServiceBus/NamespaceAuthorizationRule.cs index 175dec4281..eb9cd737a8 100644 --- a/sdk/dotnet/ServiceBus/NamespaceAuthorizationRule.cs +++ b/sdk/dotnet/ServiceBus/NamespaceAuthorizationRule.cs @@ -153,7 +153,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/namespaceAuthorizationRule:NamespaceAuthorizationRule"}, + new global::Pulumi.Alias { Type = "azure:eventhub/namespaceAuthorizationRule:NamespaceAuthorizationRule" }, }, AdditionalSecretOutputs = { diff --git a/sdk/dotnet/ServiceBus/Queue.cs b/sdk/dotnet/ServiceBus/Queue.cs index c5d5704383..9290e43b44 100644 --- a/sdk/dotnet/ServiceBus/Queue.cs +++ b/sdk/dotnet/ServiceBus/Queue.cs @@ -201,7 +201,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/queue:Queue"}, + new global::Pulumi.Alias { Type = "azure:eventhub/queue:Queue" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/ServiceBus/QueueAuthorizationRule.cs b/sdk/dotnet/ServiceBus/QueueAuthorizationRule.cs index f994d46cc9..619aeb9109 100644 --- a/sdk/dotnet/ServiceBus/QueueAuthorizationRule.cs +++ b/sdk/dotnet/ServiceBus/QueueAuthorizationRule.cs @@ -159,7 +159,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/queueAuthorizationRule:QueueAuthorizationRule"}, + new global::Pulumi.Alias { Type = "azure:eventhub/queueAuthorizationRule:QueueAuthorizationRule" }, }, AdditionalSecretOutputs = { diff --git a/sdk/dotnet/ServiceBus/Subscription.cs b/sdk/dotnet/ServiceBus/Subscription.cs index 1ed2257c82..c08d9367f9 100644 --- a/sdk/dotnet/ServiceBus/Subscription.cs +++ b/sdk/dotnet/ServiceBus/Subscription.cs @@ -181,7 +181,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/subscription:Subscription"}, + new global::Pulumi.Alias { Type = "azure:eventhub/subscription:Subscription" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/ServiceBus/SubscriptionRule.cs b/sdk/dotnet/ServiceBus/SubscriptionRule.cs index 5c70047a6b..73cc707cf7 100644 --- a/sdk/dotnet/ServiceBus/SubscriptionRule.cs +++ b/sdk/dotnet/ServiceBus/SubscriptionRule.cs @@ -191,7 +191,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/subscriptionRule:SubscriptionRule"}, + new global::Pulumi.Alias { Type = "azure:eventhub/subscriptionRule:SubscriptionRule" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/ServiceBus/Topic.cs b/sdk/dotnet/ServiceBus/Topic.cs index ecf26bc024..f3314de4e1 100644 --- a/sdk/dotnet/ServiceBus/Topic.cs +++ b/sdk/dotnet/ServiceBus/Topic.cs @@ -174,7 +174,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/topic:Topic"}, + new global::Pulumi.Alias { Type = "azure:eventhub/topic:Topic" }, }, }; var merged = CustomResourceOptions.Merge(defaultOptions, options); diff --git a/sdk/dotnet/ServiceBus/TopicAuthorizationRule.cs b/sdk/dotnet/ServiceBus/TopicAuthorizationRule.cs index 598e42c478..01db2f65a4 100644 --- a/sdk/dotnet/ServiceBus/TopicAuthorizationRule.cs +++ b/sdk/dotnet/ServiceBus/TopicAuthorizationRule.cs @@ -158,7 +158,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? Version = Utilities.Version, Aliases = { - new global::Pulumi.Alias { Type = "azure:eventhub/topicAuthorizationRule:TopicAuthorizationRule"}, + new global::Pulumi.Alias { Type = "azure:eventhub/topicAuthorizationRule:TopicAuthorizationRule" }, }, AdditionalSecretOutputs = { diff --git a/sdk/go/azure/internal/pulumiUtilities.go b/sdk/go/azure/internal/pulumiUtilities.go index 68d4ea00a5..8e605c8381 100644 --- a/sdk/go/azure/internal/pulumiUtilities.go +++ b/sdk/go/azure/internal/pulumiUtilities.go @@ -15,6 +15,10 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) +import ( + "github.com/pulumi/pulumi/sdk/v3/go/pulumi/internals" +) + type envParser func(v string) interface{} func ParseEnvBool(v string) interface{} { @@ -90,6 +94,73 @@ func IsZero(v interface{}) bool { return reflect.ValueOf(v).IsZero() } +func CallPlain( + ctx *pulumi.Context, + tok string, + args pulumi.Input, + output pulumi.Output, + self pulumi.Resource, + property string, + resultPtr reflect.Value, + errorPtr *error, + opts ...pulumi.InvokeOption, +) { + res, err := callPlainInner(ctx, tok, args, output, self, opts...) + if err != nil { + *errorPtr = err + return + } + + v := reflect.ValueOf(res) + + // extract res.property field if asked to do so + if property != "" { + v = v.FieldByName("Res") + } + + // return by setting the result pointer; this style of returns shortens the generated code without generics + resultPtr.Elem().Set(v) +} + +func callPlainInner( + ctx *pulumi.Context, + tok string, + args pulumi.Input, + output pulumi.Output, + self pulumi.Resource, + opts ...pulumi.InvokeOption, +) (any, error) { + o, err := ctx.Call(tok, args, output, self, opts...) + if err != nil { + return nil, err + } + + outputData, err := internals.UnsafeAwaitOutput(ctx.Context(), o) + if err != nil { + return nil, err + } + + // Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency. + known := outputData.Known + value := outputData.Value + secret := outputData.Secret + + problem := "" + if !known { + problem = "an unknown value" + } else if secret { + problem = "a secret value" + } + + if problem != "" { + return nil, fmt.Errorf("Plain resource method %q incorrectly returned %s. "+ + "This is an error in the provider, please report this to the provider developer.", + tok, problem) + } + + return value, nil +} + // PkgResourceDefaultOpts provides package level defaults to pulumi.OptionResource. func PkgResourceDefaultOpts(opts []pulumi.ResourceOption) []pulumi.ResourceOption { defaults := []pulumi.ResourceOption{} diff --git a/sdk/nodejs/apimanagement/apiSchema.ts b/sdk/nodejs/apimanagement/apiSchema.ts index 7d15ed74c2..3f45341035 100644 --- a/sdk/nodejs/apimanagement/apiSchema.ts +++ b/sdk/nodejs/apimanagement/apiSchema.ts @@ -26,7 +26,7 @@ import * as utilities from "../utilities"; * resourceGroupName: exampleApi.then(exampleApi => exampleApi.resourceGroupName), * schemaId: "example-schema", * contentType: "application/vnd.ms-azure-apim.xsd+xml", - * value: fs.readFileSync("api_management_api_schema.xml"), + * value: fs.readFileSync("api_management_api_schema.xml", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/apimanagement/globalSchema.ts b/sdk/nodejs/apimanagement/globalSchema.ts index 34d0bdec7f..5b0439dff7 100644 --- a/sdk/nodejs/apimanagement/globalSchema.ts +++ b/sdk/nodejs/apimanagement/globalSchema.ts @@ -27,7 +27,7 @@ import * as utilities from "../utilities"; * apiManagementName: exampleService.name, * resourceGroupName: exampleResourceGroup.name, * type: "xml", - * value: fs.readFileSync("api_management_api_schema.xml"), + * value: fs.readFileSync("api_management_api_schema.xml", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/apimanagement/policy.ts b/sdk/nodejs/apimanagement/policy.ts index 5719f9cac3..039a75cc8b 100644 --- a/sdk/nodejs/apimanagement/policy.ts +++ b/sdk/nodejs/apimanagement/policy.ts @@ -32,7 +32,7 @@ import * as utilities from "../utilities"; * }); * const examplePolicy = new azure.apimanagement.Policy("examplePolicy", { * apiManagementId: exampleService.id, - * xmlContent: fs.readFileSync("example.xml"), + * xmlContent: fs.readFileSync("example.xml", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/appservice/functionAppFunction.ts b/sdk/nodejs/appservice/functionAppFunction.ts index 1b38aabb57..c963369b10 100644 --- a/sdk/nodejs/appservice/functionAppFunction.ts +++ b/sdk/nodejs/appservice/functionAppFunction.ts @@ -105,7 +105,7 @@ import * as utilities from "../utilities"; * language: "CSharp", * files: [{ * name: "run.csx", - * content: fs.readFileSync("exampledata/run.csx"), + * content: fs.readFileSync("exampledata/run.csx", "utf8"), * }], * testData: JSON.stringify({ * name: "Azure", diff --git a/sdk/nodejs/attestation/provider.ts b/sdk/nodejs/attestation/provider.ts index dce3686d32..d160c84f20 100644 --- a/sdk/nodejs/attestation/provider.ts +++ b/sdk/nodejs/attestation/provider.ts @@ -20,7 +20,7 @@ import * as utilities from "../utilities"; * const exampleProvider = new azure.attestation.Provider("exampleProvider", { * resourceGroupName: exampleResourceGroup.name, * location: exampleResourceGroup.location, - * policySigningCertificateData: fs.readFileSync("./example/cert.pem"), + * policySigningCertificateData: fs.readFileSync("./example/cert.pem", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/automation/connectionServicePrincipal.ts b/sdk/nodejs/automation/connectionServicePrincipal.ts index 9cfa9c915e..be9c415130 100644 --- a/sdk/nodejs/automation/connectionServicePrincipal.ts +++ b/sdk/nodejs/automation/connectionServicePrincipal.ts @@ -27,7 +27,7 @@ import * as utilities from "../utilities"; * applicationId: "00000000-0000-0000-0000-000000000000", * tenantId: exampleClientConfig.then(exampleClientConfig => exampleClientConfig.tenantId), * subscriptionId: exampleClientConfig.then(exampleClientConfig => exampleClientConfig.subscriptionId), - * certificateThumbprint: fs.readFileSync("automation_certificate_test.thumb"), + * certificateThumbprint: fs.readFileSync("automation_certificate_test.thumb", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/compute/extension.ts b/sdk/nodejs/compute/extension.ts index 83150f0f18..ac4855e99d 100644 --- a/sdk/nodejs/compute/extension.ts +++ b/sdk/nodejs/compute/extension.ts @@ -49,7 +49,7 @@ import * as utilities from "../utilities"; * networkInterfaceIds: [exampleNetworkInterface.id], * adminSshKeys: [{ * username: "adminuser", - * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub"), + * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"), * }], * osDisk: { * caching: "ReadWrite", diff --git a/sdk/nodejs/compute/linuxVirtualMachine.ts b/sdk/nodejs/compute/linuxVirtualMachine.ts index 90e99999f3..85e8669a17 100644 --- a/sdk/nodejs/compute/linuxVirtualMachine.ts +++ b/sdk/nodejs/compute/linuxVirtualMachine.ts @@ -58,7 +58,7 @@ import * as utilities from "../utilities"; * networkInterfaceIds: [exampleNetworkInterface.id], * adminSshKeys: [{ * username: "adminuser", - * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub"), + * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"), * }], * osDisk: { * caching: "ReadWrite", diff --git a/sdk/nodejs/compute/scaleSet.ts b/sdk/nodejs/compute/scaleSet.ts index b435520221..3c36b1be98 100644 --- a/sdk/nodejs/compute/scaleSet.ts +++ b/sdk/nodejs/compute/scaleSet.ts @@ -104,7 +104,7 @@ import * as utilities from "../utilities"; * disablePasswordAuthentication: true, * sshKeys: [{ * path: "/home/myadmin/.ssh/authorized_keys", - * keyData: fs.readFileSync("~/.ssh/demo_key.pub"), + * keyData: fs.readFileSync("~/.ssh/demo_key.pub", "utf8"), * }], * }, * networkProfiles: [{ @@ -171,7 +171,7 @@ import * as utilities from "../utilities"; * disablePasswordAuthentication: true, * sshKeys: [{ * path: "/home/myadmin/.ssh/authorized_keys", - * keyData: fs.readFileSync("~/.ssh/demo_key.pub"), + * keyData: fs.readFileSync("~/.ssh/demo_key.pub", "utf8"), * }], * }, * networkProfiles: [{ diff --git a/sdk/nodejs/compute/sshPublicKey.ts b/sdk/nodejs/compute/sshPublicKey.ts index f084a3085b..379b389593 100644 --- a/sdk/nodejs/compute/sshPublicKey.ts +++ b/sdk/nodejs/compute/sshPublicKey.ts @@ -17,7 +17,7 @@ import * as utilities from "../utilities"; * const example = new azure.compute.SshPublicKey("example", { * resourceGroupName: "example", * location: "West Europe", - * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub"), + * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/devtest/linuxVirtualMachine.ts b/sdk/nodejs/devtest/linuxVirtualMachine.ts index 760f18f644..3ce86b2878 100644 --- a/sdk/nodejs/devtest/linuxVirtualMachine.ts +++ b/sdk/nodejs/devtest/linuxVirtualMachine.ts @@ -38,7 +38,7 @@ import * as utilities from "../utilities"; * location: exampleResourceGroup.location, * size: "Standard_DS2", * username: "exampleuser99", - * sshKey: fs.readFileSync("~/.ssh/id_rsa.pub"), + * sshKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"), * labVirtualNetworkId: exampleVirtualNetwork.id, * labSubnetName: exampleVirtualNetwork.subnet.apply(subnet => subnet.name), * storageType: "Premium", diff --git a/sdk/nodejs/logicapps/integrationAccountAgreement.ts b/sdk/nodejs/logicapps/integrationAccountAgreement.ts index 731c955fbe..3f3999e8f1 100644 --- a/sdk/nodejs/logicapps/integrationAccountAgreement.ts +++ b/sdk/nodejs/logicapps/integrationAccountAgreement.ts @@ -44,7 +44,7 @@ import * as utilities from "../utilities"; * agreementType: "AS2", * hostPartnerName: host.name, * guestPartnerName: guest.name, - * content: fs.readFileSync("testdata/integration_account_agreement_content_as2.json"), + * content: fs.readFileSync("testdata/integration_account_agreement_content_as2.json", "utf8"), * hostIdentity: { * qualifier: "AS2Identity", * value: "FabrikamNY", diff --git a/sdk/nodejs/logicapps/integrationAccountMap.ts b/sdk/nodejs/logicapps/integrationAccountMap.ts index 1651b9354f..fa958e7022 100644 --- a/sdk/nodejs/logicapps/integrationAccountMap.ts +++ b/sdk/nodejs/logicapps/integrationAccountMap.ts @@ -24,7 +24,7 @@ import * as utilities from "../utilities"; * resourceGroupName: exampleResourceGroup.name, * integrationAccountName: exampleIntegrationAccount.name, * mapType: "Xslt", - * content: fs.readFileSync("testdata/integration_account_map_content.xsd"), + * content: fs.readFileSync("testdata/integration_account_map_content.xsd", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/logicapps/integrationAccountSchema.ts b/sdk/nodejs/logicapps/integrationAccountSchema.ts index 9a27ef97c4..0568926980 100644 --- a/sdk/nodejs/logicapps/integrationAccountSchema.ts +++ b/sdk/nodejs/logicapps/integrationAccountSchema.ts @@ -23,7 +23,7 @@ import * as utilities from "../utilities"; * const exampleIntegrationAccountSchema = new azure.logicapps.IntegrationAccountSchema("exampleIntegrationAccountSchema", { * resourceGroupName: exampleResourceGroup.name, * integrationAccountName: exampleIntegrationAccount.name, - * content: fs.readFileSync("testdata/integration_account_schema_content.xsd"), + * content: fs.readFileSync("testdata/integration_account_schema_content.xsd", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/maintenance/assignmentVirtualMachine.ts b/sdk/nodejs/maintenance/assignmentVirtualMachine.ts index 9e15f5bd44..5d41dbad42 100644 --- a/sdk/nodejs/maintenance/assignmentVirtualMachine.ts +++ b/sdk/nodejs/maintenance/assignmentVirtualMachine.ts @@ -42,7 +42,7 @@ import * as utilities from "../utilities"; * networkInterfaceIds: [exampleNetworkInterface.id], * adminSshKeys: [{ * username: "adminuser", - * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub"), + * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"), * }], * osDisk: { * caching: "ReadWrite", diff --git a/sdk/nodejs/management/groupTemplateDeployment.ts b/sdk/nodejs/management/groupTemplateDeployment.ts index d417a9617e..95b9008fcd 100644 --- a/sdk/nodejs/management/groupTemplateDeployment.ts +++ b/sdk/nodejs/management/groupTemplateDeployment.ts @@ -78,8 +78,8 @@ import * as utilities from "../utilities"; * const exampleGroupTemplateDeployment = new azure.management.GroupTemplateDeployment("exampleGroupTemplateDeployment", { * location: "West Europe", * managementGroupId: exampleGroup.then(exampleGroup => exampleGroup.id), - * templateContent: fs.readFileSync("templates/example-deploy-template.json"), - * parametersContent: fs.readFileSync("templates/example-deploy-params.json"), + * templateContent: fs.readFileSync("templates/example-deploy-template.json", "utf8"), + * parametersContent: fs.readFileSync("templates/example-deploy-params.json", "utf8"), * }); * ``` * diff --git a/sdk/nodejs/securitycenter/assessment.ts b/sdk/nodejs/securitycenter/assessment.ts index 18169a539f..53f1d848f2 100644 --- a/sdk/nodejs/securitycenter/assessment.ts +++ b/sdk/nodejs/securitycenter/assessment.ts @@ -35,7 +35,7 @@ import * as utilities from "../utilities"; * adminUsername: "adminuser", * adminSshKeys: [{ * username: "adminuser", - * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub"), + * publicKey: fs.readFileSync("~/.ssh/id_rsa.pub", "utf8"), * }], * sourceImageReference: { * publisher: "Canonical", diff --git a/sdk/nodejs/utilities.ts b/sdk/nodejs/utilities.ts index 2580a644db..080cc8287c 100644 --- a/sdk/nodejs/utilities.ts +++ b/sdk/nodejs/utilities.ts @@ -2,6 +2,9 @@ // *** Do not edit by hand unless you're certain you know what you are doing! *** +import * as runtime from "@pulumi/pulumi/runtime"; +import * as pulumi from "@pulumi/pulumi"; + export function getEnv(...vars: string[]): string | undefined { for (const v of vars) { const value = process.env[v]; @@ -64,3 +67,29 @@ export function lazyLoad(exports: any, props: string[], loadModule: any) { }); } } + +export async function callAsync( + tok: string, + props: pulumi.Inputs, + res?: pulumi.Resource, + opts?: {property?: string}, +): Promise { + const o: any = runtime.call(tok, props, res); + const value = await o.promise(true /*withUnknowns*/); + const isKnown = await o.isKnown; + const isSecret = await o.isSecret; + const problem: string|undefined = + !isKnown ? "an unknown value" + : isSecret ? "a secret value" + : undefined; + // Ingoring o.resources silently. They are typically non-empty, r.f() calls include r as a dependency. + if (problem) { + throw new Error(`Plain resource method "${tok}" incorrectly returned ${problem}. ` + + "This is an error in the provider, please report this to the provider developer."); + } + // Extract a single property if requested. + if (opts && opts.property) { + return value[opts.property]; + } + return value; +} diff --git a/sdk/python/pulumi_azure/_utilities.py b/sdk/python/pulumi_azure/_utilities.py index 2d9a3c846e..968f8f569b 100644 --- a/sdk/python/pulumi_azure/_utilities.py +++ b/sdk/python/pulumi_azure/_utilities.py @@ -3,6 +3,7 @@ # *** Do not edit by hand unless you're certain you know what you are doing! *** +import asyncio import importlib.util import inspect import json @@ -13,6 +14,7 @@ import pulumi import pulumi.runtime +from pulumi.runtime.sync_await import _sync_await from semver import VersionInfo as SemverVersion from parver import Version as PEP440Version @@ -246,5 +248,44 @@ def lifted_func(*args, opts=None, **kwargs): return (lambda _: lifted_func) + +def call_plain( + tok: str, + props: pulumi.Inputs, + res: typing.Optional[pulumi.Resource] = None, + typ: typing.Optional[type] = None, +) -> typing.Any: + """ + Wraps pulumi.runtime.plain to force the output and return it plainly. + """ + + output = pulumi.runtime.call(tok, props, res, typ) + + # Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency. + result, known, secret, _ = _sync_await(asyncio.ensure_future(_await_output(output))) + + problem = None + if not known: + problem = ' an unknown value' + elif secret: + problem = ' a secret value' + + if problem: + raise AssertionError( + f"Plain resource method '{tok}' incorrectly returned {problem}. " + + "This is an error in the provider, please report this to the provider developer." + ) + + return result + + +async def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bool, bool, set]: + return ( + await o._future, + await o._is_known, + await o._is_secret, + await o._resources, + ) + def get_plugin_download_url(): return None