Skip to content

Commit

Permalink
Qualify Pulumi.Resource type to stay out of the way of the resource
Browse files Browse the repository at this point in the history
… API in K8s v1.26.0 (#2237)

* 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 <mbridgen@pulumi.com>

* 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 <mbridgen@pulumi.com>
  • Loading branch information
squaremo committed Nov 22, 2022
1 parent f69a510 commit e25e091
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
8 changes: 6 additions & 2 deletions 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)

Expand Down
6 changes: 3 additions & 3 deletions provider/pkg/gen/dotnet-templates/helm/ChartBase.cs
Expand Up @@ -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;

Expand Down Expand Up @@ -260,8 +260,8 @@ private void Fetch(string chart, ChartFetchArgsUnwrap opts)
}

private Output<ImmutableDictionary<string, KubernetesResource>> ParseTemplate(string text,
List<TransformationAction> transformations, string? resourcePrefix, ImmutableHashSet<Resource> dependsOn,
string? defaultNamespace, Pulumi.ProviderResource provider)
List<TransformationAction> transformations, string? resourcePrefix, ImmutableHashSet<Pu.Resource> dependsOn,
string? defaultNamespace, Pu.ProviderResource provider)
{
return Yaml.Invokes
.YamlDecode(new YamlDecodeArgs { Text = text, DefaultNamespace = defaultNamespace }, new InvokeOptions { Provider = provider })
Expand Down
3 changes: 2 additions & 1 deletion provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs
Expand Up @@ -23,6 +23,7 @@
using System.Text.Json.Serialization;
using Pulumi.Kubernetes.Yaml;
using Pulumi.Utilities;
using Pu = Pulumi;

namespace Pulumi.Kubernetes.Helm.V3
{
Expand Down Expand Up @@ -289,7 +290,7 @@ private static string GetName(Union<ChartArgs, LocalChartArgs> config, string re
return string.IsNullOrEmpty(prefix) ? releaseName : $"{prefix}-{releaseName}";
}

private Output<ImmutableDictionary<string, KubernetesResource>> ParseTemplate(Union<ChartArgsUnwrap, LocalChartArgsUnwrap> args, string releaseName, ImmutableHashSet<Resource> dependsOn, ComponentResourceOptions? options)
private Output<ImmutableDictionary<string, KubernetesResource>> ParseTemplate(Union<ChartArgsUnwrap, LocalChartArgsUnwrap> args, string releaseName, ImmutableHashSet<Pu.Resource> dependsOn, ComponentResourceOptions? options)
{
// Build JSON args to Helm provider invoke.
var serializeOptions = new JsonSerializerOptions
Expand Down
7 changes: 4 additions & 3 deletions provider/pkg/gen/dotnet-templates/yaml/yaml.tmpl
Expand Up @@ -22,6 +22,7 @@ using System.IO;
using System.Linq;
using System.Text.Json;
using GlobExpressions;
using Pu = Pulumi;

#pragma warning disable CS0618

Expand Down Expand Up @@ -82,9 +83,9 @@ namespace Pulumi.Kubernetes.Yaml
/// <summary>
/// Returns an array of ready resources to be used by DependsOn.
/// </summary>
public Output<ImmutableArray<Resource>> Ready()
public Output<ImmutableArray<Pu.Resource>> Ready()
{
return Resources.Apply(resources => resources.Values.Cast<Resource>().ToImmutableArray());
return Resources.Apply(resources => resources.Values.Cast<Pu.Resource>().ToImmutableArray());
}

/// <summary>
Expand Down Expand Up @@ -233,7 +234,7 @@ namespace Pulumi.Kubernetes.Yaml
var opts = new CustomResourceOptions
{
Parent = options?.Parent,
DependsOn = options?.DependsOn ?? new InputList<Resource>(),
DependsOn = options?.DependsOn ?? new InputList<Pu.Resource>(),
IgnoreChanges = options?.IgnoreChanges ?? new List<string>(),
Version = options?.Version,
Provider = options?.Provider,
Expand Down
6 changes: 3 additions & 3 deletions sdk/dotnet/Helm/ChartBase.cs
Expand Up @@ -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;

Expand Down Expand Up @@ -260,8 +260,8 @@ private void Fetch(string chart, ChartFetchArgsUnwrap opts)
}

private Output<ImmutableDictionary<string, KubernetesResource>> ParseTemplate(string text,
List<TransformationAction> transformations, string? resourcePrefix, ImmutableHashSet<Resource> dependsOn,
string? defaultNamespace, Pulumi.ProviderResource provider)
List<TransformationAction> transformations, string? resourcePrefix, ImmutableHashSet<Pu.Resource> dependsOn,
string? defaultNamespace, Pu.ProviderResource provider)
{
return Yaml.Invokes
.YamlDecode(new YamlDecodeArgs { Text = text, DefaultNamespace = defaultNamespace }, new InvokeOptions { Provider = provider })
Expand Down
3 changes: 2 additions & 1 deletion sdk/dotnet/Helm/V3/Chart.cs
Expand Up @@ -23,6 +23,7 @@
using System.Text.Json.Serialization;
using Pulumi.Kubernetes.Yaml;
using Pulumi.Utilities;
using Pu = Pulumi;

namespace Pulumi.Kubernetes.Helm.V3
{
Expand Down Expand Up @@ -289,7 +290,7 @@ private static string GetName(Union<ChartArgs, LocalChartArgs> config, string re
return string.IsNullOrEmpty(prefix) ? releaseName : $"{prefix}-{releaseName}";
}

private Output<ImmutableDictionary<string, KubernetesResource>> ParseTemplate(Union<ChartArgsUnwrap, LocalChartArgsUnwrap> args, string releaseName, ImmutableHashSet<Resource> dependsOn, ComponentResourceOptions? options)
private Output<ImmutableDictionary<string, KubernetesResource>> ParseTemplate(Union<ChartArgsUnwrap, LocalChartArgsUnwrap> args, string releaseName, ImmutableHashSet<Pu.Resource> dependsOn, ComponentResourceOptions? options)
{
// Build JSON args to Helm provider invoke.
var serializeOptions = new JsonSerializerOptions
Expand Down
7 changes: 4 additions & 3 deletions sdk/dotnet/Yaml/Yaml.cs
Expand Up @@ -22,6 +22,7 @@
using System.Linq;
using System.Text.Json;
using GlobExpressions;
using Pu = Pulumi;

#pragma warning disable CS0618

Expand Down Expand Up @@ -740,9 +741,9 @@ public Output<T> GetResource<T>(string name, string? namespaceName = null)
/// <summary>
/// Returns an array of ready resources to be used by DependsOn.
/// </summary>
public Output<ImmutableArray<Resource>> Ready()
public Output<ImmutableArray<Pu.Resource>> Ready()
{
return Resources.Apply(resources => resources.Values.Cast<Resource>().ToImmutableArray());
return Resources.Apply(resources => resources.Values.Cast<Pu.Resource>().ToImmutableArray());
}

/// <summary>
Expand Down Expand Up @@ -891,7 +892,7 @@ internal static bool IsUrl(string s)
var opts = new CustomResourceOptions
{
Parent = options?.Parent,
DependsOn = options?.DependsOn ?? new InputList<Resource>(),
DependsOn = options?.DependsOn ?? new InputList<Pu.Resource>(),
IgnoreChanges = options?.IgnoreChanges ?? new List<string>(),
Version = options?.Version,
Provider = options?.Provider,
Expand Down

0 comments on commit e25e091

Please sign in to comment.