Skip to content

Commit

Permalink
Flip transforms to non-experimental (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed Apr 29, 2024
1 parent 1f6a293 commit 8104752
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Improvements-270.yaml
@@ -0,0 +1,6 @@
component: sdk
kind: Improvements
body: Transforms are now stable, not experimental.
time: 2024-04-29T09:32:15.862863+01:00
custom:
PR: "270"
10 changes: 5 additions & 5 deletions integration_tests/transformations_remote/Program.cs
Expand Up @@ -20,12 +20,12 @@ public MyComponent(string name, ComponentResourceOptions? options = null)

class TransformsStack : Stack
{
public TransformsStack() : base(new StackOptions { XResourceTransforms = {Scenario3} })
public TransformsStack() : base(new StackOptions { ResourceTransforms = {Scenario3} })
{
// Scenario #1 - apply a transformation to a CustomResource
var res1 = new Random("res1", new RandomArgs { Length = 5 }, new CustomResourceOptions
{
XResourceTransforms =
ResourceTransforms =
{
async (args, _) =>
{
Expand All @@ -40,7 +40,7 @@ public TransformsStack() : base(new StackOptions { XResourceTransforms = {Scenar
// Scenario #2 - apply a transformation to a Component to transform its children
var res2 = new MyComponent("res2", new ComponentResourceOptions
{
XResourceTransforms =
ResourceTransforms =
{
async (args, _) =>
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public TransformsStack() : base(new StackOptions { XResourceTransforms = {Scenar
// 4. Stack transformation
var res4 = new MyComponent("res4", new ComponentResourceOptions
{
XResourceTransforms = { (args, _) => scenario4(args, "default1"), (args, _) => scenario4(args, "default2") }
ResourceTransforms = { (args, _) => scenario4(args, "default1"), (args, _) => scenario4(args, "default2") }
});

async Task<ResourceTransformResult?> scenario4(ResourceTransformArgs args, string v)
Expand All @@ -89,7 +89,7 @@ public TransformsStack() : base(new StackOptions { XResourceTransforms = {Scenar
// Scenario #5 - mutate the properties of a resource
var res5 = new Random("res5", new RandomArgs { Length = 10 }, new CustomResourceOptions
{
XResourceTransforms =
ResourceTransforms =
{
async (args, _) =>
{
Expand Down
4 changes: 2 additions & 2 deletions sdk/Pulumi/Deployment/Deployment_Prepare.cs
Expand Up @@ -122,7 +122,7 @@ public partial class Deployment
var aliases = await PrepareAliases(res, options, resourceMonitorSupportsAliasSpecs).ConfigureAwait(false);

var transforms = new List<Pulumirpc.Callback>();
if (options.XResourceTransforms.Count > 0)
if (options.ResourceTransforms.Count > 0)
{
var resourceMonitorSupportsTransforms = await MonitorSupportsTransforms().ConfigureAwait(false);
if (!resourceMonitorSupportsTransforms)
Expand All @@ -132,7 +132,7 @@ public partial class Deployment

var callbacks = await this.GetCallbacksAsync(CancellationToken.None).ConfigureAwait(false);

foreach (var t in options.XResourceTransforms)
foreach (var t in options.ResourceTransforms)
{
transforms.Add(await AllocateTransform(callbacks.Callbacks, t).ConfigureAwait(false));
}
Expand Down
4 changes: 1 addition & 3 deletions sdk/Pulumi/Resources/ResourceOptions.cs
Expand Up @@ -92,10 +92,8 @@ public List<ResourceTransformation> ResourceTransformations
/// <summary>
/// Optional list of transforms to apply to this resource during construction.The transforms are applied in
/// order, and are applied prior to transform applied to parents walking from the resource up to the stack.
///
/// This property is experimental.
/// </summary>
public List<ResourceTransform> XResourceTransforms
public List<ResourceTransform> ResourceTransforms
{
get => _resourceTransforms ??= new List<ResourceTransform>();
set => _resourceTransforms = value;
Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi/Resources/ResourceOptions_Copy.cs
Expand Up @@ -25,7 +25,7 @@ internal static TResourceOptions CreateCopy<TResourceOptions>(ResourceOptions op
PluginDownloadURL = options.PluginDownloadURL,
RetainOnDelete = options.RetainOnDelete,
DeletedWith = options.DeletedWith,
XResourceTransforms = options.XResourceTransforms.ToList(),
ResourceTransforms = options.ResourceTransforms.ToList(),
};

internal static CustomResourceOptions CreateCustomResourceOptionsCopy(ResourceOptions? options)
Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi/Resources/ResourceTransform.cs
Expand Up @@ -7,7 +7,7 @@
namespace Pulumi
{
/// <summary>
/// ResourceTransform is the callback signature for <see cref="ResourceOptions.XResourceTransforms"/>. A
/// ResourceTransform is the callback signature for <see cref="ResourceOptions.ResourceTransforms"/>. A
/// transform is passed the same set of inputs provided to the <see cref="Resource"/> constructor, and can
/// optionally return back alternate values for the <c>properties</c> and/or <c>options</c> prior to the resource
/// actually being created. The effect will be as though those <c>properties</c> and/or <c>options</c> were passed
Expand Down
4 changes: 1 addition & 3 deletions sdk/Pulumi/Resources/StackOptions.cs
Expand Up @@ -28,10 +28,8 @@ public List<ResourceTransformation> ResourceTransformations
/// <summary>
/// Optional list of transforms to apply to this stack's resources during construction. The transforms are
/// applied in order, and are applied after all the transforms of custom and component resources in the stack.
///
/// This property is experimental.
/// </summary>
public List<ResourceTransform> XResourceTransforms
public List<ResourceTransform> ResourceTransforms
{
get => _resourceTransforms ??= new List<ResourceTransform>();
set => _resourceTransforms = value;
Expand Down
2 changes: 1 addition & 1 deletion sdk/Pulumi/Stack.cs
Expand Up @@ -126,7 +126,7 @@ internal void RegisterPropertyOutputs()
return new ComponentResourceOptions
{
ResourceTransformations = options.ResourceTransformations,
XResourceTransforms = options.XResourceTransforms,
ResourceTransforms = options.ResourceTransforms,
};
}
}
Expand Down

0 comments on commit 8104752

Please sign in to comment.