make cache-from an array

This commit is contained in:
Seth Pollack 2017-10-26 12:26:26 -04:00 committed by Ryan Sullivan
parent a48b59645a
commit 008bbaf47b
No known key found for this signature in database
GPG Key ID: A81AC24687421396
2 changed files with 7 additions and 6 deletions

View File

@ -150,6 +150,7 @@ func main() {
Name: "target", Name: "target",
Usage: "build target", Usage: "build target",
EnvVar: "PLUGIN_TARGET", EnvVar: "PLUGIN_TARGET",
},
cli.StringSliceFlag{ cli.StringSliceFlag{
Name: "cache-from", Name: "cache-from",
Usage: "cache from", Usage: "cache from",
@ -249,7 +250,7 @@ func run(c *cli.Context) error {
Target: c.String("target"), Target: c.String("target"),
Squash: c.Bool("squash"), Squash: c.Bool("squash"),
Pull: c.BoolT("pull-image"), Pull: c.BoolT("pull-image"),
CacheFrom: c.String("cache-from"), CacheFrom: c.StringSlice("cache-from"),
Compress: c.Bool("compress"), Compress: c.Bool("compress"),
Repo: c.String("repo"), Repo: c.String("repo"),
Labels: c.StringSlice("custom-labels"), Labels: c.StringSlice("custom-labels"),

View File

@ -47,7 +47,7 @@ type (
Target string // Docker build target Target string // Docker build target
Squash bool // Docker build squash Squash bool // Docker build squash
Pull bool // Docker build pull Pull bool // Docker build pull
CacheFrom string // Docker build cache-from CacheFrom []string // Docker build cache-from
Compress bool // Docker build compress Compress bool // Docker build compress
Repo string // Docker build repository Repo string // Docker build repository
LabelSchema []string // label-schema Label map LabelSchema []string // label-schema Label map
@ -106,8 +106,8 @@ func (p Plugin) Exec() error {
} }
// pre-pull cache image // pre-pull cache image
if p.Build.CacheFrom != "" { for _, img := range p.Build.CacheFrom {
cmd := commandPull(p.Build.CacheFrom) cmd := commandPull(img)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
trace(cmd) trace(cmd)
@ -218,8 +218,8 @@ func commandBuild(build Build) *exec.Cmd {
if build.NoCache { if build.NoCache {
args = append(args, "--no-cache") args = append(args, "--no-cache")
} }
if build.CacheFrom != "" { for _, arg := range build.CacheFrom {
args = append(args, "--cache-from", build.CacheFrom) args = append(args, "--cache-from", arg)
} }
for _, arg := range build.ArgsEnv { for _, arg := range build.ArgsEnv {
addProxyValue(&build, arg) addProxyValue(&build, arg)