Merge pull request #6376 from pulumi/mikhailshilkov/fsharp-stack-options

Support StackOptions in F# functions
This commit is contained in:
Mikhail Shilkov 2021-02-18 15:48:39 +01:00 committed by GitHub
commit be34dd68da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 13 deletions

View file

@ -3,9 +3,12 @@ CHANGELOG
## HEAD (Unreleased)
[sdk/dotnet] C# Automation API.
- [sdk/dotnet] C# Automation API.
[#5761](https://github.com/pulumi/pulumi/pull/5761)
- [sdk/dotnet] F# API to specify stack options.
[#5077](https://github.com/pulumi/pulumi/pull/5077)
## 2.21.0 (2021-02-17)
### Improvements

View file

@ -47,17 +47,18 @@ module Ops =
/// <summary>
/// Pulumi deployment functions.
/// </summary>
module Deployment =
module Deployment =
open System.Collections.Generic
open System.Threading.Tasks
/// <summary>
/// Runs a function as a Pulumi <see cref="Deployment" />.
/// Runs a task function as a Pulumi <see cref="Deployment" />.
/// Blocks internally until the provided function completes,
/// so that this function could be used directly from the main function.
/// StackOptions can be provided to the deployment.
/// </summary>
let run (f: unit -> IDictionary<string, obj>) =
Deployment.RunAsync (fun () -> f())
let runTaskWithOptions (f: unit -> Task<IDictionary<string, obj>>) options =
Deployment.RunAsync ((fun () -> f()), options)
|> Async.AwaitTask
|> Async.RunSynchronously
@ -65,11 +66,10 @@ module Deployment =
/// Runs an async function as a Pulumi <see cref="Deployment" />.
/// Blocks internally until the provided function completes,
/// so that this function could be used directly from the main function.
/// StackOptions can be provided to the deployment.
/// </summary>
let runAsync (f: unit -> Async<IDictionary<string, obj>>) =
Deployment.RunAsync (fun () -> f() |> Async.StartAsTask)
|> Async.AwaitTask
|> Async.RunSynchronously
let runAsyncWithOptions (f: unit -> Async<IDictionary<string, obj>>) options =
runTaskWithOptions (f >> Async.StartAsTask) options
/// <summary>
/// Runs a task function as a Pulumi <see cref="Deployment" />.
@ -77,9 +77,23 @@ module Deployment =
/// so that this function could be used directly from the main function.
/// </summary>
let runTask (f: unit -> Task<IDictionary<string, obj>>) =
Deployment.RunAsync (fun () -> f())
|> Async.AwaitTask
|> Async.RunSynchronously
runTaskWithOptions f null
/// <summary>
/// Runs an async function as a Pulumi <see cref="Deployment" />.
/// Blocks internally until the provided function completes,
/// so that this function could be used directly from the main function.
/// </summary>
let runAsync (f: unit -> Async<IDictionary<string, obj>>) =
runTask (f >> Async.StartAsTask)
/// <summary>
/// Runs a function as a Pulumi <see cref="Deployment" />.
/// Blocks internally until the provided function completes,
/// so that this function could be used directly from the main function.
/// </summary>
let run (f: unit -> IDictionary<string, obj>) =
runTask (f >> Task.FromResult)
/// <summary>
/// Module containing utility functions to work with <see cref="Output{T}" />'s.