Use property.Value and property.Map
This commit is contained in:
@@ -1 +1 @@
|
||||
3.163.0
|
||||
3.165.0
|
||||
|
||||
8
go.mod
8
go.mod
@@ -16,14 +16,14 @@ require (
|
||||
github.com/otiai10/copy v1.14.0
|
||||
github.com/pulumi/providertest v0.3.1
|
||||
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-java/pkg v1.10.0
|
||||
github.com/pulumi/pulumi-go-provider v0.25.1-0.20250430161409-af6aefddbb27
|
||||
github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250430211204-978569a2545c
|
||||
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/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/v3 v3.163.0
|
||||
github.com/pulumi/pulumi/sdk/v3 v3.165.0
|
||||
github.com/regclient/regclient v0.7.1
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/spf13/afero v1.14.0
|
||||
|
||||
14
go.sum
14
go.sum
@@ -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/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-go-provider v0.25.1-0.20250421175102-c887ad454804 h1:IPmEPPcRnYqwznnCPcjk8xpWZGna2situWWQdM3Ljws=
|
||||
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 h1:a6Y6T66wAl+cGOBN/n0I/pWhbQCVq1BBWnQX0joiANE=
|
||||
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/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/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.163.0/go.mod h1:/wRipYO0ZGehdQqTcT2t32gfYO95QvJCgN/hC0VXeGQ=
|
||||
github.com/pulumi/pulumi/pkg/v3 v3.165.0 h1:a0UOxhM+yUi5NH+SP5lv0YHxac3JOaeaZ/VINVkK+bM=
|
||||
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/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/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/go.mod h1:IhJFvQ3XHlTfik9Gmlw5A7KMGXOK+UMQuslTS0cuojA=
|
||||
github.com/pulumi/pulumi/sdk/v3 v3.163.0 h1:yiT1nPelxXILVrN0yRn0I3NO8Yybba2IvWArYBstZJ8=
|
||||
github.com/pulumi/pulumi/sdk/v3 v3.163.0/go.mod h1:GAaHrdv3kWJHbzkFFFflGbTBQXUYu6SF1ZCo+O9jo44=
|
||||
github.com/pulumi/pulumi/sdk/v3 v3.165.0 h1:cglplKZOJDpqH8wa/2J250G9az/sE9eKp9fS2bC+vi8=
|
||||
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/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI=
|
||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE=
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
|
||||
provider "github.com/pulumi/pulumi-go-provider"
|
||||
"github.com/pulumi/pulumi-go-provider/infer"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/property"
|
||||
"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
|
||||
}
|
||||
|
||||
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)
|
||||
supportsMultipleExports := true
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"github.com/pulumi/pulumi-go-provider/integration"
|
||||
"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/property"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
@@ -84,46 +85,44 @@ func TestImageLifecycle(t *testing.T) {
|
||||
},
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e"),
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:main"),
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New(
|
||||
[]property.Value{
|
||||
property.New("docker.io/pulumibot/buildkit-e2e"),
|
||||
property.New("docker.io/pulumibot/buildkit-e2e:main"),
|
||||
},
|
||||
),
|
||||
"platforms": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewStringProperty("linux/arm64"),
|
||||
resource.NewStringProperty("linux/amd64"),
|
||||
"platforms": property.New(
|
||||
[]property.Value{
|
||||
property.New("linux/arm64"),
|
||||
property.New("linux/amd64"),
|
||||
},
|
||||
),
|
||||
"context": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"location": resource.NewStringProperty("testdata/noop"),
|
||||
"context": property.New(map[string]property.Value{
|
||||
"location": property.New("testdata/noop"),
|
||||
}),
|
||||
"dockerfile": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"location": resource.NewStringProperty("testdata/noop/Dockerfile"),
|
||||
"dockerfile": property.New(map[string]property.Value{
|
||||
"location": property.New("testdata/noop/Dockerfile"),
|
||||
}),
|
||||
"exports": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewObjectProperty(resource.PropertyMap{
|
||||
"raw": resource.NewStringProperty("type=registry"),
|
||||
"exports": property.New(
|
||||
[]property.Value{
|
||||
property.New(map[string]property.Value{
|
||||
"raw": property.New("type=registry"),
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
"registries": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewObjectProperty(resource.PropertyMap{
|
||||
"address": resource.NewStringProperty("fakeaddress"),
|
||||
"username": resource.NewStringProperty("fakeuser"),
|
||||
"password": resource.MakeSecret(
|
||||
resource.NewStringProperty("password"),
|
||||
),
|
||||
"registries": property.New(
|
||||
[]property.Value{
|
||||
property.New(map[string]property.Value{
|
||||
"address": property.New("fakeaddress"),
|
||||
"username": property.New("fakeuser"),
|
||||
"password": property.New("password").WithSecret(true),
|
||||
}),
|
||||
},
|
||||
),
|
||||
},
|
||||
}),
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -132,20 +131,20 @@ func TestImageLifecycle(t *testing.T) {
|
||||
client: noClient,
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty([]resource.PropertyValue{}),
|
||||
"context": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"location": resource.NewStringProperty("testdata/noop"),
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New([]property.Value{}),
|
||||
"context": property.New(map[string]property.Value{
|
||||
"location": property.New("testdata/noop"),
|
||||
}),
|
||||
"exports": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewObjectProperty(resource.PropertyMap{
|
||||
"raw": resource.NewStringProperty("type=registry"),
|
||||
"exports": property.New(
|
||||
[]property.Value{
|
||||
property.New(map[string]property.Value{
|
||||
"raw": property.New("type=registry"),
|
||||
}),
|
||||
},
|
||||
),
|
||||
},
|
||||
}),
|
||||
ExpectFailure: true,
|
||||
CheckFailures: []provider.CheckFailure{
|
||||
{
|
||||
@@ -161,19 +160,19 @@ func TestImageLifecycle(t *testing.T) {
|
||||
client: noClient,
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{resource.NewStringProperty("invalid-exports")},
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New(
|
||||
[]property.Value{property.New("invalid-exports")},
|
||||
),
|
||||
"exports": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewObjectProperty(resource.PropertyMap{
|
||||
"raw": resource.NewStringProperty("type="),
|
||||
"exports": property.New(
|
||||
[]property.Value{
|
||||
property.New(map[string]property.Value{
|
||||
"raw": property.New("type="),
|
||||
}),
|
||||
},
|
||||
),
|
||||
},
|
||||
}),
|
||||
ExpectFailure: true,
|
||||
CheckFailures: []provider.CheckFailure{{
|
||||
Property: "exports[0]",
|
||||
@@ -194,15 +193,15 @@ func TestImageLifecycle(t *testing.T) {
|
||||
},
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{resource.NewStringProperty("foo")},
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New(
|
||||
[]property.Value{property.New("foo")},
|
||||
),
|
||||
"context": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"location": resource.NewStringProperty("testdata/noop"),
|
||||
"context": property.New(map[string]property.Value{
|
||||
"location": property.New("testdata/noop"),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
ExpectFailure: true,
|
||||
}
|
||||
},
|
||||
@@ -221,15 +220,15 @@ func TestImageLifecycle(t *testing.T) {
|
||||
},
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{resource.NewStringProperty("foo")},
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New(
|
||||
[]property.Value{property.New("foo")},
|
||||
),
|
||||
"context": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"location": resource.NewStringProperty("testdata/noop"),
|
||||
"context": property.New(map[string]property.Value{
|
||||
"location": property.New("testdata/noop"),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
ExpectFailure: true,
|
||||
}
|
||||
},
|
||||
@@ -254,24 +253,24 @@ func TestImageLifecycle(t *testing.T) {
|
||||
},
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewStringProperty("default-dockerfile"),
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New(
|
||||
[]property.Value{
|
||||
property.New("default-dockerfile"),
|
||||
},
|
||||
),
|
||||
"context": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"location": resource.NewStringProperty("testdata/noop"),
|
||||
"context": property.New(map[string]property.Value{
|
||||
"location": property.New("testdata/noop"),
|
||||
}),
|
||||
},
|
||||
Hook: func(_, output resource.PropertyMap) {
|
||||
dockerfile := output["dockerfile"]
|
||||
}),
|
||||
Hook: func(_, output property.Map) {
|
||||
dockerfile := output.Get("dockerfile")
|
||||
require.NotNil(t, dockerfile)
|
||||
require.True(t, dockerfile.IsObject())
|
||||
location := dockerfile.ObjectValue()["location"]
|
||||
require.True(t, dockerfile.IsMap())
|
||||
location := dockerfile.AsMap().Get("location")
|
||||
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 {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"push": resource.NewBoolProperty(false),
|
||||
"tags": resource.NewArrayProperty(
|
||||
[]resource.PropertyValue{
|
||||
resource.NewStringProperty("inline-dockerfile"),
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"push": property.New(false),
|
||||
"tags": property.New(
|
||||
[]property.Value{
|
||||
property.New("inline-dockerfile"),
|
||||
},
|
||||
),
|
||||
"buildOnPreview": resource.NewBoolProperty(true),
|
||||
"dockerfile": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"inline": resource.NewStringProperty("FROM alpine:latest"),
|
||||
"buildOnPreview": property.New(true),
|
||||
"dockerfile": property.New(map[string]property.Value{
|
||||
"inline": property.New("FROM alpine:latest"),
|
||||
}),
|
||||
},
|
||||
Hook: func(_, output resource.PropertyMap) {
|
||||
context := output["context"]
|
||||
}),
|
||||
Hook: func(_, output property.Map) {
|
||||
context := output.Get("context")
|
||||
require.NotNil(t, context)
|
||||
require.True(t, context.IsObject())
|
||||
location := context.ObjectValue()["location"]
|
||||
require.True(t, context.IsMap())
|
||||
location := context.AsMap().Get("location")
|
||||
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{
|
||||
ID: "foo,bar",
|
||||
Urn: _fakeURN,
|
||||
Properties: resource.PropertyMap{
|
||||
"tags": resource.NewArrayProperty([]resource.PropertyValue{
|
||||
resource.NewStringProperty("docker.io/pulumi/test:foo"),
|
||||
Properties: property.NewMap(map[string]property.Value{
|
||||
"tags": property.New([]property.Value{
|
||||
property.New("docker.io/pulumi/test:foo"),
|
||||
}),
|
||||
"push": resource.NewBoolProperty(true),
|
||||
"digest": resource.NewStringProperty("sha256:foo"),
|
||||
"contextHash": resource.NewStringProperty(""),
|
||||
"ref": resource.NewStringProperty(""),
|
||||
},
|
||||
"push": property.New(true),
|
||||
"digest": property.New("sha256:foo"),
|
||||
"contextHash": property.New(""),
|
||||
"ref": property.New(""),
|
||||
}),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
@@ -398,20 +397,20 @@ func TestRead(t *testing.T) {
|
||||
resp, err := s.Read(provider.ReadRequest{
|
||||
ID: "my-image",
|
||||
Urn: _fakeURN,
|
||||
Properties: resource.PropertyMap{
|
||||
"exports": resource.NewArrayProperty([]resource.PropertyValue{
|
||||
resource.NewObjectProperty(resource.PropertyMap{
|
||||
"raw": resource.NewStringProperty("type=registry"),
|
||||
Properties: property.NewMap(map[string]property.Value{
|
||||
"exports": property.New([]property.Value{
|
||||
property.New(map[string]property.Value{
|
||||
"raw": property.New("type=registry"),
|
||||
}),
|
||||
}),
|
||||
"tags": resource.NewArrayProperty([]resource.PropertyValue{
|
||||
resource.NewStringProperty(tag),
|
||||
"tags": property.New([]property.Value{
|
||||
property.New(tag),
|
||||
}),
|
||||
"digest": resource.NewStringProperty(digest),
|
||||
},
|
||||
"digest": property.New(digest),
|
||||
}),
|
||||
})
|
||||
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) {
|
||||
@@ -796,10 +795,10 @@ func TestImageDiff(t *testing.T) {
|
||||
|
||||
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)
|
||||
require.NoError(t, err)
|
||||
return resource.NewPropertyMapFromMap(raw)
|
||||
return resource.FromResourcePropertyMap(resource.NewPropertyMapFromMap(raw))
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/pulumi/pulumi-go-provider/integration"
|
||||
"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/property"
|
||||
)
|
||||
|
||||
func TestIndexLifecycle(t *testing.T) {
|
||||
@@ -45,16 +46,16 @@ func TestIndexLifecycle(t *testing.T) {
|
||||
client: realClient,
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"tag": resource.NewStringProperty(
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"tag": property.New(
|
||||
"docker.io/pulumibot/buildkit-e2e:manifest-unit",
|
||||
),
|
||||
"sources": resource.NewArrayProperty([]resource.PropertyValue{
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:arm64"),
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:amd64"),
|
||||
"sources": property.New([]property.Value{
|
||||
property.New("docker.io/pulumibot/buildkit-e2e:arm64"),
|
||||
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,
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"tag": resource.NewStringProperty(
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"tag": property.New(
|
||||
"docker.io/pulumibot/buildkit-e2e:manifest",
|
||||
),
|
||||
"sources": resource.NewArrayProperty([]resource.PropertyValue{
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:arm64"),
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:amd64"),
|
||||
"sources": property.New([]property.Value{
|
||||
property.New("docker.io/pulumibot/buildkit-e2e:arm64"),
|
||||
property.New("docker.io/pulumibot/buildkit-e2e:amd64"),
|
||||
}),
|
||||
"push": resource.NewBoolProperty(true),
|
||||
"registry": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"address": resource.NewStringProperty("docker.io"),
|
||||
"username": resource.NewStringProperty("pulumibot"),
|
||||
"password": resource.NewSecretProperty(&resource.Secret{
|
||||
Element: resource.NewStringProperty(
|
||||
os.Getenv("DOCKER_HUB_PASSWORD"),
|
||||
),
|
||||
}),
|
||||
"push": property.New(true),
|
||||
"registry": property.New(map[string]property.Value{
|
||||
"address": property.New("docker.io"),
|
||||
"username": property.New("pulumibot"),
|
||||
"password": property.New(os.Getenv("DOCKER_HUB_PASSWORD")).WithSecret(true),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -98,25 +95,21 @@ func TestIndexLifecycle(t *testing.T) {
|
||||
},
|
||||
op: func(t *testing.T) integration.Operation {
|
||||
return integration.Operation{
|
||||
Inputs: resource.PropertyMap{
|
||||
"tag": resource.NewStringProperty(
|
||||
Inputs: property.NewMap(map[string]property.Value{
|
||||
"tag": property.New(
|
||||
"docker.io/pulumibot/buildkit-e2e:manifest",
|
||||
),
|
||||
"sources": resource.NewArrayProperty([]resource.PropertyValue{
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:arm64"),
|
||||
resource.NewStringProperty("docker.io/pulumibot/buildkit-e2e:amd64"),
|
||||
"sources": property.New([]property.Value{
|
||||
property.New("docker.io/pulumibot/buildkit-e2e:arm64"),
|
||||
property.New("docker.io/pulumibot/buildkit-e2e:amd64"),
|
||||
}),
|
||||
"push": resource.NewBoolProperty(true),
|
||||
"registry": resource.NewObjectProperty(resource.PropertyMap{
|
||||
"address": resource.NewStringProperty("docker.io"),
|
||||
"username": resource.NewStringProperty("pulumibot"),
|
||||
"password": resource.NewSecretProperty(&resource.Secret{
|
||||
Element: resource.NewStringProperty(
|
||||
os.Getenv("DOCKER_HUB_PASSWORD"),
|
||||
),
|
||||
}),
|
||||
"push": property.New(true),
|
||||
"registry": property.New(map[string]property.Value{
|
||||
"address": property.New("docker.io"),
|
||||
"username": property.New("pulumibot"),
|
||||
"password": property.New(os.Getenv("DOCKER_HUB_PASSWORD")).WithSecret(true),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -223,10 +216,10 @@ func TestIndexDiff(t *testing.T) {
|
||||
|
||||
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)
|
||||
require.NoError(t, err)
|
||||
return resource.NewPropertyMapFromMap(raw)
|
||||
return resource.FromResourcePropertyMap(resource.NewPropertyMapFromMap(raw))
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"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/util/contract"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/property"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -139,7 +140,9 @@ func diffConfigIgnoreInternal(
|
||||
diffConfig 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) {
|
||||
delete(req.News, "__internal")
|
||||
m := req.News.AsMap()
|
||||
delete(m, "__internal")
|
||||
req.News = property.NewMap(m)
|
||||
|
||||
return diffConfig(ctx, req)
|
||||
}
|
||||
|
||||
@@ -15,13 +15,8 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pulumi/pulumi-docker-build/provider/internal"
|
||||
"github.com/pulumi/pulumi-docker-build/provider/internal/deprecated"
|
||||
gp "github.com/pulumi/pulumi-go-provider"
|
||||
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
|
||||
"github.com/pulumi/pulumi/pkg/v3/resource/provider"
|
||||
rpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
|
||||
)
|
||||
@@ -39,37 +34,5 @@ func Serve() error {
|
||||
|
||||
// New creates a new provider.
|
||||
func New(host *provider.HostClient) (rpc.ResourceProviderServer, error) {
|
||||
return gp.RawServer(Name, Version, configurableProvider(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
|
||||
return gp.RawServer(Name, Version, internal.NewBuildxProvider())(host)
|
||||
}
|
||||
|
||||
@@ -22,37 +22,8 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
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) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user