Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
Fix cacheFrom and cacheTo implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
benesch committed Jan 9, 2023
1 parent 1959c4f commit 8f29b91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
18 changes: 9 additions & 9 deletions cmd/pulumi-resource-docker-buildkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,13 @@ func (k *dockerBuildkitProvider) dockerBuild(
platforms = append(platforms, v.StringValue())
}

cacheFrom := name
if !inputs["cacheFrom"].IsNull() {
index = inputs["cacheFrom"]
}

cacheTo := "type=inline"
if !inputs["cacheTo"].IsNull() {
index = inputs["cacheTo"]
var cacheFrom string
if inputs["cacheFrom"].IsNull() {
cacheFrom = name
} else {
cacheFrom = inputs["cacheFrom"].StringValue()
}
cacheTo := inputs["cacheTo"].StringValue()

args := []string{
"buildx", "build",
Expand Down Expand Up @@ -335,12 +333,14 @@ func (k *dockerBuildkitProvider) dockerBuild(
"contextDigest": contextDigest,
"repoDigest": repoDigest,
"registryServer": registry["server"].StringValue(),
"cacheFrom": cacheFrom,
"cacheTo": cacheTo,
}
if buildArgs != nil {
outputs["args"] = buildArgs
}
if !inputs["cacheFrom"].IsNull() {
outputs["cacheFrom"] = inputs["cacheFrom"].StringValue()
}
return plugin.MarshalProperties(
resource.NewPropertyMapFromMap(outputs),
plugin.MarshalOptions{KeepUnknowns: true, SkipNulls: true},
Expand Down
9 changes: 5 additions & 4 deletions cmd/pulumi-sdkgen-docker-buildkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func run(version string) error {
TypeSpec: schema.TypeSpec{Type: "string"},
},
"cacheFrom": {
Description: "Value for --cache-from when executing docker buildx, default to image name",
Description: "An external cache source to use for the build. Defaults to the name of the image.",
TypeSpec: schema.TypeSpec{Type: "string"},
},
"cacheTo": {
Description: "Value for --cache-to when executing docker buildx, default to type=inline",
Description: "An external cache destination to export the build cache to.",
TypeSpec: schema.TypeSpec{Type: "string"},
},
},
Expand Down Expand Up @@ -137,12 +137,13 @@ func run(version string) error {
Default: "",
},
"cacheFrom": {
Description: "Value for --cache-from when executing docker buildx, default to image name",
Description: "An external cache source to use for the build. Defaults to the name of the image.",
TypeSpec: schema.TypeSpec{Type: "string"},
},
"cacheTo": {
Description: "Value for --cache-to when executing docker buildx, default to type=inline",
Description: "An external cache destination to export the build cache to.",
TypeSpec: schema.TypeSpec{Type: "string"},
Default: "type=inline",
},
"args": {
Description: "The build arguments.",
Expand Down

0 comments on commit 8f29b91

Please sign in to comment.