From 10426e6a190c39fd332907590c812ee1bf8cd66c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 28 Sep 2022 15:17:39 +0200 Subject: [PATCH] Allow multible Repos (#22) close partialy #18 we still need to handle multible registry login Reviewed-on: https://codeberg.org/woodpecker-plugins/plugin-docker-buildx/pulls/22 --- cmd/docker-buildx/config.go | 2 +- docs.md | 2 +- plugin/docker.go | 6 ++++-- plugin/impl.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/docker-buildx/config.go b/cmd/docker-buildx/config.go index e11b0c3..e831d9e 100644 --- a/cmd/docker-buildx/config.go +++ b/cmd/docker-buildx/config.go @@ -189,7 +189,7 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { Usage: "enables compression og the build context using gzip", Destination: &settings.Build.Compress, }, - &cli.StringFlag{ + &cli.StringSliceFlag{ Name: "repo", EnvVars: []string{"PLUGIN_REPO"}, Usage: "sets repository name for the image", diff --git a/docs.md b/docs.md index 37d6526..b067213 100644 --- a/docs.md +++ b/docs.md @@ -30,7 +30,7 @@ It will automatically generate buildkit configuration to use custom CA certifica | Settings Name | Default | Description | --------------------------| ----------------- | -------------------------------------------- | `dry-run` | `false` | disables docker push -| `repo` | *none* | sets repository name for the image +| `repo` | *none* | sets repository name for the image (can be a list) | `username` | *none* | sets username to authenticates with | `password` | *none* | sets password / token to authenticates with | `email` | *none* | sets email address to authenticates with diff --git a/plugin/docker.go b/plugin/docker.go index 1f212e5..7b06f05 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -122,8 +122,10 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { args = append(args, "--platform", strings.Join(build.Platforms.Value()[:], ",")) } - for _, arg := range build.Tags.Value() { - args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg)) + for _, tag := range build.Tags.Value() { + for _, repo := range build.Repo.Value() { + args = append(args, "-t", fmt.Sprintf("%s:%s", repo, tag)) + } } for _, l := range build.Labels.Value() { diff --git a/plugin/impl.go b/plugin/impl.go index fbb6145..1d271b3 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -60,7 +60,7 @@ type Build struct { Pull bool // Docker build pull CacheFrom cli.StringSlice // Docker build cache-from Compress bool // Docker build compress - Repo string // Docker build repository + Repo cli.StringSlice // Docker build repository NoCache bool // Docker build no-cache AddHost cli.StringSlice // Docker build add-host Quiet bool // Docker build quiet