diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cd8cb4fc..2c6bda9c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ CHANGELOG - Add overloads to Output.All in .NET [#4321](https://github.com/pulumi/pulumi/pull/4321) +- Add additional overloads to Deployment.RunAsync in .NET API. + [#4286](https://github.com/pulumi/pulumi/pull/4286) + ## 1.14.0 (2020-04-01) - Fix error related to side-by-side versions of `@pulumi/pulumi`. [#4235](https://github.com/pulumi/pulumi/pull/4235) diff --git a/sdk/dotnet/Pulumi/Deployment/Deployment.Runner.cs b/sdk/dotnet/Pulumi/Deployment/Deployment.Runner.cs index 9de9af397..d5967f342 100644 --- a/sdk/dotnet/Pulumi/Deployment/Deployment.Runner.cs +++ b/sdk/dotnet/Pulumi/Deployment/Deployment.Runner.cs @@ -45,9 +45,9 @@ namespace Pulumi return WhileRunningAsync(); } - public Task RunAsync(Func>> func) + public Task RunAsync(Func>> func, StackOptions? options) { - var stack = new Stack(func); + var stack = new Stack(func, options); RegisterTask("User program code.", stack.Outputs.DataTask); return WhileRunningAsync(); } diff --git a/sdk/dotnet/Pulumi/Deployment/Deployment_Run.cs b/sdk/dotnet/Pulumi/Deployment/Deployment_Run.cs index 915cc9488..be05d7214 100644 --- a/sdk/dotnet/Pulumi/Deployment/Deployment_Run.cs +++ b/sdk/dotnet/Pulumi/Deployment/Deployment_Run.cs @@ -12,8 +12,9 @@ namespace Pulumi public partial class Deployment { /// - /// for more details. + /// for more details. /// + /// Callback that creates stack resources. public static Task RunAsync(Action action) => RunAsync(() => { @@ -22,15 +23,26 @@ namespace Pulumi }); /// - /// for more details. + /// for more details. /// - /// - /// + /// Callback that creates stack resources. + /// A dictionary of stack outputs. public static Task RunAsync(Func> func) => RunAsync(() => Task.FromResult(func())); + + /// + /// for more details. + /// + /// Callback that creates stack resources. + public static Task RunAsync(Func func) + => RunAsync(async () => + { + await func(); + return ImmutableDictionary.Empty; + }); /// - /// is an + /// is an /// entry-point to a Pulumi application. .NET applications should perform all startup logic /// they need in their Main method and then end with: /// @@ -53,12 +65,14 @@ namespace Pulumi /// the running of the program are properly reported. Failure to do this may lead to the /// program ending early before all resources are properly registered. /// - /// The function passed to + /// The function passed to /// can optionally return an . The keys and values /// in this dictionary will become the outputs for the Pulumi Stack that is created. /// - public static Task RunAsync(Func>> func) - => CreateRunner().RunAsync(func); + /// Callback that creates stack resources. + /// Stack options. + public static Task RunAsync(Func>> func, StackOptions? options = null) + => CreateRunner().RunAsync(func, options); /// /// is an entry-point to a Pulumi diff --git a/sdk/dotnet/Pulumi/Deployment/IRunner.cs b/sdk/dotnet/Pulumi/Deployment/IRunner.cs index 95df84690..716f71d19 100644 --- a/sdk/dotnet/Pulumi/Deployment/IRunner.cs +++ b/sdk/dotnet/Pulumi/Deployment/IRunner.cs @@ -9,7 +9,7 @@ namespace Pulumi internal interface IRunner { void RegisterTask(string description, Task task); - Task RunAsync(Func>> func); + Task RunAsync(Func>> func, StackOptions? options); Task RunAsync() where TStack : Stack, new(); } } diff --git a/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt b/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt index 8cb2998fa..4c6f15ddf 100644 --- a/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt +++ b/sdk/dotnet/Pulumi/PublicAPI.Unshipped.txt @@ -227,7 +227,8 @@ static Pulumi.CustomResourceOptions.Merge(Pulumi.CustomResourceOptions options1, static Pulumi.Deployment.Instance.get -> Pulumi.IDeployment static Pulumi.Deployment.RunAsync(System.Action action) -> System.Threading.Tasks.Task static Pulumi.Deployment.RunAsync(System.Func> func) -> System.Threading.Tasks.Task -static Pulumi.Deployment.RunAsync(System.Func>> func) -> System.Threading.Tasks.Task +static Pulumi.Deployment.RunAsync(System.Func func) -> System.Threading.Tasks.Task +static Pulumi.Deployment.RunAsync(System.Func>> func, Pulumi.StackOptions options = null) -> System.Threading.Tasks.Task static Pulumi.Deployment.RunAsync() -> System.Threading.Tasks.Task static Pulumi.Deployment.TestAsync(Pulumi.Testing.IMocks mocks, Pulumi.Testing.TestOptions options = null) -> System.Threading.Tasks.Task> static Pulumi.Input.implicit operator Pulumi.Input(Pulumi.Output value) -> Pulumi.Input diff --git a/sdk/dotnet/Pulumi/Stack.cs b/sdk/dotnet/Pulumi/Stack.cs index 1f43a0145..86bcb4919 100644 --- a/sdk/dotnet/Pulumi/Stack.cs +++ b/sdk/dotnet/Pulumi/Stack.cs @@ -63,7 +63,7 @@ namespace Pulumi /// An instance of this will be automatically created when any overload is called. /// - internal Stack(Func>> init) : this() + internal Stack(Func>> init, StackOptions? options) : this(options) { try {