Changes for upcoming go-provider v1.0 (#525)

Fixes #535
This commit is contained in:
Bryce Lampe
2025-05-15 16:38:58 -07:00
committed by GitHub
parent a59206e63c
commit 4436ab5e76
22 changed files with 681 additions and 707 deletions

View File

@@ -1 +1 @@
3.163.0 3.169.0

View File

@@ -89,7 +89,7 @@ ${PULUMI}: go.sum
GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3 GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs/v3
GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3
GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi-java/pkg/cmd/pulumi-language-java GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi-java/pkg/cmd/pulumi-language-java
GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet/v3
GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi-yaml/cmd/pulumi-converter-yaml GOBIN=${WORKING_DIR}/bin go install github.com/pulumi/pulumi-yaml/cmd/pulumi-converter-yaml
${GOGLANGCILINT}: go.sum ${GOGLANGCILINT}: go.sum

View File

@@ -5,151 +5,151 @@ config = pulumi.Config()
docker_hub_password = config.require("dockerHubPassword") docker_hub_password = config.require("dockerHubPassword")
multi_platform = docker_build.Image("multiPlatform", multi_platform = docker_build.Image("multiPlatform",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.multiPlatform", "location": "./app/Dockerfile.multiPlatform",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
platforms=[ platforms=[
docker_build.Platform.PLAN9_AMD64, docker_build.Platform.PLAN9_AMD64,
docker_build.Platform.PLAN9_386, docker_build.Platform.PLAN9_386,
]) ])
registry_push = docker_build.Image("registryPush", registry_push = docker_build.Image("registryPush",
push=False, push=False,
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
tags=["docker.io/pulumibot/buildkit-e2e:example"], tags=["docker.io/pulumibot/buildkit-e2e:example"],
exports=[docker_build.ExportArgs( exports=[{
registry=docker_build.ExportRegistryArgs( "registry": {
oci_media_types=True, "oci_media_types": True,
push=False, "push": False,
), },
)], }],
registries=[docker_build.RegistryArgs( registries=[{
address="docker.io", "address": "docker.io",
username="pulumibot", "username": "pulumibot",
password=docker_hub_password, "password": docker_hub_password,
)]) }])
cached = docker_build.Image("cached", cached = docker_build.Image("cached",
push=False, push=False,
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
cache_to=[docker_build.CacheToArgs( cache_to=[{
local=docker_build.CacheToLocalArgs( "local": {
dest="tmp/cache", "dest": "tmp/cache",
mode=docker_build.CacheMode.MAX, "mode": docker_build.CacheMode.MAX,
), },
)], }],
cache_from=[docker_build.CacheFromArgs( cache_from=[{
local=docker_build.CacheFromLocalArgs( "local": {
src="tmp/cache", "src": "tmp/cache",
), },
)]) }])
build_args = docker_build.Image("buildArgs", build_args = docker_build.Image("buildArgs",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.buildArgs", "location": "./app/Dockerfile.buildArgs",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
build_args={ build_args={
"SET_ME_TO_TRUE": "true", "SET_ME_TO_TRUE": "true",
}) })
extra_hosts = docker_build.Image("extraHosts", extra_hosts = docker_build.Image("extraHosts",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.extraHosts", "location": "./app/Dockerfile.extraHosts",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
add_hosts=["metadata.google.internal:169.254.169.254"]) add_hosts=["metadata.google.internal:169.254.169.254"])
ssh_mount = docker_build.Image("sshMount", ssh_mount = docker_build.Image("sshMount",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.sshMount", "location": "./app/Dockerfile.sshMount",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
ssh=[docker_build.SSHArgs( ssh=[{
id="default", "id": "default",
)]) }])
secrets = docker_build.Image("secrets", secrets = docker_build.Image("secrets",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.secrets", "location": "./app/Dockerfile.secrets",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
secrets={ secrets={
"password": "hunter2", "password": "hunter2",
}) })
labels = docker_build.Image("labels", labels = docker_build.Image("labels",
push=False, push=False,
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
labels={ labels={
"description": "This image will get a descriptive label 👍", "description": "This image will get a descriptive label 👍",
}) })
target = docker_build.Image("target", target = docker_build.Image("target",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.target", "location": "./app/Dockerfile.target",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
target="build-me") target="build-me")
named_contexts = docker_build.Image("namedContexts", named_contexts = docker_build.Image("namedContexts",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
location="./app/Dockerfile.namedContexts", "location": "./app/Dockerfile.namedContexts",
), },
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
named={ "named": {
"golang:latest": docker_build.ContextArgs( "golang:latest": {
location="docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984", "location": "docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
), },
}, },
)) })
remote_context = docker_build.Image("remoteContext", remote_context = docker_build.Image("remoteContext",
push=False, push=False,
context=docker_build.BuildContextArgs( context={
location="https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile", "location": "https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
)) })
remote_context_with_inline = docker_build.Image("remoteContextWithInline", remote_context_with_inline = docker_build.Image("remoteContextWithInline",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
inline="""FROM busybox "inline": """FROM busybox
COPY hello.c ./ COPY hello.c ./
""", """,
), },
context=docker_build.BuildContextArgs( context={
location="https://github.com/docker-library/hello-world.git", "location": "https://github.com/docker-library/hello-world.git",
)) })
inline = docker_build.Image("inline", inline = docker_build.Image("inline",
push=False, push=False,
dockerfile=docker_build.DockerfileArgs( dockerfile={
inline="""FROM alpine "inline": """FROM alpine
RUN echo "This uses an inline Dockerfile! 👍" RUN echo "This uses an inline Dockerfile! 👍"
""", """,
)) })
docker_load = docker_build.Image("dockerLoad", docker_load = docker_build.Image("dockerLoad",
push=False, push=False,
context=docker_build.BuildContextArgs( context={
location="./app", "location": "./app",
), },
exports=[docker_build.ExportArgs( exports=[{
docker=docker_build.ExportDockerArgs( "docker": {
tar=True, "tar": True,
), },
)]) }])
pulumi.export("platforms", multi_platform.platforms) pulumi.export("platforms", multi_platform.platforms)

28
go.mod
View File

@@ -15,15 +15,15 @@ require (
github.com/muesli/reflow v0.3.0 github.com/muesli/reflow v0.3.0
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/v3 v3.0.0-20250515194217-855e3e4c894c
github.com/pulumi/pulumi-go-provider v0.26.0 github.com/pulumi/pulumi-go-provider v1.0.0-rc.2
github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250501074704-87881c4a7c04 github.com/pulumi/pulumi-java/pkg v1.11.0
github.com/pulumi/pulumi-yaml v1.17.0 github.com/pulumi/pulumi-yaml v1.17.0
github.com/pulumi/pulumi/pkg/v3 v3.165.0 github.com/pulumi/pulumi/pkg/v3 v3.169.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-20250508095305-a4bdc94d01aa
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-20250508095305-a4bdc94d01aa
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-20250508095305-a4bdc94d01aa
github.com/pulumi/pulumi/sdk/v3 v3.165.0 github.com/pulumi/pulumi/sdk/v3 v3.169.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
@@ -34,7 +34,7 @@ require (
go.opentelemetry.io/otel/sdk v1.35.0 go.opentelemetry.io/otel/sdk v1.35.0
go.opentelemetry.io/otel/trace v1.35.0 go.opentelemetry.io/otel/trace v1.35.0
go.uber.org/mock v0.5.2 go.uber.org/mock v0.5.2
golang.org/x/crypto v0.37.0 golang.org/x/crypto v0.38.0
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
google.golang.org/protobuf v1.36.6 google.golang.org/protobuf v1.36.6
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
@@ -459,12 +459,12 @@ require (
gocloud.dev/secrets/hashivault v0.37.0 // indirect gocloud.dev/secrets/hashivault v0.37.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/mod v0.24.0 // indirect golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect golang.org/x/net v0.40.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sync v0.13.0 // indirect golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.32.0 // indirect golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.31.0 // indirect golang.org/x/term v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect golang.org/x/text v0.25.0 // indirect
golang.org/x/time v0.6.0 // indirect golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.32.0 // indirect golang.org/x/tools v0.32.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect

56
go.sum
View File

@@ -886,24 +886,24 @@ github.com/pulumi/inflector v0.2.1 h1:bqyiish3tq//vLeLiEstSFE5K7RNjy/ce47ed4QATu
github.com/pulumi/inflector v0.2.1/go.mod h1:HUFCjcPTz96YtTuUlwG3i3EZG4WlniBvR9bd+iJxCUY= github.com/pulumi/inflector v0.2.1/go.mod h1:HUFCjcPTz96YtTuUlwG3i3EZG4WlniBvR9bd+iJxCUY=
github.com/pulumi/providertest v0.3.1 h1:vlftr7TZlObh81mL88IhhF0/9ZbLrZZos4NAvR4HUUw= github.com/pulumi/providertest v0.3.1 h1:vlftr7TZlObh81mL88IhhF0/9ZbLrZZos4NAvR4HUUw=
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/v3 v3.0.0-20250515194217-855e3e4c894c h1:UTPnj4E06/n+T6ffEevqvS2f+zKLdRBeM81aQwhwNlE=
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/v3 v3.0.0-20250515194217-855e3e4c894c/go.mod h1:4XmrdCzJ36AigIW8B0HWjkjfgmY2DZTLqv4BQal3hSg=
github.com/pulumi/pulumi-go-provider v0.26.0 h1:3ia10+irvv7qPph2NZ2YwUGI/KCf6li8Frlc1luv7D4= github.com/pulumi/pulumi-go-provider v1.0.0-rc.2 h1:Fkv+MVGOE4XBwZ7M3Tp4vVWu3YE6w1pCod0vmMkukm0=
github.com/pulumi/pulumi-go-provider v0.26.0/go.mod h1:zJiGxY5xnodPzLulpRS+fsS960MzeCdlsdiVCZ5TMRA= github.com/pulumi/pulumi-go-provider v1.0.0-rc.2/go.mod h1:84yaWdhVcyPG+Vq3HfcDPPeGsNEMIQCD+S1WsymEw9A=
github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250501074704-87881c4a7c04 h1:JtnozyKVJrV3ITXhnZL82lO3V8pbqrA+p5co8b3hbr4= github.com/pulumi/pulumi-java/pkg v1.11.0 h1:M8C7CKxwBSE/c5RcoGF0sAUSFZywjd7CjmTRQh8nvNk=
github.com/pulumi/pulumi-java/pkg v1.10.1-0.20250501074704-87881c4a7c04/go.mod h1:fE/A/3U2rpqpQKG0RrmmHjf0q+7shjsSfi74mhmLF6g= github.com/pulumi/pulumi-java/pkg v1.11.0/go.mod h1:zoQdTjj488DhUx8dNed6SW1fJnAE4GwGLBVDRpsQVE8=
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.165.0 h1:a0UOxhM+yUi5NH+SP5lv0YHxac3JOaeaZ/VINVkK+bM= github.com/pulumi/pulumi/pkg/v3 v3.169.0 h1:q1f36HRYhXEKZVe3b0SQGKJjl+9llCHzAztn+aiidtE=
github.com/pulumi/pulumi/pkg/v3 v3.165.0/go.mod h1:wJDlCqph9G1OCX8BYfjRp8yOtqBXZLij57fGbn1lXsM= github.com/pulumi/pulumi/pkg/v3 v3.169.0/go.mod h1:ofgvwLttErApwvvvvmx40VhxEoNl34q0XVSraK40RqQ=
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-20250508095305-a4bdc94d01aa h1:b0CMni/Q621ChYaTe6FMHXYfrcH1FzAXjUsOsUO24nc=
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-20250508095305-a4bdc94d01aa/go.mod h1:5Vs9hUjv9+R4K97UUul5KjFIpUi0AmZdVZVE+Yl0UoY=
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-20250508095305-a4bdc94d01aa h1:RB9e9Gc4PMyX+IRdfR7VipRQeBdc3K93ROrnbmHS6V0=
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-20250508095305-a4bdc94d01aa/go.mod h1:5lah9DjodVv9BURtk2ykbJams7TclP+Xr7h+NK4B0gQ=
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-20250508095305-a4bdc94d01aa h1:3eGefORCsSeUrIYe9GIklycGRoKsKAGq3dfg1RYb3nM=
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-20250508095305-a4bdc94d01aa/go.mod h1:6LYkwLXNHz68cnVIgdsthaUaxZZDIJp1Ag0RyUnPNek=
github.com/pulumi/pulumi/sdk/v3 v3.165.0 h1:cglplKZOJDpqH8wa/2J250G9az/sE9eKp9fS2bC+vi8= github.com/pulumi/pulumi/sdk/v3 v3.169.0 h1:bgz1fp2rl28khSXgF4FaRQiB9wh3lSKWtzUOGalf+x4=
github.com/pulumi/pulumi/sdk/v3 v3.165.0/go.mod h1:GAaHrdv3kWJHbzkFFFflGbTBQXUYu6SF1ZCo+O9jo44= github.com/pulumi/pulumi/sdk/v3 v3.169.0/go.mod h1:Qhe4dOjqedyLr47kGGnG6ULIbzaPTlmjAvPqNQ1Ollo=
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=
@@ -1196,8 +1196,8 @@ golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
@@ -1250,8 +1250,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
@@ -1267,8 +1267,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1311,8 +1311,8 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -1323,8 +1323,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -1336,8 +1336,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

View File

@@ -63,6 +63,36 @@ type Client interface {
SupportsMultipleExports() bool SupportsMultipleExports() bool
} }
// registryGetter is something that can return a list of [Registry].
type registryGetter interface {
GetRegistries() []Registry
}
// clientF builds a Docker client. The order of registryGetters is significant.
// We typically prefer credentials from args, then provider config, then the
// host. Provide them to this function in order of increasing priority: host,
// config, args.
//
// We ignore state because if its creds differ from those in args then they are
// likely volatile and also likely expired.
type clientF func(context.Context, *host, ...registryGetter) (Client, error)
// RealClientF builds a real Docker client with auth layered on top of the
// host's latent credentials.
func RealClientF(_ context.Context, host *host, getters ...registryGetter) (Client, error) {
auths := []Registry{}
for _, rg := range getters {
auths = append(auths, rg.GetRegistries()...)
}
return wrap(host, auths...)
}
func mockClientF(c Client) clientF {
return func(context.Context, *host, ...registryGetter) (Client, error) {
return c, nil
}
}
// Build encapsulates all of the user-provider build parameters and options. // Build encapsulates all of the user-provider build parameters and options.
type Build interface { type Build interface {
BuildOptions() controllerapi.BuildOptions BuildOptions() controllerapi.BuildOptions

View File

@@ -38,7 +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/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/property"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
) )
@@ -61,7 +61,10 @@ var _imageExamples string
var _migration string var _migration string
// Image is a Docker image build using buildkit. // Image is a Docker image build using buildkit.
type Image struct{} type Image struct {
clientF clientF
config *Config
}
// Annotate provides a description of the Image resource. // Annotate provides a description of the Image resource.
func (i *Image) Annotate(a infer.Annotator) { func (i *Image) Annotate(a infer.Annotator) {
@@ -281,6 +284,11 @@ func (ia *ImageArgs) Annotate(a infer.Annotator) {
a.SetDefault(&ia.Network, Default) a.SetDefault(&ia.Network, Default)
} }
// GetRegistries returns the image's registries, if any.
func (ia ImageArgs) GetRegistries() []Registry {
return ia.Registries
}
// ImageState is serialized to the program's state file. // ImageState is serialized to the program's state file.
type ImageState struct { type ImageState struct {
ImageArgs ImageArgs
@@ -329,38 +337,25 @@ func (is *ImageState) Annotate(a infer.Annotator) {
// client produces a CLI client scoped to this resource and layered on top of // client produces a CLI client scoped to this resource and layered on top of
// any host-level credentials. // any host-level credentials.
func (i *Image) client(ctx context.Context, state ImageState, args ImageArgs) (Client, error) { func (i *Image) client(ctx context.Context, args ImageArgs) (Client, error) {
cfg := infer.GetConfig[Config](ctx) return i.clientF(ctx, i.config.getHost(), i.config, args)
if cli, ok := ctx.Value(_mockClientKey).(Client); ok {
return cli, nil
}
// We prefer auth from args, the provider, and state in that order. We
// build a slice in reverse order because wrap() will overwrite earlier
// entries with later ones.
auths := []Registry{}
auths = append(auths, cfg.Registries...)
auths = append(auths, args.Registries...)
return wrap(cfg.host, auths...)
} }
// Check validates ImageArgs, sets defaults, and ensures our client is // Check validates ImageArgs, sets defaults, and ensures our client is
// authenticated. // authenticated.
func (i *Image) Check( func (i *Image) Check(
ctx context.Context, ctx context.Context,
_ string, req infer.CheckRequest,
_ resource.PropertyMap, ) (infer.CheckResponse[ImageArgs], error) {
news resource.PropertyMap, args, failures, err := infer.DefaultCheck[ImageArgs](ctx, req.NewInputs)
) (ImageArgs, []provider.CheckFailure, error) {
args, failures, err := infer.DefaultCheck[ImageArgs](ctx, news)
if err != nil || len(failures) != 0 { if err != nil || len(failures) != 0 {
return args, failures, err return infer.CheckResponse[ImageArgs]{Failures: failures, Inputs: args}, err
} }
// :( // If the inputs aren't fully resolved we perform a weaker validation, for
preview := news.ContainsUnknowns() // 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
@@ -376,7 +371,7 @@ func (i *Image) Check(
} }
} }
return args, failures, err return infer.CheckResponse[ImageArgs]{Failures: failures, Inputs: args}, err
} }
type checkFailure struct { type checkFailure struct {
@@ -683,12 +678,11 @@ func (ia *ImageArgs) validate(supportsMultipleExports, preview bool) (controller
// Create builds an image using buildkit. // Create builds an image using buildkit.
func (i *Image) Create( func (i *Image) Create(
ctx context.Context, ctx context.Context,
name string, req infer.CreateRequest[ImageArgs],
input ImageArgs, ) (infer.CreateResponse[ImageState], error) {
preview bool, input := req.Inputs
) (string, ImageState, error) {
state := ImageState{ImageArgs: input} state := ImageState{ImageArgs: input}
id := name id := req.Name
// Default our ref to one of our tags. // Default our ref to one of our tags.
for _, tag := range state.Tags { for _, tag := range state.Tags {
@@ -699,22 +693,31 @@ func (i *Image) Create(
break break
} }
cli, err := i.client(ctx, state, input) cli, err := i.client(ctx, input)
if err != nil { if err != nil {
return id, state, err return infer.CreateResponse[ImageState]{ID: id, Output: state}, err
} }
ok, err := cli.BuildKitEnabled() ok, err := cli.BuildKitEnabled()
if err != nil { if err != nil {
return id, state, fmt.Errorf("checking buildkit compatibility: %w", err) return infer.CreateResponse[ImageState]{
ID: id,
Output: state,
}, fmt.Errorf("checking buildkit compatibility: %w", err)
} }
if !ok { if !ok {
return id, state, errors.New("buildkit is not supported on this host") return infer.CreateResponse[ImageState]{
ID: id,
Output: state,
}, errors.New("buildkit is not supported on this host")
} }
build, err := input.toBuild(ctx, cli.SupportsMultipleExports(), preview) build, err := input.toBuild(ctx, cli.SupportsMultipleExports(), req.DryRun)
if err != nil { if err != nil {
return id, state, fmt.Errorf("preparing: %w", err) return infer.CreateResponse[ImageState]{
ID: id,
Output: state,
}, fmt.Errorf("preparing: %w", err)
} }
hash, err := hashBuildContext( hash, err := hashBuildContext(
@@ -723,21 +726,24 @@ func (i *Image) Create(
input.Context.Named.Map(), input.Context.Named.Map(),
) )
if err != nil { if err != nil {
return id, state, fmt.Errorf("hashing build context: %w", err) return infer.CreateResponse[ImageState]{
ID: id,
Output: state,
}, fmt.Errorf("hashing build context: %w", err)
} }
state.ContextHash = hash state.ContextHash = hash
if preview && !input.shouldBuildOnPreview() { if req.DryRun && !input.shouldBuildOnPreview() {
return id, state, nil return infer.CreateResponse[ImageState]{ID: id, Output: state}, nil
} }
if preview && !input.buildable() { if req.DryRun && !input.buildable() {
provider.GetLogger(ctx).Warning("Skipping preview build because some inputs are unknown.") provider.GetLogger(ctx).Warning("Skipping preview build because some inputs are unknown.")
return id, state, nil return infer.CreateResponse[ImageState]{ID: id, Output: state}, nil
} }
result, err := cli.Build(ctx, build) result, err := cli.Build(ctx, build)
if err != nil { if err != nil {
return id, state, err return infer.CreateResponse[ImageState]{ID: id, Output: state}, err
} }
if d, ok := result.ExporterResponse[exptypes.ExporterImageDigestKey]; ok { if d, ok := result.ExporterResponse[exptypes.ExporterImageDigestKey]; ok {
@@ -747,7 +753,7 @@ func (i *Image) Create(
if state.Digest == "" { if state.Digest == "" {
// Can't construct a ref, nothing else to do. // Can't construct a ref, nothing else to do.
return id, state, nil return infer.CreateResponse[ImageState]{ID: id, Output: state}, nil
} }
// Take the first registry tag we find and add a digest to it. That becomes // Take the first registry tag we find and add a digest to it. That becomes
@@ -762,7 +768,7 @@ func (i *Image) Create(
break break
} }
return id, state, nil return infer.CreateResponse[ImageState]{ID: id, Output: state}, nil
} }
// Update builds a new image. Normally we create-replace resources, but for // Update builds a new image. Normally we create-replace resources, but for
@@ -770,36 +776,41 @@ func (i *Image) Create(
// updates and simply re-build the image without deleting anything. // updates and simply re-build the image without deleting anything.
func (i *Image) Update( func (i *Image) Update(
ctx context.Context, ctx context.Context,
name string, req infer.UpdateRequest[ImageArgs, ImageState],
_ ImageState, ) (infer.UpdateResponse[ImageState], error) {
input ImageArgs, resp, err := i.Create(ctx,
preview bool, infer.CreateRequest[ImageArgs]{Name: req.ID, Inputs: req.Inputs, DryRun: req.DryRun},
) (ImageState, error) { )
_, state, err := i.Create(ctx, name, input, preview) return infer.UpdateResponse[ImageState]{Output: resp.Output}, err
return state, err
} }
// Read attempts to read manifests from an image's exports. An image without // Read attempts to read manifests from an image's exports. An image without
// exports will have no manifests. // exports will have no manifests.
func (i *Image) Read( func (i *Image) Read(
ctx context.Context, ctx context.Context,
name string, req infer.ReadRequest[ImageArgs, ImageState],
input ImageArgs,
state ImageState,
) ( ) (
string, // id infer.ReadResponse[ImageArgs, ImageState],
ImageArgs, // normalized inputs
ImageState, // normalized state
error, error,
) { ) {
cli, err := i.client(ctx, state, input) state, input := req.State, req.Inputs
cli, err := i.client(ctx, input)
if err != nil { if err != nil {
return name, input, state, err return infer.ReadResponse[ImageArgs, ImageState]{
ID: req.ID,
Inputs: input,
State: state,
}, err
} }
if !state.isExported() { if !state.isExported() {
// Nothing was pushed -- all done. // Nothing was pushed -- all done.
return name, input, state, nil return infer.ReadResponse[ImageArgs, ImageState]{
ID: req.ID,
Inputs: input,
State: state,
}, nil
} }
tagsToKeep := []string{} tagsToKeep := []string{}
@@ -835,29 +846,29 @@ func (i *Image) Read(
// If we couldn't find the tags we expected then return an empty ID to // If we couldn't find the tags we expected then return an empty ID to
// delete the resource. // delete the resource.
if len(input.Tags) > 0 && len(tagsToKeep) == 0 { if len(input.Tags) > 0 && len(tagsToKeep) == 0 {
return "", input, state, nil return infer.ReadResponse[ImageArgs, ImageState]{ID: "", Inputs: input, State: state}, nil
} }
state.Tags = tagsToKeep state.Tags = tagsToKeep
return name, input, state, nil return infer.ReadResponse[ImageArgs, ImageState]{ID: req.ID, Inputs: input, State: state}, nil
} }
// Delete deletes an Image. If the Image was already deleted out-of-band it is // Delete deletes an Image. If the Image was already deleted out-of-band it is
// treated as a success. // treated as a success.
func (i *Image) Delete( func (i *Image) Delete(
ctx context.Context, ctx context.Context,
_ string, req infer.DeleteRequest[ImageState],
state ImageState, ) (infer.DeleteResponse, error) {
) error { state := req.State
cli, err := i.client(ctx, state, state.ImageArgs) cli, err := i.client(ctx, state.ImageArgs)
if err != nil { if err != nil {
return err return infer.DeleteResponse{}, err
} }
if state.Digest == "" { if state.Digest == "" {
// Nothing was exported. Just try to delete the local image. // Nothing was exported. Just try to delete the local image.
return cli.Delete(ctx, state.Ref) return infer.DeleteResponse{}, cli.Delete(ctx, state.Ref)
} }
digests := []string{} digests := []string{}
@@ -885,17 +896,17 @@ func (i *Image) Delete(
multierr = errors.Join(multierr, err) multierr = errors.Join(multierr, err)
} }
return multierr return infer.DeleteResponse{}, multierr
} }
// Diff re-implements most of the default diff behavior, with the exception of // Diff re-implements most of the default diff behavior, with the exception of
// ignoring "password" changes on registry inputs. // ignoring "password" changes on registry inputs.
func (*Image) Diff( func (*Image) Diff(
_ context.Context, _ context.Context,
_ string, req infer.DiffRequest[ImageArgs, ImageState],
olds ImageState,
news ImageArgs,
) (provider.DiffResponse, error) { ) (provider.DiffResponse, error) {
olds, news := req.State, req.Inputs
diff := map[string]provider.PropertyDiff{} diff := map[string]provider.PropertyDiff{}
update := provider.PropertyDiff{Kind: provider.Update} update := provider.PropertyDiff{Kind: provider.Update}

View File

@@ -35,9 +35,11 @@ import (
"go.uber.org/mock/gomock" "go.uber.org/mock/gomock"
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/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 +86,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 +132,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 +161,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 +194,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 +221,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 +254,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 +296,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())
}, },
} }
}, },
@@ -328,7 +328,7 @@ func TestImageLifecycle(t *testing.T) {
Resource: "docker-build:index:Image", Resource: "docker-build:index:Image",
Create: tt.op(t), Create: tt.op(t),
} }
s := newServer(tt.client(t)) s := newServer(t.Context(), t, mockClientF(tt.client(t)))
err := s.Configure(provider.ConfigureRequest{}) err := s.Configure(provider.ConfigureRequest{})
require.NoError(t, err) require.NoError(t, err)
@@ -353,21 +353,16 @@ func TestDelete(t *testing.T) {
Delete(gomock.Any(), "docker.io/pulumi/test@sha256:foo"). Delete(gomock.Any(), "docker.io/pulumi/test@sha256:foo").
Return(errNotFound{}) Return(errNotFound{})
s := newServer(client) i := &Image{clientF: mockClientF(client)}
err := s.Configure(provider.ConfigureRequest{})
require.NoError(t, err)
err = s.Delete(provider.DeleteRequest{ _, err := i.Delete(t.Context(), infer.DeleteRequest[ImageState]{
ID: "foo,bar", ID: "foo,bar",
Urn: _fakeURN, State: ImageState{
Properties: resource.PropertyMap{ ImageArgs: ImageArgs{
"tags": resource.NewArrayProperty([]resource.PropertyValue{ Tags: []string{"docker.io/pulumi/test:foo"},
resource.NewStringProperty("docker.io/pulumi/test:foo"), Push: true,
}), },
"push": resource.NewBoolProperty(true), Digest: "sha256:foo",
"digest": resource.NewStringProperty("sha256:foo"),
"contextHash": resource.NewStringProperty(""),
"ref": resource.NewStringProperty(""),
}, },
}) })
assert.NoError(t, err) assert.NoError(t, err)
@@ -391,27 +386,21 @@ func TestRead(t *testing.T) {
}, },
}, nil) }, nil)
s := newServer(client) i := &Image{clientF: mockClientF(client)}
err := s.Configure(provider.ConfigureRequest{})
require.NoError(t, err)
resp, err := s.Read(provider.ReadRequest{ resp, err := i.Read(t.Context(), infer.ReadRequest[ImageArgs, ImageState]{
ID: "my-image", ID: "my-image",
Urn: _fakeURN, State: ImageState{
Properties: resource.PropertyMap{ ImageArgs: ImageArgs{
"exports": resource.NewArrayProperty([]resource.PropertyValue{ Exports: []Export{{Raw: "type=registry"}},
resource.NewObjectProperty(resource.PropertyMap{ Tags: []string{tag},
"raw": resource.NewStringProperty("type=registry"), },
}), Digest: digest,
}),
"tags": resource.NewArrayProperty([]resource.PropertyValue{
resource.NewStringProperty(tag),
}),
"digest": resource.NewStringProperty(digest),
}, },
}) })
require.NoError(t, err) require.NoError(t, err)
assert.NotNil(t, resp.Properties["exports"].ArrayValue()[0].ObjectValue()["manifest"]) assert.Equal(t, []string{tag}, resp.State.Tags)
} }
func TestImageDiff(t *testing.T) { func TestImageDiff(t *testing.T) {
@@ -432,21 +421,21 @@ func TestImageDiff(t *testing.T) {
} }
tests := []struct { tests := []struct {
name string name string
olds func(*testing.T, ImageState) ImageState state func(*testing.T, ImageState) ImageState
news func(*testing.T, ImageArgs) ImageArgs inputs func(*testing.T, ImageArgs) ImageArgs
wantChanges bool wantChanges bool
}{ }{
{ {
name: "no diff if build context is unchanged", name: "no diff if build context is unchanged",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(*testing.T, ImageArgs) ImageArgs { return baseArgs }, inputs: func(*testing.T, ImageArgs) ImageArgs { return baseArgs },
wantChanges: false, wantChanges: false,
}, },
{ {
name: "no diff if registry password changes", name: "no diff if registry password changes",
olds: func(_ *testing.T, s ImageState) ImageState { state: func(_ *testing.T, s ImageState) ImageState {
s.Registries = []Registry{{ s.Registries = []Registry{{
Address: "foo", Address: "foo",
Username: "foo", Username: "foo",
@@ -454,7 +443,7 @@ func TestImageDiff(t *testing.T) {
}} }}
return s return s
}, },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Registries = []Registry{{ a.Registries = []Registry{{
Address: "foo", Address: "foo",
Username: "foo", Username: "foo",
@@ -466,11 +455,11 @@ func TestImageDiff(t *testing.T) {
}, },
{ {
name: "no diff if pull=true but no exports", name: "no diff if pull=true but no exports",
olds: func(_ *testing.T, is ImageState) ImageState { state: func(_ *testing.T, is ImageState) ImageState {
is.Pull = true is.Pull = true
return is return is
}, },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.Pull = true ia.Pull = true
return ia return ia
}, },
@@ -478,12 +467,12 @@ func TestImageDiff(t *testing.T) {
}, },
{ {
name: "diff if pull=true with exports", name: "diff if pull=true with exports",
olds: func(_ *testing.T, is ImageState) ImageState { state: func(_ *testing.T, is ImageState) ImageState {
is.Pull = true is.Pull = true
is.Load = true is.Load = true
return is return is
}, },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.Pull = true ia.Pull = true
ia.Load = true ia.Load = true
return ia return ia
@@ -491,9 +480,9 @@ func TestImageDiff(t *testing.T) {
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if build context changes", name: "diff if build context changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, a ImageArgs) ImageArgs { inputs: func(t *testing.T, a ImageArgs) ImageArgs {
tmp := filepath.Join(a.Context.Location, "tmp") tmp := filepath.Join(a.Context.Location, "tmp")
err := os.WriteFile(tmp, []byte{}, 0o600) err := os.WriteFile(tmp, []byte{}, 0o600)
require.NoError(t, err) require.NoError(t, err)
@@ -503,9 +492,9 @@ func TestImageDiff(t *testing.T) {
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if registry added", name: "diff if registry added",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Registries = []Registry{{}} a.Registries = []Registry{{}}
return a return a
}, },
@@ -513,7 +502,7 @@ func TestImageDiff(t *testing.T) {
}, },
{ {
name: "diff if registry user changes", name: "diff if registry user changes",
olds: func(_ *testing.T, s ImageState) ImageState { state: func(_ *testing.T, s ImageState) ImageState {
s.Registries = []Registry{{ s.Registries = []Registry{{
Address: "foo", Address: "foo",
Username: "foo", Username: "foo",
@@ -521,7 +510,7 @@ func TestImageDiff(t *testing.T) {
}} }}
return s return s
}, },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Registries = []Registry{{ a.Registries = []Registry{{
Address: "DIFFERENT USER", Address: "DIFFERENT USER",
Username: "foo", Username: "foo",
@@ -532,9 +521,9 @@ func TestImageDiff(t *testing.T) {
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if buildArgs changes", name: "diff if buildArgs changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.BuildArgs = map[string]string{ a.BuildArgs = map[string]string{
"foo": "bar", "foo": "bar",
} }
@@ -543,36 +532,36 @@ func TestImageDiff(t *testing.T) {
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if pull changes", name: "diff if pull changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.Pull = true ia.Pull = true
return ia return ia
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if load changes", name: "diff if load changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.Load = true ia.Load = true
return ia return ia
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if push changes", name: "diff if push changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.Push = true ia.Push = true
return ia return ia
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if buildOnPreview doesn't change", name: "diff if buildOnPreview doesn't change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
val := true val := true
ia.BuildOnPreview = &val ia.BuildOnPreview = &val
return ia return ia
@@ -580,9 +569,9 @@ func TestImageDiff(t *testing.T) {
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if buildOnPreview changes", name: "diff if buildOnPreview changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
val := false val := false
ia.BuildOnPreview = &val ia.BuildOnPreview = &val
return ia return ia
@@ -590,171 +579,171 @@ func TestImageDiff(t *testing.T) {
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if ssh changes", name: "diff if ssh changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.SSH = []SSH{{ID: "default"}} ia.SSH = []SSH{{ID: "default"}}
return ia return ia
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if hosts change", name: "diff if hosts change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(t *testing.T, ia ImageArgs) ImageArgs { inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
ia.AddHosts = []string{"localhost"} ia.AddHosts = []string{"localhost"}
return ia return ia
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if cacheFrom changes", name: "diff if cacheFrom changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.CacheFrom = []CacheFrom{{Raw: "a"}} a.CacheFrom = []CacheFrom{{Raw: "a"}}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if cacheTo changes", name: "diff if cacheTo changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.CacheTo = []CacheTo{{Raw: "a"}} a.CacheTo = []CacheTo{{Raw: "a"}}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if context changes", name: "diff if context changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Context = &BuildContext{Context: Context{Location: "testdata/ignores"}} a.Context = &BuildContext{Context: Context{Location: "testdata/ignores"}}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if named context changes", name: "diff if named context changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Context = &BuildContext{Named: NamedContexts{"foo": Context{Location: "bar"}}} a.Context = &BuildContext{Named: NamedContexts{"foo": Context{Location: "bar"}}}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if network changes", name: "diff if network changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Network = &host a.Network = &host
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if dockerfile location changes", name: "diff if dockerfile location changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Dockerfile = &Dockerfile{Location: "testdata/ignores/basedir/Dockerfile"} a.Dockerfile = &Dockerfile{Location: "testdata/ignores/basedir/Dockerfile"}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if dockerfile inline changes", name: "diff if dockerfile inline changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Dockerfile = &Dockerfile{Inline: "FROM scratch"} a.Dockerfile = &Dockerfile{Inline: "FROM scratch"}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if platforms change", name: "diff if platforms change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Platforms = []Platform{"linux/amd64"} a.Platforms = []Platform{"linux/amd64"}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if pull changes", name: "diff if pull changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Pull = true a.Pull = true
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if builder changes", name: "diff if builder changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Builder = &BuilderConfig{Name: "foo"} a.Builder = &BuilderConfig{Name: "foo"}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if tags change", name: "diff if tags change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Tags = []string{"foo"} a.Tags = []string{"foo"}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if exports change", name: "diff if exports change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Exports = []Export{{Raw: "foo"}} a.Exports = []Export{{Raw: "foo"}}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if target changes", name: "diff if target changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Target = "foo" a.Target = "foo"
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if pulling", name: "diff if pulling",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Pull = true a.Pull = true
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if noCache changes", name: "diff if noCache changes",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.NoCache = true a.NoCache = true
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if labels change", name: "diff if labels change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Labels = map[string]string{"foo": "bar"} a.Labels = map[string]string{"foo": "bar"}
return a return a
}, },
wantChanges: true, wantChanges: true,
}, },
{ {
name: "diff if secrets change", name: "diff if secrets change",
olds: func(*testing.T, ImageState) ImageState { return baseState }, state: func(*testing.T, ImageState) ImageState { return baseState },
news: func(_ *testing.T, a ImageArgs) ImageArgs { inputs: func(_ *testing.T, a ImageArgs) ImageArgs {
a.Secrets = map[string]string{"foo": "bar"} a.Secrets = map[string]string{"foo": "bar"}
return a return a
}, },
@@ -762,13 +751,13 @@ func TestImageDiff(t *testing.T) {
}, },
{ {
name: "diff if local export doesn't exist", name: "diff if local export doesn't exist",
olds: func(t *testing.T, state ImageState) ImageState { state: func(t *testing.T, state ImageState) ImageState {
state.Exports = []Export{ state.Exports = []Export{
{Local: &ExportLocal{Dest: "not-real"}}, {Local: &ExportLocal{Dest: "not-real"}},
} }
return state return state
}, },
news: func(_ *testing.T, args ImageArgs) ImageArgs { inputs: func(_ *testing.T, args ImageArgs) ImageArgs {
args.Exports = []Export{ args.Exports = []Export{
{Local: &ExportLocal{Dest: "not-real"}}, {Local: &ExportLocal{Dest: "not-real"}},
} }
@@ -778,13 +767,13 @@ func TestImageDiff(t *testing.T) {
}, },
{ {
name: "diff if tar export doesn't exist", name: "diff if tar export doesn't exist",
olds: func(t *testing.T, state ImageState) ImageState { state: func(t *testing.T, state ImageState) ImageState {
state.Exports = []Export{ state.Exports = []Export{
{Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}}, {Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}},
} }
return state return state
}, },
news: func(_ *testing.T, args ImageArgs) ImageArgs { inputs: func(_ *testing.T, args ImageArgs) ImageArgs {
args.Exports = []Export{ args.Exports = []Export{
{Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}}, {Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}},
} }
@@ -794,12 +783,12 @@ func TestImageDiff(t *testing.T) {
}, },
} }
s := newServer(nil) s := newServer(t.Context(), t, 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 {
@@ -808,9 +797,9 @@ func TestImageDiff(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
resp, err := s.Diff(provider.DiffRequest{ resp, err := s.Diff(provider.DiffRequest{
Urn: _fakeURN, Urn: _fakeURN,
Olds: encode(t, tt.olds(t, baseState)), State: encode(t, tt.state(t, baseState)),
News: encode(t, tt.news(t, baseArgs)), Inputs: encode(t, tt.inputs(t, baseArgs)),
}) })
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, tt.wantChanges, resp.HasChanges, resp.DetailedDiff) assert.Equal(t, tt.wantChanges, resp.HasChanges, resp.DetailedDiff)

View File

@@ -28,7 +28,6 @@ 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/common/resource"
) )
var ( var (
@@ -47,7 +46,10 @@ var (
var _indexExamples string var _indexExamples string
// Index is an OCI index or manifest list on a remote registry. // Index is an OCI index or manifest list on a remote registry.
type Index struct{} type Index struct {
clientF clientF
config *Config
}
// IndexArgs instantiate an Index. // IndexArgs instantiate an Index.
type IndexArgs struct { type IndexArgs struct {
@@ -64,6 +66,14 @@ func (i IndexArgs) isPushed() bool {
return *i.Push return *i.Push
} }
// GetRegistries returns the index's registry.
func (i IndexArgs) GetRegistries() []Registry {
if i.Registry == nil {
return nil
}
return []Registry{*i.Registry}
}
// IndexState captures the state of an Index. // IndexState captures the state of an Index.
type IndexState struct { type IndexState struct {
IndexArgs IndexArgs
@@ -132,66 +142,82 @@ func (i *IndexState) Annotate(a infer.Annotator) {
// Create is a passthrough to Update. // Create is a passthrough to Update.
func (i *Index) Create( func (i *Index) Create(
ctx context.Context, ctx context.Context,
name string, req infer.CreateRequest[IndexArgs],
input IndexArgs, ) (infer.CreateResponse[IndexState], error) {
preview bool, resp, err := i.Update(ctx,
) (string, IndexState, error) { infer.UpdateRequest[IndexArgs, IndexState]{
state, err := i.Update(ctx, name, IndexState{}, input, preview) ID: req.Name,
return name, state, err State: IndexState{},
Inputs: req.Inputs,
DryRun: req.DryRun,
},
)
return infer.CreateResponse[IndexState]{ID: req.Name, Output: resp.Output}, err
} }
// Update performs `buildx imagetools create` to create a new OCI index / // Update performs `buildx imagetools create` to create a new OCI index /
// manifest list. // manifest list.
func (i *Index) Update( func (i *Index) Update(
ctx context.Context, ctx context.Context,
name string, req infer.UpdateRequest[IndexArgs, IndexState],
state IndexState, ) (infer.UpdateResponse[IndexState], error) {
input IndexArgs, state, input := req.State, req.Inputs
preview bool,
) (IndexState, error) {
state.IndexArgs = input state.IndexArgs = input
state.Ref = input.Tag state.Ref = input.Tag
cli, err := i.client(ctx, state, input) cli, err := i.client(ctx, input)
if err != nil { if err != nil {
return state, err return infer.UpdateResponse[IndexState]{Output: state}, err
} }
if preview { if req.DryRun {
return state, nil return infer.UpdateResponse[IndexState]{Output: state}, nil
} }
provider.GetLogger(ctx).Debugf("creating index with tag %s and sources %s", input.Tag, input.Sources) provider.GetLogger(ctx).
Debugf("creating index with tag %s and sources %s", input.Tag, input.Sources)
err = cli.ManifestCreate(ctx, input.isPushed(), input.Tag, input.Sources...) err = cli.ManifestCreate(ctx, input.isPushed(), input.Tag, input.Sources...)
if err != nil { if err != nil {
return state, fmt.Errorf("creating: %w", err) return infer.UpdateResponse[IndexState]{Output: state}, fmt.Errorf("creating: %w", err)
} }
_, _, state, err = i.Read(ctx, name, input, state) // Read remote manifest information, if it exists.
live, err := i.Read(ctx,
infer.ReadRequest[IndexArgs, IndexState]{ID: req.ID, Inputs: input, State: state},
)
if err != nil { if err != nil {
return state, fmt.Errorf("reading: %w", err) return infer.UpdateResponse[IndexState]{Output: state}, fmt.Errorf("reading: %w", err)
} }
return state, nil return infer.UpdateResponse[IndexState]{Output: live.State}, nil
} }
func (i *Index) Read( func (i *Index) Read(
ctx context.Context, ctx context.Context,
name string, req infer.ReadRequest[IndexArgs, IndexState],
input IndexArgs, ) (infer.ReadResponse[IndexArgs, IndexState], error) {
state IndexState, state, input := req.State, req.Inputs
) (string, IndexArgs, IndexState, error) {
state.IndexArgs = input state.IndexArgs = input
state.Ref = input.Tag state.Ref = input.Tag
if !input.isPushed() { if !input.isPushed() {
provider.GetLogger(ctx).Debug("skipping read because index was not pushed") provider.GetLogger(ctx).Debug("skipping read because index was not pushed")
return name, input, state, nil // Nothing to read. return infer.ReadResponse[IndexArgs, IndexState]{
ID: req.ID,
Inputs: input,
State: state,
}, nil // Nothing to read.
} }
cli, err := i.client(ctx, state, input) cli, err := i.client(ctx, input)
if err != nil { if err != nil {
return name, input, state, err return infer.ReadResponse[IndexArgs, IndexState]{
ID: req.ID,
Inputs: input,
State: state,
}, err
} }
provider.GetLogger(ctx).Debug("reading index with tag " + input.Tag) provider.GetLogger(ctx).Debug("reading index with tag " + input.Tag)
@@ -199,21 +225,29 @@ func (i *Index) Read(
digest, err := cli.ManifestInspect(ctx, input.Tag) digest, err := cli.ManifestInspect(ctx, input.Tag)
if errors.Is(err, errs.ErrNotFound) { if errors.Is(err, errs.ErrNotFound) {
// A remote tag was expected but isn't there -- delete the resource. // A remote tag was expected but isn't there -- delete the resource.
return "", input, state, nil return infer.ReadResponse[IndexArgs, IndexState]{ID: "", Inputs: input, State: state}, nil
} }
if errors.Is(err, errs.ErrHTTPUnauthorized) { if errors.Is(err, errs.ErrHTTPUnauthorized) {
provider.GetLogger(ctx).Warning("invalid credentials, skipping") provider.GetLogger(ctx).Warning("invalid credentials, skipping")
return name, input, state, nil return infer.ReadResponse[IndexArgs, IndexState]{
ID: req.ID,
Inputs: input,
State: state,
}, nil
} }
if err != nil { if err != nil {
return name, input, state, err return infer.ReadResponse[IndexArgs, IndexState]{
ID: req.ID,
Inputs: input,
State: state,
}, err
} }
if ref, ok := addDigest(input.Tag, digest); ok { if ref, ok := addDigest(input.Tag, digest); ok {
state.Ref = ref state.Ref = ref
} }
return name, input, state, nil return infer.ReadResponse[IndexArgs, IndexState]{ID: req.ID, Inputs: input, State: state}, nil
} }
// Check confirms the Index's tag and source refs are all valid. This doesn't // Check confirms the Index's tag and source refs are all valid. This doesn't
@@ -222,13 +256,11 @@ func (i *Index) Read(
// cases for now. // cases for now.
func (i *Index) Check( func (i *Index) Check(
ctx context.Context, ctx context.Context,
_ string, req infer.CheckRequest,
_ resource.PropertyMap, ) (infer.CheckResponse[IndexArgs], error) {
news resource.PropertyMap, args, failures, err := infer.DefaultCheck[IndexArgs](ctx, req.NewInputs)
) (IndexArgs, []provider.CheckFailure, error) {
args, failures, err := infer.DefaultCheck[IndexArgs](ctx, news)
if err != nil { if err != nil {
return args, failures, err return infer.CheckResponse[IndexArgs]{Failures: failures, Inputs: args}, err
} }
if _, err := normalizeReference(args.Tag); args.Tag != "" && err != nil { if _, err := normalizeReference(args.Tag); args.Tag != "" && err != nil {
@@ -253,27 +285,31 @@ func (i *Index) Check(
} }
} }
return args, failures, nil return infer.CheckResponse[IndexArgs]{Failures: failures, Inputs: args}, nil
} }
// Delete attempts to delete the remote manifest. // Delete attempts to delete the remote manifest.
func (i *Index) Delete(ctx context.Context, _ string, state IndexState) error { func (i *Index) Delete(
ctx context.Context,
req infer.DeleteRequest[IndexState],
) (infer.DeleteResponse, error) {
state := req.State
if !state.isPushed() { if !state.isPushed() {
return nil // Nothing to delete. return infer.DeleteResponse{}, nil // Nothing to delete.
} }
cli, err := i.client(ctx, state, state.IndexArgs) cli, err := i.client(ctx, state.IndexArgs)
if err != nil { if err != nil {
return err return infer.DeleteResponse{}, err
} }
err = cli.ManifestDelete(ctx, state.Ref) err = cli.ManifestDelete(ctx, state.Ref)
// TODO: Upstream buildx swallows the error types we'd like to test for // TODO: Upstream buildx swallows the error types we'd like to test for
// here. // here.
if err != nil && strings.Contains(err.Error(), "No such manifest:") { if err != nil && strings.Contains(err.Error(), "No such manifest:") {
return nil return infer.DeleteResponse{}, nil
} }
return err return infer.DeleteResponse{}, err
} }
// Diff returns a diff of proposed changes against current state. Ideally we // Diff returns a diff of proposed changes against current state. Ideally we
@@ -282,10 +318,10 @@ func (i *Index) Delete(ctx context.Context, _ string, state IndexState) error {
// change all the time due to short-lived AWS credentials). // change all the time due to short-lived AWS credentials).
func (i *Index) Diff( func (i *Index) Diff(
_ context.Context, _ context.Context,
_ string, req infer.DiffRequest[IndexArgs, IndexState],
olds IndexState,
news IndexArgs,
) (provider.DiffResponse, error) { ) (provider.DiffResponse, error) {
olds, news := req.State, req.Inputs
diff := map[string]provider.PropertyDiff{} diff := map[string]provider.PropertyDiff{}
update := provider.PropertyDiff{Kind: provider.Update} update := provider.PropertyDiff{Kind: provider.Update}
replace := provider.PropertyDiff{Kind: provider.UpdateReplace} replace := provider.PropertyDiff{Kind: provider.UpdateReplace}
@@ -323,23 +359,7 @@ func (i *Index) Diff(
// any host-level credentials. // any host-level credentials.
func (i *Index) client( func (i *Index) client(
ctx context.Context, ctx context.Context,
_ IndexState,
args IndexArgs, args IndexArgs,
) (Client, error) { ) (Client, error) {
cfg := infer.GetConfig[Config](ctx) return i.clientF(ctx, i.config.getHost(), i.config, args)
if cli, ok := ctx.Value(_mockClientKey).(Client); ok {
return cli, nil
}
// We prefer auth from args, the provider, and state in that order. We
// build a slice in reverse order because wrap() will overwrite earlier
// entries with later ones.
auths := []Registry{}
auths = append(auths, cfg.Registries...)
if args.Registry != nil {
auths = append(auths, *args.Registry)
}
return wrap(cfg.host, auths...)
} }

View File

@@ -27,34 +27,35 @@ 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) {
t.Parallel() t.Parallel()
realClient := func(t *testing.T) Client { return nil } realClient := func(t *testing.T) clientF { return RealClientF }
tests := []struct { tests := []struct {
name string name string
skip bool skip bool
op func(t *testing.T) integration.Operation op func(t *testing.T) integration.Operation
client func(t *testing.T) Client client func(t *testing.T) clientF
}{ }{
{ {
name: "not pushed", name: "not pushed",
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,59 +65,51 @@ 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"),
),
}),
}), }),
}, }),
} }
}, },
}, },
{ {
name: "expired credentials", name: "expired credentials",
client: func(t *testing.T) Client { client: func(t *testing.T) clientF {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
c := NewMockClient(ctrl) c := NewMockClient(ctrl)
c.EXPECT().ManifestCreate(gomock.Any(), true, gomock.Any(), gomock.Any()) c.EXPECT().ManifestCreate(gomock.Any(), true, gomock.Any(), gomock.Any())
c.EXPECT().ManifestInspect(gomock.Any(), gomock.Any()).Return("", errs.ErrHTTPUnauthorized) c.EXPECT().ManifestInspect(gomock.Any(), gomock.Any()).Return("", errs.ErrHTTPUnauthorized)
c.EXPECT().ManifestDelete(gomock.Any(), gomock.Any()).Return(nil) c.EXPECT().ManifestDelete(gomock.Any(), gomock.Any()).Return(nil)
return c return mockClientF(c)
}, },
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"),
),
}),
}), }),
}, }),
} }
}, },
}, },
@@ -132,7 +125,7 @@ func TestIndexLifecycle(t *testing.T) {
Resource: "docker-build:index:Index", Resource: "docker-build:index:Index",
Create: tt.op(t), Create: tt.op(t),
} }
s := newServer(tt.client(t)) s := newServer(t.Context(), t, tt.client(t))
err := s.Configure(provider.ConfigureRequest{}) err := s.Configure(provider.ConfigureRequest{})
require.NoError(t, err) require.NoError(t, err)
@@ -149,22 +142,22 @@ func TestIndexDiff(t *testing.T) {
baseState := IndexState{IndexArgs: baseArgs} baseState := IndexState{IndexArgs: baseArgs}
tests := []struct { tests := []struct {
name string name string
olds func(*testing.T, IndexState) IndexState state func(*testing.T, IndexState) IndexState
news func(*testing.T, IndexArgs) IndexArgs inputs func(*testing.T, IndexArgs) IndexArgs
wantChanges bool wantChanges bool
}{ }{
{ {
name: "no diff if no changes", name: "no diff if no changes",
olds: func(*testing.T, IndexState) IndexState { return baseState }, state: func(*testing.T, IndexState) IndexState { return baseState },
news: func(*testing.T, IndexArgs) IndexArgs { return baseArgs }, inputs: func(*testing.T, IndexArgs) IndexArgs { return baseArgs },
wantChanges: false, wantChanges: false,
}, },
{ {
name: "diff if tag changes", name: "diff if tag changes",
olds: func(*testing.T, IndexState) IndexState { return baseState }, state: func(*testing.T, IndexState) IndexState { return baseState },
news: func(t *testing.T, a IndexArgs) IndexArgs { inputs: func(t *testing.T, a IndexArgs) IndexArgs {
a.Tag = "new-tag" a.Tag = "new-tag"
return a return a
}, },
@@ -172,7 +165,7 @@ func TestIndexDiff(t *testing.T) {
}, },
{ {
name: "no diff if registry password changes", name: "no diff if registry password changes",
olds: func(_ *testing.T, s IndexState) IndexState { state: func(_ *testing.T, s IndexState) IndexState {
s.Registry = &Registry{ s.Registry = &Registry{
Address: "foo", Address: "foo",
Username: "foo", Username: "foo",
@@ -180,7 +173,7 @@ func TestIndexDiff(t *testing.T) {
} }
return s return s
}, },
news: func(_ *testing.T, a IndexArgs) IndexArgs { inputs: func(_ *testing.T, a IndexArgs) IndexArgs {
a.Registry = &Registry{ a.Registry = &Registry{
Address: "foo", Address: "foo",
Username: "foo", Username: "foo",
@@ -191,9 +184,9 @@ func TestIndexDiff(t *testing.T) {
wantChanges: false, wantChanges: false,
}, },
{ {
name: "diff if registry added", name: "diff if registry added",
olds: func(*testing.T, IndexState) IndexState { return baseState }, state: func(*testing.T, IndexState) IndexState { return baseState },
news: func(_ *testing.T, a IndexArgs) IndexArgs { inputs: func(_ *testing.T, a IndexArgs) IndexArgs {
a.Registry = &Registry{Address: "foo.com", Username: "foo", Password: "foo"} a.Registry = &Registry{Address: "foo.com", Username: "foo", Password: "foo"}
return a return a
}, },
@@ -201,7 +194,7 @@ func TestIndexDiff(t *testing.T) {
}, },
{ {
name: "diff if registry user changes", name: "diff if registry user changes",
olds: func(_ *testing.T, s IndexState) IndexState { state: func(_ *testing.T, s IndexState) IndexState {
s.Registry = &Registry{ s.Registry = &Registry{
Address: "foo", Address: "foo",
Username: "foo", Username: "foo",
@@ -209,7 +202,7 @@ func TestIndexDiff(t *testing.T) {
} }
return s return s
}, },
news: func(_ *testing.T, a IndexArgs) IndexArgs { inputs: func(_ *testing.T, a IndexArgs) IndexArgs {
a.Registry = &Registry{ a.Registry = &Registry{
Address: "DIFFERENT USER", Address: "DIFFERENT USER",
Username: "foo", Username: "foo",
@@ -221,21 +214,21 @@ func TestIndexDiff(t *testing.T) {
}, },
} }
s := newServer(nil) s := newServer(t.Context(), t, 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 {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
resp, err := s.Diff(provider.DiffRequest{ resp, err := s.Diff(provider.DiffRequest{
Urn: urn, Urn: urn,
Olds: encode(t, tt.olds(t, baseState)), State: encode(t, tt.state(t, baseState)),
News: encode(t, tt.news(t, baseArgs)), Inputs: encode(t, tt.inputs(t, baseArgs)),
}) })
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, tt.wantChanges, resp.HasChanges, resp.DetailedDiff) assert.Equal(t, tt.wantChanges, resp.HasChanges, resp.DetailedDiff)

View File

@@ -45,9 +45,6 @@ type Config struct {
host *host host *host
} }
// _mockClientKey is used by tests to inject a mock Docker client.
var _mockClientKey any = "mock-client"
// Annotate provides user-facing descriptions and defaults for Config's fields. // Annotate provides user-facing descriptions and defaults for Config's fields.
func (c *Config) Annotate(a infer.Annotator) { func (c *Config) Annotate(a infer.Annotator) {
a.Describe(&c.Host, "The build daemon's address.") a.Describe(&c.Host, "The build daemon's address.")
@@ -64,8 +61,23 @@ func (c *Config) Configure(ctx context.Context) error {
return nil return nil
} }
// GetRegistries returns the config's registries, if any.
func (c Config) GetRegistries() []Registry {
return c.Registries
}
// getHost returns the config's host, or nil if the config is also nil.
func (c *Config) getHost() *host {
if c == nil {
return nil
}
return c.host
}
// NewBuildxProvider returns a new buildx provider. // NewBuildxProvider returns a new buildx provider.
func NewBuildxProvider() provider.Provider { func NewBuildxProvider(clientF clientF) provider.Provider {
config := &Config{}
prov := infer.Provider( prov := infer.Provider(
infer.Options{ infer.Options{
Metadata: pschema.Metadata{ Metadata: pschema.Metadata{
@@ -113,41 +125,22 @@ func NewBuildxProvider() provider.Provider {
}, },
}, },
Resources: []infer.InferredResource{ Resources: []infer.InferredResource{
infer.Resource[*Image](), infer.Resource(&Image{clientF: clientF, config: config}),
infer.Resource[*Index](), infer.Resource(&Index{clientF: clientF, config: config}),
}, },
ModuleMap: map[tokens.ModuleName]tokens.ModuleName{ ModuleMap: map[tokens.ModuleName]tokens.ModuleName{
"internal": "index", "internal": "index",
}, },
Config: infer.Config[*Config](), Config: infer.Config(config),
}, },
) )
prov.DiffConfig = diffConfigIgnoreInternal(prov.DiffConfig)
return prov return prov
} }
// TODO(pulumi/pulumi-docker-build#404): Remove this function once the bug is fixed in either
// upstream pu/pu or pulumi-go-provider.
// diffConfigInternalIgnore is a custom DiffConfig implementation for the buildx provider. This is required to
// circumvent the bug identified in https://github.com/pulumi/pulumi-docker-build/issues/404.
// Since `__internal` is currently populated in new inputs, but stripped in old state, we need to
// ignore this field in the diff. There is no easy way to override DiffConfig to compare inputs only.
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")
return diffConfig(ctx, req)
}
}
// Schema returns our package specification. // Schema returns our package specification.
func Schema(ctx context.Context, version string) schema.PackageSpec { func Schema(ctx context.Context, version string) schema.PackageSpec {
p := NewBuildxProvider() p := NewBuildxProvider(nil)
spec, err := provider.GetSchema(ctx, "docker-build", version, p) spec, err := provider.GetSchema(ctx, "docker-build", version, p)
contract.AssertNoErrorf(err, "missing schema") contract.AssertNoErrorf(err, "missing schema")
return spec return spec

View File

@@ -20,18 +20,18 @@ import (
"github.com/blang/semver" "github.com/blang/semver"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
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-go-provider/integration" "github.com/pulumi/pulumi-go-provider/integration"
mwcontext "github.com/pulumi/pulumi-go-provider/middleware/context"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens" "github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
) )
func TestConfigure(t *testing.T) { func TestConfigure(t *testing.T) {
t.Parallel() t.Parallel()
s := newServer(nil) s := newServer(t.Context(), t, nil)
err := s.Configure( err := s.Configure(
provider.ConfigureRequest{}, provider.ConfigureRequest{},
@@ -60,7 +60,7 @@ func TestAnnotate(t *testing.T) {
func TestSchema(t *testing.T) { func TestSchema(t *testing.T) {
t.Parallel() t.Parallel()
s := newServer(nil) s := newServer(t.Context(), t, nil)
_, err := s.GetSchema(provider.GetSchemaRequest{Version: 0}) _, err := s.GetSchema(provider.GetSchemaRequest{Version: 0})
assert.NoError(t, err) assert.NoError(t, err)
@@ -68,21 +68,27 @@ func TestSchema(t *testing.T) {
type annotator struct{} type annotator struct{}
func (annotator) Deprecate(_ any, _ string) {}
func (annotator) Describe(_ any, _ string) {} func (annotator) Describe(_ any, _ string) {}
func (annotator) SetDefault(_, _ any, _ ...string) {} func (annotator) SetDefault(_, _ any, _ ...string) {}
func (annotator) SetToken(tokens.ModuleName, tokens.TypeName) {} func (annotator) SetToken(tokens.ModuleName, tokens.TypeName) {}
func (annotator) AddAlias(tokens.ModuleName, tokens.TypeName) {} func (annotator) AddAlias(tokens.ModuleName, tokens.TypeName) {}
func (annotator) SetResourceDeprecationMessage(_ string) {} func (annotator) SetResourceDeprecationMessage(_ string) {}
func newServer(client Client) integration.Server { func newServer(ctx context.Context, t *testing.T, clientF clientF) integration.Server {
p := NewBuildxProvider() t.Helper()
// Inject a mock client if provided. if clientF == nil {
if client != nil { clientF = RealClientF
p = mwcontext.Wrap(p, func(ctx context.Context) context.Context {
return context.WithValue(ctx, _mockClientKey, client)
})
} }
return integration.NewServer("docker-build", semver.Version{Major: 0}, p) p := NewBuildxProvider(clientF)
s, err := integration.NewServer(
ctx,
"docker-build", semver.Version{Major: 0},
integration.WithProvider(p),
)
require.NoError(t, err)
return s
} }

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(internal.RealClientF))(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()

View File

@@ -4,7 +4,7 @@ go 1.24.1
require ( require (
github.com/blang/semver v3.5.1+incompatible github.com/blang/semver v3.5.1+incompatible
github.com/pulumi/pulumi/sdk/v3 v3.165.0 github.com/pulumi/pulumi/sdk/v3 v3.169.0
) )
require ( require (
@@ -83,14 +83,14 @@ require (
go.opentelemetry.io/otel v1.35.0 // indirect go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/sdk v1.35.0 // indirect go.opentelemetry.io/otel/sdk v1.35.0 // indirect
go.uber.org/atomic v1.11.0 // indirect go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.37.0 // indirect golang.org/x/crypto v0.38.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/mod v0.24.0 // indirect golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect golang.org/x/net v0.40.0 // indirect
golang.org/x/sync v0.13.0 // indirect golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.32.0 // indirect golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.31.0 // indirect golang.org/x/term v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect golang.org/x/text v0.25.0 // indirect
golang.org/x/tools v0.32.0 // indirect golang.org/x/tools v0.32.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
google.golang.org/grpc v1.71.1 // indirect google.golang.org/grpc v1.71.1 // indirect

View File

@@ -162,8 +162,8 @@ github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 h1:vkHw5I/plNdTr435
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231/go.mod h1:murToZ2N9hNJzewjHBgfFdXhZKjY3z5cYC1VXk+lbFE= github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231/go.mod h1:murToZ2N9hNJzewjHBgfFdXhZKjY3z5cYC1VXk+lbFE=
github.com/pulumi/esc v0.13.0 h1:O2MPR2koScaQ2fXwyer8Q3Dd7z+DCnaDfsgNl5mVNMk= github.com/pulumi/esc v0.13.0 h1:O2MPR2koScaQ2fXwyer8Q3Dd7z+DCnaDfsgNl5mVNMk=
github.com/pulumi/esc v0.13.0/go.mod h1:IIQo6W6Uzajt6f1RW4QvNxIRDlbK3TNQysnrwBHNo3U= github.com/pulumi/esc v0.13.0/go.mod h1:IIQo6W6Uzajt6f1RW4QvNxIRDlbK3TNQysnrwBHNo3U=
github.com/pulumi/pulumi/sdk/v3 v3.165.0 h1:cglplKZOJDpqH8wa/2J250G9az/sE9eKp9fS2bC+vi8= github.com/pulumi/pulumi/sdk/v3 v3.169.0 h1:bgz1fp2rl28khSXgF4FaRQiB9wh3lSKWtzUOGalf+x4=
github.com/pulumi/pulumi/sdk/v3 v3.165.0/go.mod h1:GAaHrdv3kWJHbzkFFFflGbTBQXUYu6SF1ZCo+O9jo44= github.com/pulumi/pulumi/sdk/v3 v3.169.0/go.mod h1:Qhe4dOjqedyLr47kGGnG6ULIbzaPTlmjAvPqNQ1Ollo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@@ -228,8 +228,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
@@ -244,13 +244,13 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -266,16 +266,16 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

View File

@@ -3,7 +3,7 @@
# *** Do not edit by hand unless you're certain you know what you are doing! *** # *** Do not edit by hand unless you're certain you know what you are doing! ***
import builtins import builtins
import builtins import pulumi
from enum import Enum from enum import Enum
__all__ = [ __all__ = [
@@ -14,6 +14,7 @@ __all__ = [
] ]
@pulumi.type_token("docker-build:index:CacheMode")
class CacheMode(builtins.str, Enum): class CacheMode(builtins.str, Enum):
MIN = "min" MIN = "min"
""" """
@@ -25,6 +26,7 @@ class CacheMode(builtins.str, Enum):
""" """
@pulumi.type_token("docker-build:index:CompressionType")
class CompressionType(builtins.str, Enum): class CompressionType(builtins.str, Enum):
GZIP = "gzip" GZIP = "gzip"
""" """
@@ -40,6 +42,7 @@ class CompressionType(builtins.str, Enum):
""" """
@pulumi.type_token("docker-build:index:NetworkMode")
class NetworkMode(builtins.str, Enum): class NetworkMode(builtins.str, Enum):
DEFAULT = "default" DEFAULT = "default"
""" """
@@ -55,6 +58,7 @@ class NetworkMode(builtins.str, Enum):
""" """
@pulumi.type_token("docker-build:index:Platform")
class Platform(builtins.str, Enum): class Platform(builtins.str, Enum):
DARWIN_386 = "darwin/386" DARWIN_386 = "darwin/386"
DARWIN_AMD64 = "darwin/amd64" DARWIN_AMD64 = "darwin/amd64"

View File

@@ -583,10 +583,8 @@ class ImageArgs:
pulumi.set(self, "target", value) pulumi.set(self, "target", value)
@pulumi.type_token("docker-build:index:Image")
class Image(pulumi.CustomResource): class Image(pulumi.CustomResource):
pulumi_type = "docker-build:index:Image"
@overload @overload
def __init__(__self__, def __init__(__self__,
resource_name: str, resource_name: str,

View File

@@ -99,10 +99,8 @@ class IndexArgs:
pulumi.set(self, "registry", value) pulumi.set(self, "registry", value)
@pulumi.type_token("docker-build:index:Index")
class Index(pulumi.CustomResource): class Index(pulumi.CustomResource):
pulumi_type = "docker-build:index:Index"
@overload @overload
def __init__(__self__, def __init__(__self__,
resource_name: str, resource_name: str,

View File

@@ -56,10 +56,8 @@ class ProviderArgs:
pulumi.set(self, "registries", value) pulumi.set(self, "registries", value)
@pulumi.type_token("pulumi:providers:docker-build")
class Provider(pulumi.ProviderResource): class Provider(pulumi.ProviderResource):
pulumi_type = "pulumi:providers:docker-build"
@overload @overload
def __init__(__self__, def __init__(__self__,
resource_name: str, resource_name: str,

View File

@@ -1,7 +1,7 @@
[project] [project]
name = "pulumi_docker_build" name = "pulumi_docker_build"
description = "A Pulumi provider for building modern Docker images with buildx and BuildKit." description = "A Pulumi provider for building modern Docker images with buildx and BuildKit."
dependencies = ["parver>=0.2.1", "pulumi>=3.142.0,<4.0.0", "semver>=2.8.1", "typing-extensions>=4.11,<5; python_version < \"3.11\""] dependencies = ["parver>=0.2.1", "pulumi>=3.165.0,<4.0.0", "semver>=2.8.1", "typing-extensions>=4.11,<5; python_version < \"3.11\""]
keywords = ["docker", "buildkit", "buildx", "kind/native"] keywords = ["docker", "buildkit", "buildx", "kind/native"]
readme = "README.md" readme = "README.md"
requires-python = ">=3.9" requires-python = ">=3.9"

View File

@@ -6,7 +6,7 @@ package tools
import ( import (
_ "github.com/golangci/golangci-lint/cmd/golangci-lint" _ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet" _ "github.com/pulumi/pulumi-dotnet/pulumi-language-dotnet/v3"
_ "github.com/pulumi/pulumi-java/pkg/cmd/pulumi-language-java" _ "github.com/pulumi/pulumi-java/pkg/cmd/pulumi-language-java"
_ "github.com/pulumi/pulumi-yaml/cmd/pulumi-converter-yaml" _ "github.com/pulumi/pulumi-yaml/cmd/pulumi-converter-yaml"
_ "github.com/pulumi/pulumi-yaml/cmd/pulumi-language-yaml" _ "github.com/pulumi/pulumi-yaml/cmd/pulumi-language-yaml"