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

Commit 248b7a5

Browse files
authored
fix: allow escaping of commas in plugin list options (#142)
1 parent f058ddd commit 248b7a5

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

cmd/drone-docker-buildx/config.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"github.com/thegeeklab/drone-docker-buildx/plugin"
5+
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
56
"github.com/urfave/cli/v2"
67
)
78

@@ -202,12 +203,12 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
202203
Destination: &settings.Build.Target,
203204
Category: category,
204205
},
205-
&cli.StringSliceFlag{
206-
Name: "cache-from",
207-
EnvVars: []string{"PLUGIN_CACHE_FROM"},
208-
Usage: "images to consider as cache sources",
209-
Destination: &settings.Build.CacheFrom,
210-
Category: category,
206+
&cli.GenericFlag{
207+
Name: "cache-from",
208+
EnvVars: []string{"PLUGIN_CACHE_FROM"},
209+
Usage: "images to consider as cache sources",
210+
Value: &drone.StringSliceFlag{},
211+
Category: category,
211212
},
212213
&cli.StringFlag{
213214
Name: "cache-to",

cmd/drone-docker-buildx/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/thegeeklab/drone-docker-buildx/plugin"
1010
"github.com/urfave/cli/v2"
1111

12+
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
1213
"github.com/thegeeklab/drone-plugin-lib/v2/urfave"
1314
)
1415

@@ -45,6 +46,8 @@ func run(settings *plugin.Settings) cli.ActionFunc {
4546
return func(ctx *cli.Context) error {
4647
urfave.LoggingFromContext(ctx)
4748

49+
settings.Build.CacheFrom = ctx.Generic("cache-from").(*drone.StringSliceFlag).Get()
50+
4851
plugin := plugin.New(
4952
*settings,
5053
urfave.PipelineFromContext(ctx),

plugin/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
8787
if build.NoCache {
8888
args = append(args, "--no-cache")
8989
}
90-
for _, arg := range build.CacheFrom.Value() {
90+
for _, arg := range build.CacheFrom {
9191
args = append(args, "--cache-from", arg)
9292
}
9393
if build.CacheTo != "" {

plugin/impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type Build struct {
5353
ArgsEnv cli.StringSlice // Docker build args from env
5454
Target string // Docker build target
5555
Pull bool // Docker build pull
56-
CacheFrom cli.StringSlice // Docker build cache-from
56+
CacheFrom []string // Docker build cache-from
5757
CacheTo string // Docker build cache-to
5858
Compress bool // Docker build compress
5959
Repo string // Docker build repository

0 commit comments

Comments
 (0)