-
Notifications
You must be signed in to change notification settings - Fork 5
/
buildx.go
35 lines (30 loc) · 908 Bytes
/
buildx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package docker
import (
"os/exec"
)
const (
defaultDriver = "docker"
dockerContainerDriver = "docker-container"
remoteDriver = "remote"
)
func cmdSetupBuildx(builder Builder, driverOpts []string) *exec.Cmd {
args := []string{"buildx", "create", "--use", "--driver", builder.Driver}
if builder.Name != "" {
args = append(args, "--name", builder.Name)
}
for _, opt := range driverOpts {
args = append(args, "--driver-opt", opt)
}
if builder.RemoteConn != "" && builder.Driver == remoteDriver {
args = append(args, builder.RemoteConn)
}
return exec.Command(dockerExe, args...)
}
func cmdInspectBuildx(name string) *exec.Cmd {
args := []string{"buildx", "inspect", "--bootstrap", "--builder", name}
return exec.Command(dockerExe, args...)
}
func cmdRemoveBuildx(name string) *exec.Cmd {
args := []string{"buildx", "rm", name}
return exec.Command(dockerExe, args...)
}