-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] Unknowns for previews involving an uninitialized provider (#…
…2957) <!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md) for Pulumi's contribution guidelines. Help us merge your changes more quickly by adding more details such as labels, milestones, and reviewers.--> ### Proposed changes This PR fixes the "panic" that occurs when an uninitialized provider is used with the yaml/kustomize resources. In that situation, the invoke calls aren't performed and the engine simply returns an uninitialized result. This causes a problem in the callers because the methods on `ImmutableArray` mustn't be used when the value is uninitialized (`IsDefault` is true). ### Example The example given in #2741 easily repros the issue. With this fix, the behavior improves: ``` Diagnostics: kubernetes:yaml:ConfigFile (guestbook): warning: Required input properties have unknown values. Preview is incomplete. Outputs: FrontendIp: output<string> ``` ### Testing Includes integration tests involving an uninitialized provider with a `ConfigFile` or `Directory`. ### Related issues (optional) <!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes #1234'. Or link to full URLs to issues or pull requests in other GitHub repositories. --> Closes #2741
- Loading branch information
1 parent
ee61f79
commit 6eb4495
Showing
17 changed files
with
244 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/sdk/dotnet/kustomize-uninitialized-provider/KustomizeUninitializedProvider.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
35 changes: 35 additions & 0 deletions
35
tests/sdk/dotnet/kustomize-uninitialized-provider/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Kubernetes = Pulumi.Kubernetes; | ||
using Kustomize = Pulumi.Kubernetes.Kustomize; | ||
using CoreV1 = Pulumi.Kubernetes.Core.V1; | ||
using Pulumi; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
return await Deployment.RunAsync(() => | ||
{ | ||
// Create an uninitialized provider | ||
var provider = new Kubernetes.Provider("provider", new() | ||
{ | ||
KubeConfig = Pulumi.Utilities.OutputUtilities.CreateUnknown(""), | ||
}); | ||
// Create resources using Directory (and for which Invoke is skipped) | ||
var directory = new Kustomize.Directory("directory", | ||
new Kustomize.DirectoryArgs | ||
{ | ||
Directory = "kustomize", | ||
}, | ||
new ComponentResourceOptions | ||
{ | ||
Provider = provider | ||
}); | ||
// Lookup the registered service, to exercise the 'resources' output property. | ||
// During preview, we expect the stack outputs to be unknown. | ||
var service = directory.GetResource<CoreV1.Service>("kustomize-uninitialized-provider"); | ||
return new Dictionary<string, object?> | ||
{ | ||
["serviceUid"] = service.Apply(svc => svc.Metadata.Apply(meta => meta.Uid)), | ||
}; | ||
}); |
3 changes: 3 additions & 0 deletions
3
tests/sdk/dotnet/kustomize-uninitialized-provider/Pulumi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: dotnet_kustomize_uninitialized_provider | ||
description: A test of the kustomize resoures with an uninitialized provider | ||
runtime: dotnet |
5 changes: 5 additions & 0 deletions
5
tests/sdk/dotnet/kustomize-uninitialized-provider/kustomize/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
commonLabels: | ||
app: hello | ||
|
||
resources: | ||
- manifest.yaml |
7 changes: 7 additions & 0 deletions
7
tests/sdk/dotnet/kustomize-uninitialized-provider/kustomize/manifest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kustomize-uninitialized-provider | ||
spec: | ||
type: ExternalName | ||
externalName: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Kubernetes = Pulumi.Kubernetes; | ||
using Yaml = Pulumi.Kubernetes.Yaml; | ||
using CoreV1 = Pulumi.Kubernetes.Core.V1; | ||
using Pulumi; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
return await Deployment.RunAsync(() => | ||
{ | ||
// Create an uninitialized provider | ||
var provider = new Kubernetes.Provider("provider", new() | ||
{ | ||
KubeConfig = Pulumi.Utilities.OutputUtilities.CreateUnknown(""), | ||
}); | ||
// Create resources using ConfigFile (and for which Invoke is skipped) | ||
var manifest = new Yaml.ConfigFile("manifest", | ||
new Yaml.ConfigFileArgs | ||
{ | ||
File = "manifest.yaml", | ||
}, | ||
new ComponentResourceOptions | ||
{ | ||
Provider = provider | ||
}); | ||
// Lookup the registered service, to exercise the 'resources' output property. | ||
// During preview, we expect the stack outputs to be unknown. | ||
var service = manifest.GetResource<CoreV1.Service>("yaml-uninitialized-provider"); | ||
return new Dictionary<string, object?> | ||
{ | ||
["serviceUid"] = service.Apply(svc => svc.Metadata.Apply(meta => meta.Uid)), | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: dotnet_yaml_uninitialized_provider | ||
description: A test of the yaml resoures with an uninitialized provider | ||
runtime: dotnet |
8 changes: 8 additions & 0 deletions
8
tests/sdk/dotnet/yaml-uninitialized-provider/YamlUninitializedProvider.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: yaml-uninitialized-provider | ||
spec: | ||
type: ExternalName | ||
externalName: localhost |