Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9936e95
commit a1b63e8
Showing
16 changed files
with
273 additions
and
365 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
8 changes: 8 additions & 0 deletions
8
tests/integration/aliases/dotnet/rename_component/step1/Aliases.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>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
39 changes: 39 additions & 0 deletions
39
tests/integration/aliases/dotnet/rename_component/step1/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,39 @@ | ||
// Copyright 2016-2019, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Resource : ComponentResource | ||
{ | ||
public Resource(string name, ComponentResourceOptions options = null) | ||
: base("my:module:Resource", name, options) | ||
{ | ||
} | ||
} | ||
|
||
// Scenario #3 - rename a component (and all it's children) | ||
class ComponentThree : ComponentResource | ||
{ | ||
private Resource resource1; | ||
private Resource resource2; | ||
|
||
public ComponentThree(string name, ComponentResourceOptions options = null) | ||
: base("my:module:ComponentThree", name, options) | ||
{ | ||
// Note that both un-prefixed and parent-name-prefixed child names are supported. For the later, the implicit | ||
// alias inherited from the parent alias will include replacing the name prefix to match the parent alias name. | ||
this.resource1 = new Resource($"{name}-child", new ComponentResourceOptions { Parent = this }); | ||
this.resource2 = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); | ||
} | ||
} | ||
|
||
class Program | ||
{ | ||
static Task<int> Main(string[] args) | ||
{ | ||
return Deployment.RunAsync(() => | ||
{ | ||
var comp3 = new ComponentThree("comp3"); | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/integration/aliases/dotnet/rename_component/step1/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: aliases_rename_component | ||
description: A program that replaces a resource with a new name and alias. | ||
runtime: dotnet |
45 changes: 45 additions & 0 deletions
45
tests/integration/aliases/dotnet/rename_component/step2/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,45 @@ | ||
// Copyright 2016-2019, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Resource : ComponentResource | ||
{ | ||
public Resource(string name, ComponentResourceOptions options = null) | ||
: base("my:module:Resource", name, options) | ||
{ | ||
} | ||
} | ||
|
||
// Scenario #3 - rename a component (and all it's children) | ||
// No change to the component itself. | ||
class ComponentThree : ComponentResource | ||
{ | ||
private Resource resource1; | ||
private Resource resource2; | ||
|
||
public ComponentThree(string name, ComponentResourceOptions options = null) | ||
: base("my:module:ComponentThree", name, options) | ||
{ | ||
// Note that both un-prefixed and parent-name-prefixed child names are supported. For the later, the implicit | ||
// alias inherited from the parent alias will include replacing the name prefix to match the parent alias name. | ||
this.resource1 = new Resource($"{name}-child", new ComponentResourceOptions { Parent = this }); | ||
this.resource2 = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); | ||
} | ||
} | ||
|
||
|
||
class Program | ||
{ | ||
static Task<int> Main(string[] args) | ||
{ | ||
return Deployment.RunAsync(() => | ||
{ | ||
// Applying an alias to the instance successfully renames both the component and the children. | ||
var comp3 = new ComponentThree("newcomp3", new ComponentResourceOptions | ||
{ | ||
Aliases = { new Alias { Name = "comp3" } }, | ||
}); | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/integration/aliases/dotnet/rename_component_and_child/step1/Aliases.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>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
35 changes: 35 additions & 0 deletions
35
tests/integration/aliases/dotnet/rename_component_and_child/step1/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 @@ | ||
// Copyright 2016-2019, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Resource : ComponentResource | ||
{ | ||
public Resource(string name, ComponentResourceOptions options = null) | ||
: base("my:module:Resource", name, options) | ||
{ | ||
} | ||
} | ||
|
||
// Scenario #5 - composing #1 and #3 and making both changes at the same time | ||
class ComponentFive : ComponentResource | ||
{ | ||
private Resource resource; | ||
|
||
public ComponentFive(string name, ComponentResourceOptions options = null) | ||
: base("my:module:ComponentFive", name, options) | ||
{ | ||
this.resource = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); | ||
} | ||
} | ||
|
||
class Program | ||
{ | ||
static Task<int> Main(string[] args) | ||
{ | ||
return Deployment.RunAsync(() => | ||
{ | ||
var comp5 = new ComponentFive("comp5"); | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/integration/aliases/dotnet/rename_component_and_child/step1/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: aliases_rename_component_and_child | ||
description: A program that replaces a resource with a new name and alias. | ||
runtime: dotnet |
42 changes: 42 additions & 0 deletions
42
tests/integration/aliases/dotnet/rename_component_and_child/step2/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,42 @@ | ||
// Copyright 2016-2019, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Resource : ComponentResource | ||
{ | ||
public Resource(string name, ComponentResourceOptions options = null) | ||
: base("my:module:Resource", name, options) | ||
{ | ||
} | ||
} | ||
|
||
// Scenario #5 - composing #1 and #3 | ||
class ComponentFive : ComponentResource | ||
{ | ||
private Resource resource; | ||
|
||
public ComponentFive(string name, ComponentResourceOptions options = null) | ||
: base("my:module:ComponentFive", name, options) | ||
{ | ||
this.resource = new Resource("otherchildrenamed", new ComponentResourceOptions | ||
{ | ||
Parent = this, | ||
Aliases = { { new Alias { Name = "otherchild", Parent = this } } }, | ||
}); | ||
} | ||
} | ||
|
||
class Program | ||
{ | ||
static Task<int> Main(string[] args) | ||
{ | ||
return Deployment.RunAsync(() => | ||
{ | ||
var comp5 = new ComponentFive("newcomp5", new ComponentResourceOptions | ||
{ | ||
Aliases = { new Alias { Name = "comp5" } }, | ||
}); | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/integration/aliases/dotnet/retype_component/step1/Aliases.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>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
35 changes: 35 additions & 0 deletions
35
tests/integration/aliases/dotnet/retype_component/step1/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 @@ | ||
// Copyright 2016-2019, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Resource : ComponentResource | ||
{ | ||
public Resource(string name, ComponentResourceOptions options = null) | ||
: base("my:module:Resource", name, options) | ||
{ | ||
} | ||
} | ||
|
||
// Scenario #4 - change the type of a component | ||
class ComponentFour : ComponentResource | ||
{ | ||
private Resource resource; | ||
|
||
public ComponentFour(string name, ComponentResourceOptions options = null) | ||
: base("my:module:ComponentFour", name, options) | ||
{ | ||
this.resource = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); | ||
} | ||
} | ||
|
||
class Program | ||
{ | ||
static Task<int> Main(string[] args) | ||
{ | ||
return Deployment.RunAsync(() => | ||
{ | ||
var comp4 = new ComponentFour("comp4"); | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/integration/aliases/dotnet/retype_component/step1/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: aliases_retype_component | ||
description: A program that replaces a resource with a new name and alias. | ||
runtime: dotnet |
41 changes: 41 additions & 0 deletions
41
tests/integration/aliases/dotnet/retype_component/step2/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,41 @@ | ||
// Copyright 2016-2019, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Resource : ComponentResource | ||
{ | ||
public Resource(string name, ComponentResourceOptions options = null) | ||
: base("my:module:Resource", name, options) | ||
{ | ||
} | ||
} | ||
|
||
// Scenario #4 - change the type of a component | ||
class ComponentFour : ComponentResource | ||
{ | ||
private Resource resource; | ||
|
||
public ComponentFour(string name, ComponentResourceOptions options = null) | ||
: base("my:differentmodule:ComponentFourWithADifferentTypeName", name, ComponentResourceOptions.Merge(options, new ComponentResourceOptions | ||
{ | ||
// Add an alias that references the old type of this resource | ||
// and then make the base() call with the new type of this resource and the added alias. | ||
Aliases = { new Alias { Type = "my:module:ComponentFour" } } | ||
})) | ||
{ | ||
// The child resource will also pick up an implicit alias due to the new type of the component it is parented to. | ||
this.resource = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); | ||
} | ||
} | ||
|
||
class Program | ||
{ | ||
static Task<int> Main(string[] args) | ||
{ | ||
return Deployment.RunAsync(() => | ||
{ | ||
var comp4 = new ComponentFour("comp4"); | ||
}); | ||
} | ||
} |
Oops, something went wrong.