From 65ea60594a172271062c436a9dc40aa2321d5d87 Mon Sep 17 00:00:00 2001 From: Rutvij Mehta Date: Sat, 6 May 2023 14:10:51 -0700 Subject: [PATCH] Add support for builder driver opts --- buildx.go | 4 ++-- cmd/drone-docker/main.go | 6 ++++-- docker.go | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/buildx.go b/buildx.go index 0e381bc..0a5f7ad 100644 --- a/buildx.go +++ b/buildx.go @@ -15,8 +15,8 @@ func cmdSetupBuildx(builder Builder) *exec.Cmd { if builder.Name != "" { args = append(args, "--name", builder.Name) } - if builder.DriverOpts != "" { - args = append(args, "--driver-opt", builder.DriverOpts) + for _, opt := range builder.DriverOpts { + args = append(args, "--driver-opt", opt) } if builder.RemoteConn != "" && builder.Driver == remoteDriver { args = append(args, builder.RemoteConn) diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index 23d78cc..713876a 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -289,9 +289,11 @@ func main() { Name: "builder-driver", EnvVar: "PLUGIN_BUILDER_DRIVER", }, - cli.StringFlag{ + cli.GenericFlag{ Name: "builder-driver-opts", + Usage: "buildx builder driver opts", EnvVar: "PLUGIN_BUILDER_DRIVER_OPTS", + Value: new(docker.CustomStringSliceFlag), }, cli.StringFlag{ Name: "builder-remote-conn", @@ -366,7 +368,7 @@ func run(c *cli.Context) error { Builder: docker.Builder{ Name: c.String("builder-name"), Driver: c.String("builder-driver"), - DriverOpts: c.String("builder-driver-opts"), + DriverOpts: c.Generic("builder-driver-opts").(*docker.CustomStringSliceFlag).GetValue(), RemoteConn: c.String("builder-remote-conn"), }, } diff --git a/docker.go b/docker.go index f7af5a1..59fc1cd 100644 --- a/docker.go +++ b/docker.go @@ -28,10 +28,10 @@ type ( } Builder struct { - Name string // Buildx builder name - Driver string // Buildx driver type - DriverOpts string // Buildx driver opts - RemoteConn string // Buildx remote connection endpoint + Name string // Buildx builder name + Driver string // Buildx driver type + DriverOpts []string // Buildx driver opts + RemoteConn string // Buildx remote connection endpoint } // Login defines Docker login parameters.