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

Commit 8f29b91

Browse files
committed
Fix cacheFrom and cacheTo implementation
1 parent 1959c4f commit 8f29b91

File tree

2 files changed

+14
-13
lines changed
  • cmd
    • pulumi-resource-docker-buildkit
    • pulumi-sdkgen-docker-buildkit

2 files changed

+14
-13
lines changed

cmd/pulumi-resource-docker-buildkit/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,13 @@ func (k *dockerBuildkitProvider) dockerBuild(
275275
platforms = append(platforms, v.StringValue())
276276
}
277277

278-
cacheFrom := name
279-
if !inputs["cacheFrom"].IsNull() {
280-
index = inputs["cacheFrom"]
281-
}
282-
283-
cacheTo := "type=inline"
284-
if !inputs["cacheTo"].IsNull() {
285-
index = inputs["cacheTo"]
278+
var cacheFrom string
279+
if inputs["cacheFrom"].IsNull() {
280+
cacheFrom = name
281+
} else {
282+
cacheFrom = inputs["cacheFrom"].StringValue()
286283
}
284+
cacheTo := inputs["cacheTo"].StringValue()
287285

288286
args := []string{
289287
"buildx", "build",
@@ -335,12 +333,14 @@ func (k *dockerBuildkitProvider) dockerBuild(
335333
"contextDigest": contextDigest,
336334
"repoDigest": repoDigest,
337335
"registryServer": registry["server"].StringValue(),
338-
"cacheFrom": cacheFrom,
339336
"cacheTo": cacheTo,
340337
}
341338
if buildArgs != nil {
342339
outputs["args"] = buildArgs
343340
}
341+
if !inputs["cacheFrom"].IsNull() {
342+
outputs["cacheFrom"] = inputs["cacheFrom"].StringValue()
343+
}
344344
return plugin.MarshalProperties(
345345
resource.NewPropertyMapFromMap(outputs),
346346
plugin.MarshalOptions{KeepUnknowns: true, SkipNulls: true},

cmd/pulumi-sdkgen-docker-buildkit/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ func run(version string) error {
8989
TypeSpec: schema.TypeSpec{Type: "string"},
9090
},
9191
"cacheFrom": {
92-
Description: "Value for --cache-from when executing docker buildx, default to image name",
92+
Description: "An external cache source to use for the build. Defaults to the name of the image.",
9393
TypeSpec: schema.TypeSpec{Type: "string"},
9494
},
9595
"cacheTo": {
96-
Description: "Value for --cache-to when executing docker buildx, default to type=inline",
96+
Description: "An external cache destination to export the build cache to.",
9797
TypeSpec: schema.TypeSpec{Type: "string"},
9898
},
9999
},
@@ -137,12 +137,13 @@ func run(version string) error {
137137
Default: "",
138138
},
139139
"cacheFrom": {
140-
Description: "Value for --cache-from when executing docker buildx, default to image name",
140+
Description: "An external cache source to use for the build. Defaults to the name of the image.",
141141
TypeSpec: schema.TypeSpec{Type: "string"},
142142
},
143143
"cacheTo": {
144-
Description: "Value for --cache-to when executing docker buildx, default to type=inline",
144+
Description: "An external cache destination to export the build cache to.",
145145
TypeSpec: schema.TypeSpec{Type: "string"},
146+
Default: "type=inline",
146147
},
147148
"args": {
148149
Description: "The build arguments.",

0 commit comments

Comments
 (0)