Compare commits
10 Commits
c8fa946f16
...
c0177b3f8f
Author | SHA1 | Date |
---|---|---|
Nicolai Ort | c0177b3f8f | |
Nicolai Ort | 02b85c7603 | |
pat-s | da8571c718 | |
pat-s | 21518998d8 | |
Thomas Renes | 4c119d46fc | |
pat-s | 5116f6263f | |
woodpecker-bot | b71ce15f17 | |
woodpecker-bot | 3d64e92383 | |
pat-s | e29bb19c9d | |
OCram85 | a0371f8850 |
|
@ -5,13 +5,13 @@ when:
|
|||
- ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
||||
variables:
|
||||
- &golang 'golang:1.21'
|
||||
- &build_plugin 'woodpeckerci/plugin-docker-buildx:2.1.0'
|
||||
- base_settings: &base_buildx_settings
|
||||
platforms: 'linux/amd64,linux/arm64'
|
||||
dockerfile: Dockerfile.multiarch
|
||||
auto_tag: true
|
||||
repo: woodpeckerci/plugin-docker-buildx,codeberg.org/woodpecker-plugins/docker-buildx
|
||||
- &golang "golang:1.21"
|
||||
- &build_plugin "woodpeckerci/plugin-docker-buildx:2.2.0"
|
||||
- base_settings: &base_buildx_settings
|
||||
platforms: "linux/amd64,linux/arm64"
|
||||
dockerfile: Dockerfile.multiarch
|
||||
auto_tag: true
|
||||
repo: registry.odit.services/library/docker-buildx
|
||||
|
||||
steps:
|
||||
vendor:
|
||||
|
@ -37,20 +37,11 @@ steps:
|
|||
image: *build_plugin
|
||||
settings:
|
||||
<<: *base_buildx_settings
|
||||
logins:
|
||||
# Default DockerHub login
|
||||
- registry: https://index.docker.io/v1/
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
# Additional Codeberg login
|
||||
- registry: https://codeberg.org
|
||||
username:
|
||||
from_secret: cb_username
|
||||
password:
|
||||
from_secret: cb_password
|
||||
username:
|
||||
from_secret: odit-registry-builder-username
|
||||
password:
|
||||
from_secret: odit-registry-builder-password
|
||||
|
||||
when:
|
||||
event: [push, tag, cron]
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
|
@ -1,6 +1,6 @@
|
|||
ARG BUILDX_VERSION=0.11.2@sha256:e7f00cf9fc3754de699190b215d383e57bd654179b31b28eefadf978a362e647
|
||||
ARG DOCKER_VERSION=24.0-dind@sha256:0752ca4e936da012c173c119217c0f9599b3b191c1557e53206d5d06d2627580
|
||||
ARG GOLANG_VERSION=1.21@sha256:24a09375a6216764a3eda6a25490a88ac178b5fcb9511d59d0da5ebf9e496474
|
||||
ARG BUILDX_VERSION=0.11.2
|
||||
ARG DOCKER_VERSION=24.0-dind
|
||||
ARG GOLANG_VERSION=1.21
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GOLANG_VERSION} as build
|
||||
|
||||
|
@ -15,7 +15,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
|
|||
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx-bin
|
||||
FROM docker:${DOCKER_VERSION}
|
||||
|
||||
RUN apk --update --no-cache add coredns
|
||||
RUN apk --update --no-cache add coredns git
|
||||
|
||||
COPY --from=build /src/Corefile /etc/coredns/Corefile
|
||||
COPY --from=buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"codeberg.org/woodpecker-plugins/plugin-docker-buildx/plugin"
|
||||
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
@ -99,6 +100,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||
Usage: "sets content of the docker buildkit json config",
|
||||
Destination: &settings.Daemon.BuildkitConfig,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "daemon.buildkit-driveropt",
|
||||
EnvVars: []string{"PLUGIN_BUILDKIT_DRIVEROPT"},
|
||||
Usage: "adds optional driver-ops args like 'env.http_proxy'",
|
||||
Destination: &settings.Daemon.BuildkitDriverOpt,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "dockerfile",
|
||||
EnvVars: []string{"PLUGIN_DOCKERFILE"},
|
||||
|
@ -183,11 +190,11 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||
Usage: "sets the build target to use",
|
||||
Destination: &settings.Build.Target,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "cache-from",
|
||||
EnvVars: []string{"PLUGIN_CACHE_FROM"},
|
||||
Usage: "sets images to consider as cache sources",
|
||||
Destination: &settings.Build.CacheFrom,
|
||||
&cli.GenericFlag{
|
||||
Name: "cache-from",
|
||||
EnvVars: []string{"PLUGIN_CACHE_FROM"},
|
||||
Usage: "images to consider as cache sources",
|
||||
Value: &drone.StringSliceFlag{},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "cache-to",
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/woodpecker-plugins/plugin-docker-buildx/plugin"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/drone-plugins/drone-plugin-lib/errors"
|
||||
"github.com/drone-plugins/drone-plugin-lib/urfave"
|
||||
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
|
||||
"github.com/thegeeklab/drone-plugin-lib/v2/urfave"
|
||||
)
|
||||
|
||||
var version = "unknown"
|
||||
|
@ -19,7 +21,7 @@ func main() {
|
|||
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||
godotenv.Overload("/run/drone/env")
|
||||
}
|
||||
|
||||
|
||||
if envFile, set := os.LookupEnv("PLUGIN_ENV_FILE"); set {
|
||||
godotenv.Overload(envFile)
|
||||
}
|
||||
|
@ -33,7 +35,7 @@ func main() {
|
|||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
errors.HandleExit(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,6 +43,13 @@ func run(settings *plugin.Settings) cli.ActionFunc {
|
|||
return func(ctx *cli.Context) error {
|
||||
urfave.LoggingFromContext(ctx)
|
||||
|
||||
cacheFrom, ok := ctx.Generic("cache-from").(*drone.StringSliceFlag)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to read cache-from input")
|
||||
}
|
||||
|
||||
settings.Build.CacheFrom = cacheFrom.Get()
|
||||
|
||||
plugin := plugin.New(
|
||||
*settings,
|
||||
urfave.PipelineFromContext(ctx),
|
||||
|
@ -48,19 +57,11 @@ func run(settings *plugin.Settings) cli.ActionFunc {
|
|||
)
|
||||
|
||||
if err := plugin.Validate(); err != nil {
|
||||
if e, ok := err.(errors.ExitCoder); ok {
|
||||
return e
|
||||
}
|
||||
|
||||
return errors.ExitMessagef("validation failed: %w", err)
|
||||
return fmt.Errorf("validation failed: %w", err)
|
||||
}
|
||||
|
||||
if err := plugin.Execute(); err != nil {
|
||||
if e, ok := err.(errors.ExitCoder); ok {
|
||||
return e
|
||||
}
|
||||
|
||||
return errors.ExitMessagef("execution failed: %w", err)
|
||||
return fmt.Errorf("execution failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
55
docs.md
55
docs.md
|
@ -102,7 +102,8 @@ If it's not a tag event, and no default branch, automated tags are skipped.
|
|||
| `debug` | `false` | enables verbose debug mode for the docker daemon
|
||||
| `daemon_off` | `false` | disables the startup of the docker daemon
|
||||
| `buildkit_config` | *none* | sets content of the docker [buildkit TOML config](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md)
|
||||
| `tags_file` | *none* | overrides the `tags` option with values in a file named `.tags`; multiple tags can be specified separated by a comma
|
||||
| `buildkit_driveropt` | *none* | adds one or multiple `--driver-opt` buildx arguments for the default buildkit builder instance
|
||||
| `tags_file` | *none* | overrides the `tags` option with values in a file named `.tags`; multiple tags can be specified separated by a newline
|
||||
| `context` | `.` | sets the path of the build context to use
|
||||
| `auto_tag` | `false` | generates tag names automatically based on git branch and git tag, tags supplied via `tags` are additionally added to the auto_tags without suffix
|
||||
| `default_suffix"`/`auto_tag_suffix`| *none* | generates tag names with the given suffix
|
||||
|
@ -142,3 +143,55 @@ settings:
|
|||
password:
|
||||
from_secret: cb_token
|
||||
```
|
||||
|
||||
|
||||
## Using `plugin-docker-buildx` behind a proxy
|
||||
|
||||
When performing a docker build behind a corporate proxy one needs to pass through the proxy settings to the plugin.
|
||||
|
||||
```yaml
|
||||
variables:
|
||||
# proxy config
|
||||
- proxy_conf: &proxy_conf
|
||||
- http_proxy: 'http://X.Y.Z.Z:3128'
|
||||
- https_proxy: 'http://X.Y.Z.Z:3128'
|
||||
- no_proxy: '.my-subdomain.com'
|
||||
# deployment targets
|
||||
- &publish_repos 'codeberg.org/test'
|
||||
# logins for deployment targets
|
||||
- publish_logins: &publish_logins
|
||||
- registry: https://codeberg.org
|
||||
username:
|
||||
from_secret: CODEBERG_USER
|
||||
password:
|
||||
from_secret: CODEBERG_TOKEN
|
||||
|
||||
steps:
|
||||
test:
|
||||
image: woodpeckerci/plugin-docker-buildx:2
|
||||
environment:
|
||||
# adding proxy in env for the plugin runtime itself.
|
||||
- <<: *proxy_conf
|
||||
privileged: true
|
||||
settings:
|
||||
dry_run: true
|
||||
repo: *publish_repos
|
||||
dockerfile: Dockerfile.multi
|
||||
platforms: linux/amd64
|
||||
auto_tag: true
|
||||
logins: *publish_logins
|
||||
# Adding custom dns server to lookup internal Docker Hub mirror.
|
||||
# custom_dns:
|
||||
# - 192.168.55.31
|
||||
# - 192.168.55.32
|
||||
# Adding an optional Docker Hub mirror for the nested dockerd.
|
||||
# mirror: https://my-mirror.example.com
|
||||
build_args:
|
||||
# passthrough proxy config to the build process and Dockerfile CMDs itself.
|
||||
- <<: *proxy_conf
|
||||
# add driver-opt http config to tell buildkit + buildx to resolve external checksums through a proxy.
|
||||
buildkit_driveropt:
|
||||
- 'env.http_proxy=http://X.Y.Z.Z:3128'
|
||||
- 'env.https_proxy=http://X.Y.Z.Z:3128'
|
||||
- 'env.no_proxy=.my-subdomain.com'
|
||||
```
|
4
go.mod
4
go.mod
|
@ -5,11 +5,11 @@ go 1.20
|
|||
require (
|
||||
codeberg.org/6543/go-yaml2json v1.0.0
|
||||
github.com/6543/go-version v1.3.1
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.1
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4
|
||||
github.com/urfave/cli/v2 v2.25.5
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
|
||||
honnef.co/go/tools v0.4.6
|
||||
)
|
||||
|
|
47
go.sum
47
go.sum
|
@ -1,99 +1,62 @@
|
|||
codeberg.org/6543/go-yaml2json v0.3.0 h1:BlvjmY0Gous8P+rr8aBdgPYnIfUAqFepF8q7Tp0R5t8=
|
||||
codeberg.org/6543/go-yaml2json v0.3.0/go.mod h1:mz61q14LWF4ZABrgMEDMmk3t9dPi6zgR1uBh2VKV2RQ=
|
||||
codeberg.org/6543/go-yaml2json v1.0.0 h1:heGqo9VEi7gY2yNqjj7X4ADs5nzlFIbGsJtgYDLrnig=
|
||||
codeberg.org/6543/go-yaml2json v1.0.0/go.mod h1:mz61q14LWF4ZABrgMEDMmk3t9dPi6zgR1uBh2VKV2RQ=
|
||||
github.com/6543/go-version v1.3.1 h1:HvOp+Telns7HWJ2Xo/05YXQSB2bE0WmVgbHqwMPZT4U=
|
||||
github.com/6543/go-version v1.3.1/go.mod h1:oqFAHCwtLVUTLdhQmVZWYvaHXTdsbB4SY85at64SQEo=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.0 h1:qywEYGhquUuid6zNLmKia8CWY1TUa8jPQQ/G9ozfAmc=
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.0/go.mod h1:EgqogX38GoJFtckeSQyhBJYX8P+KWBPhdprAVvyRxF8=
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.1 h1:47rZlmcMpr1hSp+6Gl+1Z4t+efi/gMQU3lxukC1Yg64=
|
||||
github.com/drone-plugins/drone-plugin-lib v0.4.1/go.mod h1:KwCu92jFjHV3xv2hu5Qg/8zBNvGwbhoJDQw/EwnTvoM=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/urfave/cli/v2 v2.16.3 h1:gHoFIwpPjoyIMbJp/VFd+/vuD0dAgFK4B6DpEMFJfQk=
|
||||
github.com/urfave/cli/v2 v2.16.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI=
|
||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4 h1:Quzrike/xRAR0izxQ0d+ocJyIUm4h1497Oyo9grcRzg=
|
||||
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4/go.mod h1:qWVUZCmwL0Ntwa/hvyqM03EeIr1ReBR2XJsmIc7MGus=
|
||||
github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc=
|
||||
github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
|
||||
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
||||
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=
|
||||
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=
|
||||
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
|
||||
golang.org/x/tools v0.12.1-0.20230825192346-2191a27a6dc5 h1:Vk4mysSz+GqQK2eqgWbo4zEO89wkeAjJiFIr9bpqa8k=
|
||||
golang.org/x/tools v0.12.1-0.20230825192346-2191a27a6dc5/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||
honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
|
||||
honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
|
||||
honnef.co/go/tools v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
|
||||
honnef.co/go/tools v0.4.6/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0=
|
||||
|
|
|
@ -41,6 +41,10 @@ func commandBuilder(daemon Daemon) *exec.Cmd {
|
|||
args = append(args, "--config", buildkitConfig)
|
||||
}
|
||||
|
||||
for _, driveropt := range daemon.BuildkitDriverOpt.Value() {
|
||||
args = append(args, "--driver-opt", driveropt)
|
||||
}
|
||||
|
||||
return exec.Command(dockerExe, args...)
|
||||
}
|
||||
|
||||
|
@ -74,7 +78,7 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
|
|||
if build.NoCache {
|
||||
args = append(args, "--no-cache")
|
||||
}
|
||||
for _, arg := range build.CacheFrom.Value() {
|
||||
for _, arg := range build.CacheFrom {
|
||||
args = append(args, "--cache-from", arg)
|
||||
}
|
||||
for _, arg := range build.CacheTo.Value() {
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func TestCommandBuilder(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
Name string
|
||||
Daemon Daemon
|
||||
Input string
|
||||
WantedLen int
|
||||
Skip bool
|
||||
Excuse string
|
||||
}{
|
||||
{
|
||||
Name: "Single driver-opt value",
|
||||
Daemon: Daemon{},
|
||||
Input: "no_proxy=*.mydomain",
|
||||
WantedLen: 1,
|
||||
},
|
||||
{
|
||||
Name: "Single driver-opt value with comma",
|
||||
Input: "no_proxy=.mydomain,.sub.domain.com",
|
||||
WantedLen: 1,
|
||||
Skip: true,
|
||||
Excuse: "Can be enabled whenever #94 is fixed.",
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
if (test.Skip) {
|
||||
t.Skip(fmt.Printf("%v skipped. %v", test.Name, test.Excuse))
|
||||
}
|
||||
// prepare test values to mock plugin call with settings
|
||||
os.Setenv("PLUGIN_BUILDKIT_DRIVEROPT", test.Input)
|
||||
|
||||
// create dummy cli app to reproduce the issue
|
||||
app := &cli.App{
|
||||
Name: "dummy App",
|
||||
Usage: "testing inputs",
|
||||
Version: "0.0.1",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringSliceFlag{
|
||||
Name: "daemon.buildkit-driveropt",
|
||||
EnvVars: []string{"PLUGIN_BUILDKIT_DRIVEROPT"},
|
||||
Usage: "adds optional driver-ops args like 'env.http_proxy'",
|
||||
Destination: &test.Daemon.BuildkitDriverOpt,
|
||||
},
|
||||
},
|
||||
Action: nil,
|
||||
}
|
||||
|
||||
// need to run the app to resolve the flags
|
||||
_ = app.Run(nil)
|
||||
|
||||
// call the commandBuilder to prepare the cmd with its args
|
||||
_ = commandBuilder(test.Daemon)
|
||||
|
||||
assert.Len(t, test.Daemon.BuildkitDriverOpt.Value(), test.WantedLen)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
|
@ -18,20 +18,21 @@ import (
|
|||
|
||||
// Daemon defines Docker daemon parameters.
|
||||
type Daemon struct {
|
||||
Registry string // Docker registry
|
||||
Mirror string // Docker registry mirror
|
||||
Insecure bool // Docker daemon enable insecure registries
|
||||
StorageDriver string // Docker daemon storage driver
|
||||
StoragePath string // Docker daemon storage path
|
||||
Disabled bool // DOcker daemon is disabled (already running)
|
||||
Debug bool // Docker daemon started in debug mode
|
||||
Bip string // Docker daemon network bridge IP address
|
||||
DNS cli.StringSlice // Docker daemon dns server
|
||||
DNSSearch cli.StringSlice // Docker daemon dns search domain
|
||||
MTU string // Docker daemon mtu setting
|
||||
IPv6 bool // Docker daemon IPv6 networking
|
||||
Experimental bool // Docker daemon enable experimental mode
|
||||
BuildkitConfig string // Docker buildkit config
|
||||
Registry string // Docker registry
|
||||
Mirror string // Docker registry mirror
|
||||
Insecure bool // Docker daemon enable insecure registries
|
||||
StorageDriver string // Docker daemon storage driver
|
||||
StoragePath string // Docker daemon storage path
|
||||
Disabled bool // DOcker daemon is disabled (already running)
|
||||
Debug bool // Docker daemon started in debug mode
|
||||
Bip string // Docker daemon network bridge IP address
|
||||
DNS cli.StringSlice // Docker daemon dns server
|
||||
DNSSearch cli.StringSlice // Docker daemon dns search domain
|
||||
MTU string // Docker daemon mtu setting
|
||||
IPv6 bool // Docker daemon IPv6 networking
|
||||
Experimental bool // Docker daemon enable experimental mode
|
||||
BuildkitConfig string // Docker buildkit config
|
||||
BuildkitDriverOpt cli.StringSlice // Docker buildkit driveropt args
|
||||
}
|
||||
|
||||
// Login defines Docker login parameters.
|
||||
|
@ -63,7 +64,7 @@ type Build struct {
|
|||
Target string // Docker build target
|
||||
Output string // Docker build output
|
||||
Pull bool // Docker build pull
|
||||
CacheFrom cli.StringSlice // Docker build cache-from
|
||||
CacheFrom []string // Docker build cache-from
|
||||
CacheTo cli.StringSlice // Docker build cache-to
|
||||
Compress bool // Docker build compress
|
||||
Repo cli.StringSlice // Docker build repository
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"github.com/drone-plugins/drone-plugin-lib/drone"
|
||||
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
|
||||
)
|
||||
|
||||
// Plugin implements drone.Plugin to provide the plugin implementation.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["github>thegeeklab/renovate-presets"]
|
||||
"extends": ["local>woodpecker-plugins/renovate-config"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue