Use property.Value and property.Map

This commit is contained in:
Bryce Lampe
2025-04-30 14:21:13 -07:00
parent 144aad3a66
commit 9f06bf2d93
9 changed files with 160 additions and 225 deletions

View File

@@ -1 +1 @@
3.163.0 3.165.0

8
go.mod
View File

@@ -16,14 +16,14 @@ require (
github.com/otiai10/copy v1.14.0 github.com/otiai10/copy v1.14.0
github.com/pulumi/providertest v0.3.1 github.com/pulumi/providertest v0.3.1
github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet v0.0.0-20241219213128-b19d8c8da35b github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet v0.0.0-20241219213128-b19d8c8da35b
github.com/pulumi/pulumi-go-provider v0.25.1-0.20250421175102-c887ad454804 github.com/pulumi/pulumi-go-provider v0.25.1-0.20250430161409-af6aefddbb27
github.com/pulumi/pulumi-java/pkg v1.10.0 github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250430211204-978569a2545c
github.com/pulumi/pulumi-yaml v1.17.0 github.com/pulumi/pulumi-yaml v1.17.0
github.com/pulumi/pulumi/pkg/v3 v3.163.0 github.com/pulumi/pulumi/pkg/v3 v3.165.0
github.com/pulumi/pulumi/sdk/go/pulumi-language-go/v3 v3.0.0-20250417110128-49fb14839a5a github.com/pulumi/pulumi/sdk/go/pulumi-language-go/v3 v3.0.0-20250417110128-49fb14839a5a
github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 v3.0.0-20250417110128-49fb14839a5a github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 v3.0.0-20250417110128-49fb14839a5a
github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 v3.0.0-20250417110128-49fb14839a5a github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 v3.0.0-20250417110128-49fb14839a5a
github.com/pulumi/pulumi/sdk/v3 v3.163.0 github.com/pulumi/pulumi/sdk/v3 v3.165.0
github.com/regclient/regclient v0.7.1 github.com/regclient/regclient v0.7.1
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.14.0 github.com/spf13/afero v1.14.0

14
go.sum
View File

@@ -950,22 +950,24 @@ github.com/pulumi/providertest v0.3.1 h1:vlftr7TZlObh81mL88IhhF0/9ZbLrZZos4NAvR4
github.com/pulumi/providertest v0.3.1/go.mod h1:fFHUP4/9DRyYnHWiRnwcynMtM/a7hHR/QcJfcuZKO3A= github.com/pulumi/providertest v0.3.1/go.mod h1:fFHUP4/9DRyYnHWiRnwcynMtM/a7hHR/QcJfcuZKO3A=
github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet v0.0.0-20241219213128-b19d8c8da35b h1:pyYHkDsogl5q4dorkTKVk4/87l+fFUEIIVuwBqKJMHM= github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet v0.0.0-20241219213128-b19d8c8da35b h1:pyYHkDsogl5q4dorkTKVk4/87l+fFUEIIVuwBqKJMHM=
github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet v0.0.0-20241219213128-b19d8c8da35b/go.mod h1:5LjEUmPDpUyXzFbQCy3s1oFgeU9K3gVA6tX+xn1Xvbo= github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet v0.0.0-20241219213128-b19d8c8da35b/go.mod h1:5LjEUmPDpUyXzFbQCy3s1oFgeU9K3gVA6tX+xn1Xvbo=
github.com/pulumi/pulumi-go-provider v0.25.1-0.20250421175102-c887ad454804 h1:IPmEPPcRnYqwznnCPcjk8xpWZGna2situWWQdM3Ljws= github.com/pulumi/pulumi-go-provider v0.25.1-0.20250430161409-af6aefddbb27 h1:a6Y6T66wAl+cGOBN/n0I/pWhbQCVq1BBWnQX0joiANE=
github.com/pulumi/pulumi-go-provider v0.25.1-0.20250421175102-c887ad454804/go.mod h1:WaxPrK2ohj29oHINF8aZlqbnj/iOLnQWk7WrV0EMMe0= github.com/pulumi/pulumi-go-provider v0.25.1-0.20250430161409-af6aefddbb27/go.mod h1:4WYnu61f4I8EvmNzxftRtXznAfe7SdgtFMvxqoygGCg=
github.com/pulumi/pulumi-java/pkg v1.10.0 h1:gPW5dtKOdagDak7KUedkwRKKKUlhkdT7/vV21+ouWCw= github.com/pulumi/pulumi-java/pkg v1.10.0 h1:gPW5dtKOdagDak7KUedkwRKKKUlhkdT7/vV21+ouWCw=
github.com/pulumi/pulumi-java/pkg v1.10.0/go.mod h1:MgV+XcV5jcs0R5Naqyxp3UBJn+lXLE3aG5JVb/O8JeE= github.com/pulumi/pulumi-java/pkg v1.10.0/go.mod h1:MgV+XcV5jcs0R5Naqyxp3UBJn+lXLE3aG5JVb/O8JeE=
github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250430211204-978569a2545c h1:S0EGaFRWVXhVvRJ2cx3xb64Bzraga45tojsavqLsAHI=
github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250430211204-978569a2545c/go.mod h1:fE/A/3U2rpqpQKG0RrmmHjf0q+7shjsSfi74mhmLF6g=
github.com/pulumi/pulumi-yaml v1.17.0 h1:ebzggygqBcQrtmdBUqi28B1L/fAyHCFVIt0dS5re8Oc= github.com/pulumi/pulumi-yaml v1.17.0 h1:ebzggygqBcQrtmdBUqi28B1L/fAyHCFVIt0dS5re8Oc=
github.com/pulumi/pulumi-yaml v1.17.0/go.mod h1:4cpS4ITkIAXgVedTZB3JY/DnZu9XSh+RhrKB5WlB/fs= github.com/pulumi/pulumi-yaml v1.17.0/go.mod h1:4cpS4ITkIAXgVedTZB3JY/DnZu9XSh+RhrKB5WlB/fs=
github.com/pulumi/pulumi/pkg/v3 v3.163.0 h1:b9cwzffrRTWgawIkUdKfRqIyajAm4gdwHbYTJrpisms= github.com/pulumi/pulumi/pkg/v3 v3.165.0 h1:a0UOxhM+yUi5NH+SP5lv0YHxac3JOaeaZ/VINVkK+bM=
github.com/pulumi/pulumi/pkg/v3 v3.163.0/go.mod h1:/wRipYO0ZGehdQqTcT2t32gfYO95QvJCgN/hC0VXeGQ= github.com/pulumi/pulumi/pkg/v3 v3.165.0/go.mod h1:wJDlCqph9G1OCX8BYfjRp8yOtqBXZLij57fGbn1lXsM=
github.com/pulumi/pulumi/sdk/go/pulumi-language-go/v3 v3.0.0-20250417110128-49fb14839a5a h1:4V6DbJaLLSvOc9J/7ODqQEg892LaPD2JZtB9pKpHPI0= github.com/pulumi/pulumi/sdk/go/pulumi-language-go/v3 v3.0.0-20250417110128-49fb14839a5a h1:4V6DbJaLLSvOc9J/7ODqQEg892LaPD2JZtB9pKpHPI0=
github.com/pulumi/pulumi/sdk/go/pulumi-language-go/v3 v3.0.0-20250417110128-49fb14839a5a/go.mod h1:kle5wfWZA+tNa8M/8tBVk6yLE2kGqYtD3VEIpl8Vc6Y= github.com/pulumi/pulumi/sdk/go/pulumi-language-go/v3 v3.0.0-20250417110128-49fb14839a5a/go.mod h1:kle5wfWZA+tNa8M/8tBVk6yLE2kGqYtD3VEIpl8Vc6Y=
github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 v3.0.0-20250417110128-49fb14839a5a h1:5QPCsb+EAqwB2N70hXHPJig8eKi02Gttm9pGs9PQf2I= github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 v3.0.0-20250417110128-49fb14839a5a h1:5QPCsb+EAqwB2N70hXHPJig8eKi02Gttm9pGs9PQf2I=
github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 v3.0.0-20250417110128-49fb14839a5a/go.mod h1:9z23xCno15uQcyMDfFgXpISVExs/yXDuPsi5L8ykeRU= github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 v3.0.0-20250417110128-49fb14839a5a/go.mod h1:9z23xCno15uQcyMDfFgXpISVExs/yXDuPsi5L8ykeRU=
github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 v3.0.0-20250417110128-49fb14839a5a h1:4JkTGfh7AMYWlngOHk1V5m3US5JQsphUsQBpfCCW5yg= github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 v3.0.0-20250417110128-49fb14839a5a h1:4JkTGfh7AMYWlngOHk1V5m3US5JQsphUsQBpfCCW5yg=
github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 v3.0.0-20250417110128-49fb14839a5a/go.mod h1:IhJFvQ3XHlTfik9Gmlw5A7KMGXOK+UMQuslTS0cuojA= github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 v3.0.0-20250417110128-49fb14839a5a/go.mod h1:IhJFvQ3XHlTfik9Gmlw5A7KMGXOK+UMQuslTS0cuojA=
github.com/pulumi/pulumi/sdk/v3 v3.163.0 h1:yiT1nPelxXILVrN0yRn0I3NO8Yybba2IvWArYBstZJ8= github.com/pulumi/pulumi/sdk/v3 v3.165.0 h1:cglplKZOJDpqH8wa/2J250G9az/sE9eKp9fS2bC+vi8=
github.com/pulumi/pulumi/sdk/v3 v3.163.0/go.mod h1:GAaHrdv3kWJHbzkFFFflGbTBQXUYu6SF1ZCo+O9jo44= github.com/pulumi/pulumi/sdk/v3 v3.165.0/go.mod h1:GAaHrdv3kWJHbzkFFFflGbTBQXUYu6SF1ZCo+O9jo44=
github.com/quasilyte/go-ruleguard v0.4.2 h1:htXcXDK6/rO12kiTHKfHuqR4kr3Y4M0J0rOL6CH/BYs= github.com/quasilyte/go-ruleguard v0.4.2 h1:htXcXDK6/rO12kiTHKfHuqR4kr3Y4M0J0rOL6CH/BYs=
github.com/quasilyte/go-ruleguard v0.4.2/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI= github.com/quasilyte/go-ruleguard v0.4.2/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI=
github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE= github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE=

View File

@@ -38,6 +38,7 @@ import (
provider "github.com/pulumi/pulumi-go-provider" provider "github.com/pulumi/pulumi-go-provider"
"github.com/pulumi/pulumi-go-provider/infer" "github.com/pulumi/pulumi-go-provider/infer"
"github.com/pulumi/pulumi/sdk/v3/go/property"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
) )
@@ -356,7 +357,10 @@ func (i *Image) Check(
return infer.CheckResponse[ImageArgs]{Failures: failures, Inputs: args}, err return infer.CheckResponse[ImageArgs]{Failures: failures, Inputs: args}, err
} }
preview := req.NewInputs.ContainsUnknowns() // If the inputs aren't fully resolved we perform a weaker validation, for
// example we might not be able to check the Dockerfile for syntactic
// correctness.
preview := property.New(req.NewInputs).HasComputed()
cfg := infer.GetConfig[Config](ctx) cfg := infer.GetConfig[Config](ctx)
supportsMultipleExports := true supportsMultipleExports := true

View File

@@ -38,6 +38,7 @@ import (
"github.com/pulumi/pulumi-go-provider/integration" "github.com/pulumi/pulumi-go-provider/integration"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/mapper" "github.com/pulumi/pulumi/sdk/v3/go/common/util/mapper"
"github.com/pulumi/pulumi/sdk/v3/go/property"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
) )
@@ -84,46 +85,44 @@ func TestImageLifecycle(t *testing.T) {
}, },
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty( "tags": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e"), property.New("docker.io/pulumibot/buildkit-e2e"),
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:main"), property.New("docker.io/pulumibot/buildkit-e2e:main"),
}, },
), ),
"platforms": resource.NewArrayProperty( "platforms": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewStringProperty("linux/arm64"), property.New("linux/arm64"),
resource.NewStringProperty("linux/amd64"), property.New("linux/amd64"),
}, },
), ),
"context": resource.NewObjectProperty(resource.PropertyMap{ "context": property.New(map[string]property.Value{
"location": resource.NewStringProperty("testdata/noop"), "location": property.New("testdata/noop"),
}), }),
"dockerfile": resource.NewObjectProperty(resource.PropertyMap{ "dockerfile": property.New(map[string]property.Value{
"location": resource.NewStringProperty("testdata/noop/Dockerfile"), "location": property.New("testdata/noop/Dockerfile"),
}), }),
"exports": resource.NewArrayProperty( "exports": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewObjectProperty(resource.PropertyMap{ property.New(map[string]property.Value{
"raw": resource.NewStringProperty("type=registry"), "raw": property.New("type=registry"),
}, },
), ),
}, },
), ),
"registries": resource.NewArrayProperty( "registries": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewObjectProperty(resource.PropertyMap{ property.New(map[string]property.Value{
"address": resource.NewStringProperty("fakeaddress"), "address": property.New("fakeaddress"),
"username": resource.NewStringProperty("fakeuser"), "username": property.New("fakeuser"),
"password": resource.MakeSecret( "password": property.New("password").WithSecret(true),
resource.NewStringProperty("password"),
),
}), }),
}, },
), ),
}, }),
} }
}, },
}, },
@@ -132,20 +131,20 @@ func TestImageLifecycle(t *testing.T) {
client: noClient, client: noClient,
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty([]resource.PropertyValue{}), "tags": property.New([]property.Value{}),
"context": resource.NewObjectProperty(resource.PropertyMap{ "context": property.New(map[string]property.Value{
"location": resource.NewStringProperty("testdata/noop"), "location": property.New("testdata/noop"),
}), }),
"exports": resource.NewArrayProperty( "exports": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewObjectProperty(resource.PropertyMap{ property.New(map[string]property.Value{
"raw": resource.NewStringProperty("type=registry"), "raw": property.New("type=registry"),
}), }),
}, },
), ),
}, }),
ExpectFailure: true, ExpectFailure: true,
CheckFailures: []provider.CheckFailure{ CheckFailures: []provider.CheckFailure{
{ {
@@ -161,19 +160,19 @@ func TestImageLifecycle(t *testing.T) {
client: noClient, client: noClient,
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty( "tags": property.New(
[]resource.PropertyValue{resource.NewStringProperty("invalid-exports")}, []property.Value{property.New("invalid-exports")},
), ),
"exports": resource.NewArrayProperty( "exports": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewObjectProperty(resource.PropertyMap{ property.New(map[string]property.Value{
"raw": resource.NewStringProperty("type="), "raw": property.New("type="),
}), }),
}, },
), ),
}, }),
ExpectFailure: true, ExpectFailure: true,
CheckFailures: []provider.CheckFailure{{ CheckFailures: []provider.CheckFailure{{
Property: "exports[0]", Property: "exports[0]",
@@ -194,15 +193,15 @@ func TestImageLifecycle(t *testing.T) {
}, },
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty( "tags": property.New(
[]resource.PropertyValue{resource.NewStringProperty("foo")}, []property.Value{property.New("foo")},
), ),
"context": resource.NewObjectProperty(resource.PropertyMap{ "context": property.New(map[string]property.Value{
"location": resource.NewStringProperty("testdata/noop"), "location": property.New("testdata/noop"),
}), }),
}, }),
ExpectFailure: true, ExpectFailure: true,
} }
}, },
@@ -221,15 +220,15 @@ func TestImageLifecycle(t *testing.T) {
}, },
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty( "tags": property.New(
[]resource.PropertyValue{resource.NewStringProperty("foo")}, []property.Value{property.New("foo")},
), ),
"context": resource.NewObjectProperty(resource.PropertyMap{ "context": property.New(map[string]property.Value{
"location": resource.NewStringProperty("testdata/noop"), "location": property.New("testdata/noop"),
}), }),
}, }),
ExpectFailure: true, ExpectFailure: true,
} }
}, },
@@ -254,24 +253,24 @@ func TestImageLifecycle(t *testing.T) {
}, },
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty( "tags": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewStringProperty("default-dockerfile"), property.New("default-dockerfile"),
}, },
), ),
"context": resource.NewObjectProperty(resource.PropertyMap{ "context": property.New(map[string]property.Value{
"location": resource.NewStringProperty("testdata/noop"), "location": property.New("testdata/noop"),
}), }),
}, }),
Hook: func(_, output resource.PropertyMap) { Hook: func(_, output property.Map) {
dockerfile := output["dockerfile"] dockerfile := output.Get("dockerfile")
require.NotNil(t, dockerfile) require.NotNil(t, dockerfile)
require.True(t, dockerfile.IsObject()) require.True(t, dockerfile.IsMap())
location := dockerfile.ObjectValue()["location"] location := dockerfile.AsMap().Get("location")
require.True(t, location.IsString()) require.True(t, location.IsString())
assert.Equal(t, "testdata/noop/Dockerfile", location.StringValue()) assert.Equal(t, "testdata/noop/Dockerfile", location.AsString())
}, },
} }
}, },
@@ -296,25 +295,25 @@ func TestImageLifecycle(t *testing.T) {
}, },
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"push": resource.NewBoolProperty(false), "push": property.New(false),
"tags": resource.NewArrayProperty( "tags": property.New(
[]resource.PropertyValue{ []property.Value{
resource.NewStringProperty("inline-dockerfile"), property.New("inline-dockerfile"),
}, },
), ),
"buildOnPreview": resource.NewBoolProperty(true), "buildOnPreview": property.New(true),
"dockerfile": resource.NewObjectProperty(resource.PropertyMap{ "dockerfile": property.New(map[string]property.Value{
"inline": resource.NewStringProperty("FROM alpine:latest"), "inline": property.New("FROM alpine:latest"),
}), }),
}, }),
Hook: func(_, output resource.PropertyMap) { Hook: func(_, output property.Map) {
context := output["context"] context := output.Get("context")
require.NotNil(t, context) require.NotNil(t, context)
require.True(t, context.IsObject()) require.True(t, context.IsMap())
location := context.ObjectValue()["location"] location := context.AsMap().Get("location")
require.True(t, location.IsString()) require.True(t, location.IsString())
assert.Equal(t, ".", location.StringValue()) assert.Equal(t, ".", location.AsString())
}, },
} }
}, },
@@ -360,15 +359,15 @@ func TestDelete(t *testing.T) {
err = s.Delete(provider.DeleteRequest{ err = s.Delete(provider.DeleteRequest{
ID: "foo,bar", ID: "foo,bar",
Urn: _fakeURN, Urn: _fakeURN,
Properties: resource.PropertyMap{ Properties: property.NewMap(map[string]property.Value{
"tags": resource.NewArrayProperty([]resource.PropertyValue{ "tags": property.New([]property.Value{
resource.NewStringProperty("docker.io/pulumi/test:foo"), property.New("docker.io/pulumi/test:foo"),
}), }),
"push": resource.NewBoolProperty(true), "push": property.New(true),
"digest": resource.NewStringProperty("sha256:foo"), "digest": property.New("sha256:foo"),
"contextHash": resource.NewStringProperty(""), "contextHash": property.New(""),
"ref": resource.NewStringProperty(""), "ref": property.New(""),
}, }),
}) })
assert.NoError(t, err) assert.NoError(t, err)
}) })
@@ -398,20 +397,20 @@ func TestRead(t *testing.T) {
resp, err := s.Read(provider.ReadRequest{ resp, err := s.Read(provider.ReadRequest{
ID: "my-image", ID: "my-image",
Urn: _fakeURN, Urn: _fakeURN,
Properties: resource.PropertyMap{ Properties: property.NewMap(map[string]property.Value{
"exports": resource.NewArrayProperty([]resource.PropertyValue{ "exports": property.New([]property.Value{
resource.NewObjectProperty(resource.PropertyMap{ property.New(map[string]property.Value{
"raw": resource.NewStringProperty("type=registry"), "raw": property.New("type=registry"),
}), }),
}), }),
"tags": resource.NewArrayProperty([]resource.PropertyValue{ "tags": property.New([]property.Value{
resource.NewStringProperty(tag), property.New(tag),
}), }),
"digest": resource.NewStringProperty(digest), "digest": property.New(digest),
}, }),
}) })
require.NoError(t, err) require.NoError(t, err)
assert.NotNil(t, resp.Properties["exports"].ArrayValue()[0].ObjectValue()["manifest"]) assert.NotNil(t, resp.Properties.Get("exports").AsArray().Get(0).AsMap().Get("manifest"))
} }
func TestImageDiff(t *testing.T) { func TestImageDiff(t *testing.T) {
@@ -796,10 +795,10 @@ func TestImageDiff(t *testing.T) {
s := newServer(nil) s := newServer(nil)
encode := func(t *testing.T, x any) resource.PropertyMap { encode := func(t *testing.T, x any) property.Map {
raw, err := mapper.New(&mapper.Opts{IgnoreMissing: true}).Encode(x) raw, err := mapper.New(&mapper.Opts{IgnoreMissing: true}).Encode(x)
require.NoError(t, err) require.NoError(t, err)
return resource.NewPropertyMapFromMap(raw) return resource.FromResourcePropertyMap(resource.NewPropertyMapFromMap(raw))
} }
for _, tt := range tests { for _, tt := range tests {

View File

@@ -27,6 +27,7 @@ import (
"github.com/pulumi/pulumi-go-provider/integration" "github.com/pulumi/pulumi-go-provider/integration"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/mapper" "github.com/pulumi/pulumi/sdk/v3/go/common/util/mapper"
"github.com/pulumi/pulumi/sdk/v3/go/property"
) )
func TestIndexLifecycle(t *testing.T) { func TestIndexLifecycle(t *testing.T) {
@@ -45,16 +46,16 @@ func TestIndexLifecycle(t *testing.T) {
client: realClient, client: realClient,
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"tag": resource.NewStringProperty( "tag": property.New(
"docker.io/pulumibot/buildkit-e2e:manifest-unit", "docker.io/pulumibot/buildkit-e2e:manifest-unit",
), ),
"sources": resource.NewArrayProperty([]resource.PropertyValue{ "sources": property.New([]property.Value{
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:arm64"), property.New("docker.io/pulumibot/buildkit-e2e:arm64"),
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:amd64"), property.New("docker.io/pulumibot/buildkit-e2e:amd64"),
}), }),
"push": resource.NewBoolProperty(false), "push": property.New(false),
}, }),
} }
}, },
}, },
@@ -64,25 +65,21 @@ func TestIndexLifecycle(t *testing.T) {
client: realClient, client: realClient,
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"tag": resource.NewStringProperty( "tag": property.New(
"docker.io/pulumibot/buildkit-e2e:manifest", "docker.io/pulumibot/buildkit-e2e:manifest",
), ),
"sources": resource.NewArrayProperty([]resource.PropertyValue{ "sources": property.New([]property.Value{
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:arm64"), property.New("docker.io/pulumibot/buildkit-e2e:arm64"),
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:amd64"), property.New("docker.io/pulumibot/buildkit-e2e:amd64"),
}), }),
"push": resource.NewBoolProperty(true), "push": property.New(true),
"registry": resource.NewObjectProperty(resource.PropertyMap{ "registry": property.New(map[string]property.Value{
"address": resource.NewStringProperty("docker.io"), "address": property.New("docker.io"),
"username": resource.NewStringProperty("pulumibot"), "username": property.New("pulumibot"),
"password": resource.NewSecretProperty(&resource.Secret{ "password": property.New(os.Getenv("DOCKER_HUB_PASSWORD")).WithSecret(true),
Element: resource.NewStringProperty(
os.Getenv("DOCKER_HUB_PASSWORD"),
),
}),
}), }),
}, }),
} }
}, },
}, },
@@ -98,25 +95,21 @@ func TestIndexLifecycle(t *testing.T) {
}, },
op: func(t *testing.T) integration.Operation { op: func(t *testing.T) integration.Operation {
return integration.Operation{ return integration.Operation{
Inputs: resource.PropertyMap{ Inputs: property.NewMap(map[string]property.Value{
"tag": resource.NewStringProperty( "tag": property.New(
"docker.io/pulumibot/buildkit-e2e:manifest", "docker.io/pulumibot/buildkit-e2e:manifest",
), ),
"sources": resource.NewArrayProperty([]resource.PropertyValue{ "sources": property.New([]property.Value{
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:arm64"), property.New("docker.io/pulumibot/buildkit-e2e:arm64"),
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:amd64"), property.New("docker.io/pulumibot/buildkit-e2e:amd64"),
}), }),
"push": resource.NewBoolProperty(true), "push": property.New(true),
"registry": resource.NewObjectProperty(resource.PropertyMap{ "registry": property.New(map[string]property.Value{
"address": resource.NewStringProperty("docker.io"), "address": property.New("docker.io"),
"username": resource.NewStringProperty("pulumibot"), "username": property.New("pulumibot"),
"password": resource.NewSecretProperty(&resource.Secret{ "password": property.New(os.Getenv("DOCKER_HUB_PASSWORD")).WithSecret(true),
Element: resource.NewStringProperty(
os.Getenv("DOCKER_HUB_PASSWORD"),
),
}),
}), }),
}, }),
} }
}, },
}, },
@@ -223,10 +216,10 @@ func TestIndexDiff(t *testing.T) {
s := newServer(nil) s := newServer(nil)
encode := func(t *testing.T, x any) resource.PropertyMap { encode := func(t *testing.T, x any) property.Map {
raw, err := mapper.New(&mapper.Opts{IgnoreMissing: true}).Encode(x) raw, err := mapper.New(&mapper.Opts{IgnoreMissing: true}).Encode(x)
require.NoError(t, err) require.NoError(t, err)
return resource.NewPropertyMapFromMap(raw) return resource.FromResourcePropertyMap(resource.NewPropertyMapFromMap(raw))
} }
for _, tt := range tests { for _, tt := range tests {

View File

@@ -29,6 +29,7 @@ import (
"github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens" "github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi/sdk/v3/go/property"
) )
var ( var (
@@ -139,7 +140,9 @@ func diffConfigIgnoreInternal(
diffConfig func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error), diffConfig func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error),
) func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error) { ) func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error) {
return func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error) { return func(ctx context.Context, req provider.DiffRequest) (provider.DiffResponse, error) {
delete(req.News, "__internal") m := req.News.AsMap()
delete(m, "__internal")
req.News = property.NewMap(m)
return diffConfig(ctx, req) return diffConfig(ctx, req)
} }

View File

@@ -15,13 +15,8 @@
package provider package provider
import ( import (
"context"
"encoding/json"
"github.com/pulumi/pulumi-docker-build/provider/internal" "github.com/pulumi/pulumi-docker-build/provider/internal"
"github.com/pulumi/pulumi-docker-build/provider/internal/deprecated"
gp "github.com/pulumi/pulumi-go-provider" gp "github.com/pulumi/pulumi-go-provider"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/pkg/v3/resource/provider" "github.com/pulumi/pulumi/pkg/v3/resource/provider"
rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" rpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
) )
@@ -39,37 +34,5 @@ func Serve() error {
// New creates a new provider. // New creates a new provider.
func New(host *provider.HostClient) (rpc.ResourceProviderServer, error) { func New(host *provider.HostClient) (rpc.ResourceProviderServer, error) {
return gp.RawServer(Name, Version, configurableProvider(internal.NewBuildxProvider()))(host) return gp.RawServer(Name, Version, internal.NewBuildxProvider())(host)
}
// configurableProvider is a workaround for
// https://github.com/pulumi/pulumi-go-provider/issues/171 and
// In short, our SDKs send provider Configure requests as simple strings
// instead of rich objects. We don't want to preserve this behavior in
// pulumi-go-provider, but we also haven't updated SDKs yet to send rich types.
//
// If you find yourself in a position where you need to copy this -- STOP!
// https://github.com/pulumi/pulumi/pull/15032 should be merged with this fix.
func configurableProvider(p gp.Provider) gp.Provider {
configure := p.Configure
p.Configure = func(ctx context.Context, req gp.ConfigureRequest) error {
r, err := p.GetSchema(ctx, gp.GetSchemaRequest{Version: 0})
if err != nil {
return err
}
spec := schema.PackageSpec{}
err = json.Unmarshal([]byte(r.Schema), &spec)
if err != nil {
return err
}
ce := deprecated.New(spec.Config)
if props, err := ce.UnmarshalProperties(req.Args); err == nil {
req.Args = props
}
return configure(ctx, req)
}
return p
} }

View File

@@ -22,37 +22,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
emptypb "google.golang.org/protobuf/types/known/emptypb" emptypb "google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/structpb"
"github.com/pulumi/pulumi-docker-build/provider/internal"
provider "github.com/pulumi/pulumi-go-provider"
"github.com/pulumi/pulumi-go-provider/integration"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
) )
// TestConfigure checks backwards-compatibility with SDKs that still send
// provider config as JSON-encoded strings. This test can be removed once we
// upgrade to a version of pulumi that no longer generates SDKs with that
// behavior.
func TestConfigure(t *testing.T) {
t.Parallel()
p := configurableProvider(internal.NewBuildxProvider())
args, err := structpb.NewStruct(map[string]any{
"registries": `[{"address": "docker.io"}]`,
})
require.NoError(t, err)
argsMap, err := plugin.UnmarshalProperties(args, plugin.MarshalOptions{})
require.NoError(t, err)
s := integration.NewServer("docker-build", semver.Version{Major: 0}, p)
err = s.Configure(provider.ConfigureRequest{
Args: argsMap,
})
assert.NoError(t, err)
}
func TestVersion(t *testing.T) { func TestVersion(t *testing.T) {
t.Parallel() t.Parallel()