From bc2ca1f89f30e08d1bcf4b1e3d26caaae21cb102 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Thu, 17 Nov 2022 12:11:25 +0000 Subject: [PATCH 1/3] Qualify Resource type from Pulumi namespace The next release of Kubernetes (1.26.0) has an API named `resource`. In the .NET codegen, this will end up being a namespace `Resource`, clashing with the type name `Resource` which is implicitly in scope. To avoid this, give the Pulumi namespace an alias and use that to qualify the `Resource` type. Signed-off-by: Michael Bridgen --- provider/pkg/gen/dotnet-templates/helm/ChartBase.cs | 6 +++--- provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs | 3 ++- provider/pkg/gen/dotnet-templates/yaml/yaml.tmpl | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/provider/pkg/gen/dotnet-templates/helm/ChartBase.cs b/provider/pkg/gen/dotnet-templates/helm/ChartBase.cs index 647f5c2f20..769700566c 100644 --- a/provider/pkg/gen/dotnet-templates/helm/ChartBase.cs +++ b/provider/pkg/gen/dotnet-templates/helm/ChartBase.cs @@ -24,7 +24,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Text.Json; -using Pulumi; +using Pu = Pulumi; using Pulumi.Kubernetes.Yaml; using Pulumi.Utilities; @@ -260,8 +260,8 @@ private void Fetch(string chart, ChartFetchArgsUnwrap opts) } private Output> ParseTemplate(string text, - List transformations, string? resourcePrefix, ImmutableHashSet dependsOn, - string? defaultNamespace, Pulumi.ProviderResource provider) + List transformations, string? resourcePrefix, ImmutableHashSet dependsOn, + string? defaultNamespace, Pu.ProviderResource provider) { return Yaml.Invokes .YamlDecode(new YamlDecodeArgs { Text = text, DefaultNamespace = defaultNamespace }, new InvokeOptions { Provider = provider }) diff --git a/provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs b/provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs index 4deea87447..e9a52eace1 100644 --- a/provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs +++ b/provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs @@ -23,6 +23,7 @@ using System.Text.Json.Serialization; using Pulumi.Kubernetes.Yaml; using Pulumi.Utilities; +using Pu = Pulumi; namespace Pulumi.Kubernetes.Helm.V3 { @@ -289,7 +290,7 @@ private static string GetName(Union config, string re return string.IsNullOrEmpty(prefix) ? releaseName : $"{prefix}-{releaseName}"; } - private Output> ParseTemplate(Union args, string releaseName, ImmutableHashSet dependsOn, ComponentResourceOptions? options) + private Output> ParseTemplate(Union args, string releaseName, ImmutableHashSet dependsOn, ComponentResourceOptions? options) { // Build JSON args to Helm provider invoke. var serializeOptions = new JsonSerializerOptions diff --git a/provider/pkg/gen/dotnet-templates/yaml/yaml.tmpl b/provider/pkg/gen/dotnet-templates/yaml/yaml.tmpl index 3b5d660e10..307bac8a22 100644 --- a/provider/pkg/gen/dotnet-templates/yaml/yaml.tmpl +++ b/provider/pkg/gen/dotnet-templates/yaml/yaml.tmpl @@ -22,6 +22,7 @@ using System.IO; using System.Linq; using System.Text.Json; using GlobExpressions; +using Pu = Pulumi; #pragma warning disable CS0618 @@ -82,9 +83,9 @@ namespace Pulumi.Kubernetes.Yaml /// /// Returns an array of ready resources to be used by DependsOn. /// - public Output> Ready() + public Output> Ready() { - return Resources.Apply(resources => resources.Values.Cast().ToImmutableArray()); + return Resources.Apply(resources => resources.Values.Cast().ToImmutableArray()); } /// @@ -233,7 +234,7 @@ namespace Pulumi.Kubernetes.Yaml var opts = new CustomResourceOptions { Parent = options?.Parent, - DependsOn = options?.DependsOn ?? new InputList(), + DependsOn = options?.DependsOn ?? new InputList(), IgnoreChanges = options?.IgnoreChanges ?? new List(), Version = options?.Version, Provider = options?.Provider, From c91455a62083ab07d9e434d548065a33a66d2e3f Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Thu, 17 Nov 2022 12:17:22 +0000 Subject: [PATCH 2/3] Regenerate .NET SDK using updated templates make build This produces code equivalent to previously, but now the templates alias the Pulumi namespace so the `Resource` type won't clash with any upcoming `Resource` namespace. Signed-off-by: Michael Bridgen --- sdk/dotnet/Helm/ChartBase.cs | 6 +++--- sdk/dotnet/Helm/V3/Chart.cs | 3 ++- sdk/dotnet/Yaml/Yaml.cs | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sdk/dotnet/Helm/ChartBase.cs b/sdk/dotnet/Helm/ChartBase.cs index 647f5c2f20..769700566c 100644 --- a/sdk/dotnet/Helm/ChartBase.cs +++ b/sdk/dotnet/Helm/ChartBase.cs @@ -24,7 +24,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Text.Json; -using Pulumi; +using Pu = Pulumi; using Pulumi.Kubernetes.Yaml; using Pulumi.Utilities; @@ -260,8 +260,8 @@ private void Fetch(string chart, ChartFetchArgsUnwrap opts) } private Output> ParseTemplate(string text, - List transformations, string? resourcePrefix, ImmutableHashSet dependsOn, - string? defaultNamespace, Pulumi.ProviderResource provider) + List transformations, string? resourcePrefix, ImmutableHashSet dependsOn, + string? defaultNamespace, Pu.ProviderResource provider) { return Yaml.Invokes .YamlDecode(new YamlDecodeArgs { Text = text, DefaultNamespace = defaultNamespace }, new InvokeOptions { Provider = provider }) diff --git a/sdk/dotnet/Helm/V3/Chart.cs b/sdk/dotnet/Helm/V3/Chart.cs index 4deea87447..e9a52eace1 100644 --- a/sdk/dotnet/Helm/V3/Chart.cs +++ b/sdk/dotnet/Helm/V3/Chart.cs @@ -23,6 +23,7 @@ using System.Text.Json.Serialization; using Pulumi.Kubernetes.Yaml; using Pulumi.Utilities; +using Pu = Pulumi; namespace Pulumi.Kubernetes.Helm.V3 { @@ -289,7 +290,7 @@ private static string GetName(Union config, string re return string.IsNullOrEmpty(prefix) ? releaseName : $"{prefix}-{releaseName}"; } - private Output> ParseTemplate(Union args, string releaseName, ImmutableHashSet dependsOn, ComponentResourceOptions? options) + private Output> ParseTemplate(Union args, string releaseName, ImmutableHashSet dependsOn, ComponentResourceOptions? options) { // Build JSON args to Helm provider invoke. var serializeOptions = new JsonSerializerOptions diff --git a/sdk/dotnet/Yaml/Yaml.cs b/sdk/dotnet/Yaml/Yaml.cs index d302fc1dcb..89e3179334 100755 --- a/sdk/dotnet/Yaml/Yaml.cs +++ b/sdk/dotnet/Yaml/Yaml.cs @@ -22,6 +22,7 @@ using System.Linq; using System.Text.Json; using GlobExpressions; +using Pu = Pulumi; #pragma warning disable CS0618 @@ -740,9 +741,9 @@ public Output GetResource(string name, string? namespaceName = null) /// /// Returns an array of ready resources to be used by DependsOn. /// - public Output> Ready() + public Output> Ready() { - return Resources.Apply(resources => resources.Values.Cast().ToImmutableArray()); + return Resources.Apply(resources => resources.Values.Cast().ToImmutableArray()); } /// @@ -891,7 +892,7 @@ internal static Output> ParseYam var opts = new CustomResourceOptions { Parent = options?.Parent, - DependsOn = options?.DependsOn ?? new InputList(), + DependsOn = options?.DependsOn ?? new InputList(), IgnoreChanges = options?.IgnoreChanges ?? new List(), Version = options?.Version, Provider = options?.Provider, From 7669dfbbc050a3cdd51ad331b827b64d2c509d86 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Thu, 17 Nov 2022 12:25:01 +0000 Subject: [PATCH 3/3] Mention template change in CHANGELOG Signed-off-by: Michael Bridgen --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cab2e9dde..a3aa5bf0bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ ## Unreleased -- Add allowNullValues boolean option to pass Null values through helm configs without having them scrubbed (https://github.com/pulumi/pulumi-kubernetes/issues/2089) -- For SSA conflicts, add a note to the error message about how to resolve (https://github.com/pulumi/pulumi-kubernetes/issues/2235) +- Add allowNullValues boolean option to pass Null values through helm configs without having them + scrubbed (https://github.com/pulumi/pulumi-kubernetes/issues/2089) +- For SSA conflicts, add a note to the error message about how to resolve + (https://github.com/pulumi/pulumi-kubernetes/issues/2235) +- Make room for the `resource` API in Kubernetes 1.26.0 by qualifying the type of the same name in + .NET code templates (https://github.com/pulumi/pulumi-kubernetes/pull/2237) ## 3.22.1 (October 26, 2022)