Skip to content

Commit

Permalink
Merge branch 'master' into lukehoban/moreesm
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehoban committed Dec 30, 2021
2 parents ba09f6d + 6daaa1c commit 2f6ddd4
Show file tree
Hide file tree
Showing 26 changed files with 713 additions and 128 deletions.
50 changes: 49 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
CHANGELOG
=========

## 3.21.0 (2021-12-29)

### Improvements

- [engine] - Interpret `pluginDownloadURL` as the provider host url when
downloading plugins.
[#8544](https://github.com/pulumi/pulumi/pull/8544)

- [sdk/dotnet] - `InputMap` and `InputList` can now be initialized
with any value that implicitly converts to the collection type.
These values are then automatically appended, for example:

var list = new InputList<string>
{
"V1",
Output.Create("V2"),
new[] { "V3", "V4" },
new List<string> { "V5", "V6" },
Output.Create(ImmutableArray.Create("V7", "V8"))
};

This feature simplifies the syntax for constructing resources and
specifying resource options such as the `DependsOn` option.

[#8498](https://github.com/pulumi/pulumi/pull/8498)

### Bug Fixes

- [sdk/python] - Fixes an issue with stack outputs persisting after
they are removed from the Pulumi program
[#8583](https://github.com/pulumi/pulumi/pull/8583)

- [auto/*] - Fixes `stack.setConfig()` breaking when trying to set
values that look like flags (such as `-value`)
[#8518](https://github.com/pulumi/pulumi/pull/8614)

- [sdk/dotnet] - Don't throw converting value types that don't match schema
[#8628](https://github.com/pulumi/pulumi/pull/8628)

- [sdk/{go,nodejs,dotnet,python}] - Compute full set of aliases when both parent and child are aliased.
[#8627](https://github.com/pulumi/pulumi/pull/8627)

- [cli/import] - Fix import of resource with non-identifier map keys
[#8645](https://github.com/pulumi/pulumi/pull/8645)

- [backend/filestate] - Allow preview on locked stack
[#8642](https://github.com/pulumi/pulumi/pull/8642)

## 3.20.0 (2021-12-16)

### Improvements
Expand Down Expand Up @@ -88,7 +136,7 @@ CHANGELOG

### Improvements

- [cli] - When running `pulumi new https://github.com/name/repo`, check
- [cli] - When running `pulumi new https://github.com/name/repo`, check
for branch `main` if branch `master` doesn't exist.
[#8463](https://github.com/pulumi/pulumi/pull/8463)

Expand Down
36 changes: 3 additions & 33 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
### Improvements

- [engine] - Interpret `pluginDownloadURL` as the provider host url when
downloading plugins.
[#8544](https://github.com/pulumi/pulumi/pull/8544)

- [sdk/dotnet] - `InputMap` and `InputList` can now be initialized
with any value that implicitly converts to the collection type.
These values are then automatically appended, for example:

var list = new InputList<string>
{
"V1",
Output.Create("V2"),
new[] { "V3", "V4" },
new List<string> { "V5", "V6" },
Output.Create(ImmutableArray.Create("V7", "V8"))
};

This feature simplifies the syntax for constructing resources and
specifying resource options such as the `DependsOn` option.

[#8498](https://github.com/pulumi/pulumi/pull/8498)

- [sdk/nodejs] Support using native ES modules as Pulumi scripts
[#7764](https://github.com/pulumi/pulumi/pull/7764)

### Bug Fixes

- [sdk/python] - Fixes an issue with stack outputs persisting after
they are removed from the Pulumi program
[#8583](https://github.com/pulumi/pulumi/pull/8583)
- [sdk/nodejs] Support a `nodeargs` option for passing `node` arguments to the Node language host
[#8655](https://github.com/pulumi/pulumi/pull/8655)

- [auto/*] - Fixes `stack.setConfig()` breaking when trying to set
values that look like flags (such as `-value`)
[#8518](https://github.com/pulumi/pulumi/pull/8614)

- [sdk/dotnet] - Don't throw converting value types that don't match schema
[#8628](https://github.com/pulumi/pulumi/pull/8628)
### Bug Fixes
6 changes: 0 additions & 6 deletions pkg/backend/filestate/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,6 @@ func (b *localBackend) PackPolicies(
func (b *localBackend) Preview(ctx context.Context, stack backend.Stack,
op backend.UpdateOperation) (engine.ResourceChanges, result.Result) {

err := b.Lock(ctx, stack.Ref())
if err != nil {
return nil, result.FromError(err)
}
defer b.Unlock(ctx, stack.Ref())

// We can skip PreviewThenPromptThenExecute and just go straight to Execute.
opts := backend.ApplierOptions{
DryRun: true,
Expand Down
8 changes: 2 additions & 6 deletions pkg/codegen/importer/hcl2.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,8 @@ func generateValue(typ schema.Type, value resource.PropertyValue) (model.Express
return nil, err
}

// we need to take into account when we have a complex key - without this
// we will return key as an array as the / will show as 2 parts
propKey := string(k)
if strings.Contains(string(k), "/") {
propKey = fmt.Sprintf("%q", string(k))
}
// Always quote the key in case it includes invalid identifier characters (like '/' or ':')
propKey := fmt.Sprintf("%q", string(k))

items = append(items, model.ObjectConsItem{
Key: &model.LiteralValueExpression{
Expand Down
3 changes: 2 additions & 1 deletion pkg/codegen/importer/testdata/cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@
"enableDnsSupport": true,
"instanceTenancy": "foobar",
"tags": {
"Name": "foobar"
"Name": "foobar",
"pulumi:Project": "tag-check"
}
}
},
Expand Down
3 changes: 1 addition & 2 deletions pkg/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d
github.com/opentracing/opentracing-go v1.1.0
github.com/pgavlin/goldmark v1.1.33-0.20200616210433-b5eb04559386
github.com/pulumi/pulumi/sdk/v3 v3.20.0
github.com/pulumi/pulumi/sdk/v3 v3.21.0
github.com/rjeczalik/notify v0.9.2
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0
github.com/sergi/go-diff v1.1.0
Expand Down Expand Up @@ -91,7 +91,6 @@ require (
github.com/emirpasic/gods v1.12.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/gofrs/flock v0.7.1 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.3 // indirect
Expand Down
2 changes: 0 additions & 2 deletions pkg/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down
81 changes: 81 additions & 0 deletions sdk/dotnet/Pulumi.Tests/Mocks/Aliases.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

using Pulumi;
using Pulumi.Testing;

namespace Pulumi.Tests.Mocks.Aliases
{
class AliasesStack : Stack
{
public AliasesStack()
{
var parent1 = new Pulumi.CustomResource("test:resource:type", "myres1", null, new CustomResourceOptions { });
var child1 = new Pulumi.CustomResource("test:resource:child", "myres1-child", null, new CustomResourceOptions
{
Parent = parent1,
});

var parent2 = new Pulumi.CustomResource("test:resource:type", "myres2", null, new CustomResourceOptions { });
var child2 = new Pulumi.CustomResource("test:resource:child", "myres2-child", null, new CustomResourceOptions
{
Parent = parent2,
Aliases = { new Alias { Type = "test:resource:child2" } }
});

var parent3 = new Pulumi.CustomResource("test:resource:type", "myres3", null, new CustomResourceOptions { });
var child3 = new Pulumi.CustomResource("test:resource:child", "myres3-child", null, new CustomResourceOptions
{
Parent = parent3,
Aliases = { new Alias { Name = "child2" } }
});

var parent4 = new Pulumi.CustomResource("test:resource:type", "myres4", null, new CustomResourceOptions
{
Aliases = { new Alias { Type = "test:resource:type3" } }
});
var child4 = new Pulumi.CustomResource("test:resource:child", "myres4-child", null, new CustomResourceOptions
{
Parent = parent4,
Aliases = { new Alias { Name = "myres4-child2" } }
});

var parent5 = new Pulumi.CustomResource("test:resource:type", "myres5", null, new CustomResourceOptions
{
Aliases = { new Alias { Name = "myres52" } }
});
var child5 = new Pulumi.CustomResource("test:resource:child", "myres5-child", null, new CustomResourceOptions
{
Parent = parent5,
Aliases = { new Alias { Name = "myres5-child2" } }
});

var parent6 = new Pulumi.CustomResource("test:resource:type", "myres6", null, new CustomResourceOptions
{
Aliases = { new Alias { Name = "myres62" }, new Alias { Type = "test:resource:type3"}, new Alias { Name = "myres63" }, }
});
var child6 = new Pulumi.CustomResource("test:resource:child", "myres6-child", null, new CustomResourceOptions
{
Parent = parent6,
Aliases = { new Alias { Name = "myres6-child2" }, new Alias { Type = "test:resource:child2"} }
});
}
}

class AliasesMocks : IMocks
{
public Task<object> CallAsync(MockCallArgs args)
{
return Task.FromResult<object>(args);
}

public async Task<(string? id, object state)> NewResourceAsync(
MockResourceArgs args)
{
await Task.Delay(0);
return ("myID", new Dictionary<string, object>());
}
}
}
61 changes: 60 additions & 1 deletion sdk/dotnet/Pulumi.Tests/Mocks/MocksTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public async Task TestStack()
[Fact]
public async Task TestInvokeThrowing()
{
var (resources, exception) = await Testing.RunAsync(new Issue8163Mocks(), async () => {
var (resources, exception) = await Testing.RunAsync(new Issue8163Mocks(), async () =>
{
var role = await GetRole.InvokeAsync(new GetRoleArgs()
{
Expand Down Expand Up @@ -183,6 +184,64 @@ public async Task TestUrnOutputPropertyIsNeverNull()
await Deployment.TestAsync<Issue7422.Issue7422Stack>(
new Issue7422.Issue7422Mocks());
}

[Fact]
public async Task TestAliases()
{
var resources = await Deployment.TestAsync<Aliases.AliasesStack>(
new Aliases.AliasesMocks());

// TODO[pulumi/pulumi#8637]
//
// var parent1Urn = await resources[1].Urn.GetValueAsync("");
// Assert.Equal("urn:pulumi:stack::project::test:resource:type::myres1", parent1Urn);

// TODO[pulumi/pulumi#8637]: A subset of the "expected" below include the implicit root stack type
// `pulumi:pulumi:Stack` as an explicit parent type in the URN. This should not happen, and indicates
// a bug in the the Pulumi .NET SDK unrelated to Aliases. It appears this only happens when using the
// .NET mock testing framework, not when running normal programs.
var expected = new Dictionary<string, List<string>>{
{ "myres1-child", new List<string>{}},
{ "myres2-child", new List<string>{
"urn:pulumi:stack::project::pulumi:pulumi:Stack$test:resource:type$test:resource:child2::myres2-child"
}},
{ "myres3-child", new List<string>{
"urn:pulumi:stack::project::pulumi:pulumi:Stack$test:resource:type$test:resource:child::child2"
}},
{ "myres4-child", new List<string>{
"urn:pulumi:stack::project::pulumi:pulumi:Stack$test:resource:type$test:resource:child::myres4-child2",
"urn:pulumi:stack::project::test:resource:type3$test:resource:child::myres4-child",
"urn:pulumi:stack::project::test:resource:type3$test:resource:child::myres4-child2",
}},
{ "myres5-child", new List<string>{
"urn:pulumi:stack::project::pulumi:pulumi:Stack$test:resource:type$test:resource:child::myres5-child2",
"urn:pulumi:stack::project::test:resource:type$test:resource:child::myres52-child",
"urn:pulumi:stack::project::test:resource:type$test:resource:child::myres52-child2",
}},
{ "myres6-child", new List<string>{
"urn:pulumi:stack::project::pulumi:pulumi:Stack$test:resource:type$test:resource:child::myres6-child2",
"urn:pulumi:stack::project::pulumi:pulumi:Stack$test:resource:type$test:resource:child2::myres6-child",
"urn:pulumi:stack::project::test:resource:type$test:resource:child::myres62-child",
"urn:pulumi:stack::project::test:resource:type$test:resource:child::myres62-child2",
"urn:pulumi:stack::project::test:resource:type$test:resource:child2::myres62-child",
"urn:pulumi:stack::project::test:resource:type3$test:resource:child::myres6-child",
"urn:pulumi:stack::project::test:resource:type3$test:resource:child::myres6-child2",
"urn:pulumi:stack::project::test:resource:type3$test:resource:child2::myres6-child",
"urn:pulumi:stack::project::test:resource:type$test:resource:child::myres63-child",
"urn:pulumi:stack::project::test:resource:type$test:resource:child::myres63-child2",
"urn:pulumi:stack::project::test:resource:type$test:resource:child2::myres63-child",
}},

};
foreach (var resource in resources)
{
if (resource.GetResourceType() == "test:resource:child")
{
var aliases = await Output.All(resource._aliases).GetValueAsync(ImmutableArray.Create<string>());
Assert.Equal<string>(expected[resource.GetResourceName()], aliases);
}
}
}
}

public static class Testing
Expand Down
17 changes: 15 additions & 2 deletions sdk/dotnet/Pulumi/Core/Urn.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2016-2019, Pulumi Corporation

using System;
using System.Collections.Generic;

namespace Pulumi
{
Expand Down Expand Up @@ -48,7 +49,7 @@ public static class Urn
/// resource in cases where the resource has a named derived from the name of the parent,
/// and the parent name changed.
/// </summary>
internal static Output<Alias> InheritedChildAlias(string childName, string parentName, Input<string> parentAlias, string childType)
internal static Output<string> InheritedChildAlias(string childName, string parentName, Input<string> parentAlias, string childType)
{
// If the child name has the parent name as a prefix, then we make the assumption that
// it was constructed from the convention of using '{name}-details' as the name of the
Expand All @@ -72,7 +73,19 @@ internal static Output<Alias> InheritedChildAlias(string childName, string paren
var urn = Create(
aliasName, childType, parent: null,
parentUrn: parentAlias, project: null, stack: null);
return urn.Apply(u => new Alias { Urn = u });
return urn;
}

internal static string Name(string urn) {
var parts = urn.Split("::");
return parts[3];
}

internal static string Type(string urn) {
var parts = urn.Split("::");
var typeParts = parts[2].Split("$");
return typeParts[typeParts.Length-1];
}

}
}

0 comments on commit 2f6ddd4

Please sign in to comment.