From f528612af5820dbda0163a3d7852459e3e4f93b5 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 13 Aug 2023 22:08:53 +0200 Subject: [PATCH] refactor: initial commit after rewrite to woodpecker --- .chglog/config.yml | 2 +- .dictionary | 2 +- .drone.yml | 291 ------------------ .github/settings.yml | 31 +- .gitignore | 2 +- .prettierignore | 1 - Dockerfile.multiarch | 12 +- Makefile | 6 +- README.md | 26 +- _docs/content/_index.md | 32 +- _docs/data/data.yaml | 8 +- cmd/drone-docker-buildx/main.go | 83 ----- .../config.go | 8 +- cmd/wp-docker-buildx/main.go | 31 ++ go.mod | 13 +- go.sum | 36 ++- plugin/coredns.go | 2 +- plugin/daemon.go | 4 +- plugin/impl.go | 157 ++++------ plugin/plugin.go | 91 +++++- 20 files changed, 256 insertions(+), 582 deletions(-) delete mode 100644 .drone.yml delete mode 100644 cmd/drone-docker-buildx/main.go rename cmd/{drone-docker-buildx => wp-docker-buildx}/config.go (98%) create mode 100644 cmd/wp-docker-buildx/main.go diff --git a/.chglog/config.yml b/.chglog/config.yml index 8548d73..cebc5f3 100755 --- a/.chglog/config.yml +++ b/.chglog/config.yml @@ -2,7 +2,7 @@ style: github template: CHANGELOG.tpl.md info: title: CHANGELOG - repository_url: https://github.com/thegeeklab/drone-docker-buildx + repository_url: https://github.com/thegeeklab/wp-docker-buildx options: commit_groups: title_maps: diff --git a/.dictionary b/.dictionary index be38f21..d19a748 100644 --- a/.dictionary +++ b/.dictionary @@ -12,7 +12,7 @@ gzip toml config host:ip -drone-docker-buildx +wp-docker-buildx multiarch buildx DockerHub diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 950b2d6..0000000 --- a/.drone.yml +++ /dev/null @@ -1,291 +0,0 @@ ---- -kind: pipeline -name: test - -platform: - os: linux - arch: amd64 - -steps: - - name: deps - image: golang:1.20 - commands: - - make deps - volumes: - - name: godeps - path: /go - - - name: lint - image: golang:1.20 - commands: - - make lint - volumes: - - name: godeps - path: /go - - - name: test - image: golang:1.20 - commands: - - make test - volumes: - - name: godeps - path: /go - -volumes: - - name: godeps - temp: {} - -trigger: - ref: - - refs/heads/main - - refs/tags/** - - refs/pull/** - ---- -kind: pipeline -name: build-binaries - -platform: - os: linux - arch: amd64 - -steps: - - name: build - image: techknowlogick/xgo:go-1.20.x - commands: - - ln -s /drone/src /source - - make release - - - name: executable - image: alpine - commands: - - $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help - - - name: changelog-generate - image: thegeeklab/git-chglog - commands: - - git fetch -tq - - git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased} - - - name: changelog-format - image: thegeeklab/alpine-tools - commands: - - prettier CHANGELOG.md - - prettier -w CHANGELOG.md - - - name: publish - image: plugins/github-release - settings: - api_key: - from_secret: github_token - files: - - dist/* - note: CHANGELOG.md - overwrite: true - title: ${DRONE_TAG} - when: - ref: - - refs/tags/** - -trigger: - ref: - - refs/heads/main - - refs/tags/** - - refs/pull/** - -depends_on: - - test - ---- -kind: pipeline -name: build-container - -platform: - os: linux - arch: amd64 - -steps: - - name: dryrun - image: thegeeklab/drone-docker-buildx:23 - settings: - dockerfile: Dockerfile.multiarch - dry_run: true - platforms: - - linux/amd64 - - linux/arm64 - provenance: false - repo: thegeeklab/${DRONE_REPO_NAME} - when: - ref: - - refs/pull/** - - - name: publish-dockerhub - image: thegeeklab/drone-docker-buildx:23 - settings: - auto_tag: true - dockerfile: Dockerfile.multiarch - password: - from_secret: docker_password - platforms: - - linux/amd64 - - linux/arm64 - provenance: false - repo: thegeeklab/${DRONE_REPO_NAME} - username: - from_secret: docker_username - when: - ref: - - refs/heads/main - - refs/tags/** - depends_on: - - dryrun - - - name: publish-quay - image: thegeeklab/drone-docker-buildx:23 - settings: - auto_tag: true - dockerfile: Dockerfile.multiarch - password: - from_secret: quay_password - platforms: - - linux/amd64 - - linux/arm64 - provenance: false - registry: quay.io - repo: quay.io/thegeeklab/${DRONE_REPO_NAME} - username: - from_secret: quay_username - when: - ref: - - refs/heads/main - - refs/tags/** - depends_on: - - dryrun - -trigger: - ref: - - refs/heads/main - - refs/tags/** - - refs/pull/** - -depends_on: - - test - ---- -kind: pipeline -name: docs - -platform: - os: linux - arch: amd64 - -concurrency: - limit: 1 - -steps: - - name: markdownlint - image: thegeeklab/markdownlint-cli - commands: - - markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md' - - - name: spellcheck - image: thegeeklab/alpine-tools - commands: - - spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions - environment: - FORCE_COLOR: true - NPM_CONFIG_LOGLEVEL: error - - - name: publish - image: thegeeklab/drone-git-action - settings: - action: - - pages - author_email: bot@thegeeklab.de - author_name: thegeeklab-bot - branch: docs - message: auto-update documentation - netrc_password: - from_secret: github_token - pages_directory: _docs/ - when: - ref: - - refs/heads/main - -trigger: - ref: - - refs/heads/main - - refs/tags/** - - refs/pull/** - -depends_on: - - build-binaries - - build-container - ---- -kind: pipeline -name: notifications - -platform: - os: linux - arch: amd64 - -steps: - - name: pushrm-dockerhub - image: chko/docker-pushrm:1 - environment: - DOCKER_PASS: - from_secret: docker_password - DOCKER_USER: - from_secret: docker_username - PUSHRM_FILE: README.md - PUSHRM_SHORT: Drone plugin to build multiarch Docker images with buildx - PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME} - when: - status: - - success - - - name: pushrm-quay - image: chko/docker-pushrm:1 - environment: - APIKEY__QUAY_IO: - from_secret: quay_token - PUSHRM_FILE: README.md - PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME} - when: - status: - - success - - - name: matrix - image: thegeeklab/drone-matrix - settings: - homeserver: - from_secret: matrix_homeserver - password: - from_secret: matrix_password - roomid: - from_secret: matrix_roomid - template: "Status: **{{ .Build.Status }}**
Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}
Message: {{ .Commit.Message.Title }}" - username: - from_secret: matrix_username - when: - status: - - success - - failure - -trigger: - ref: - - refs/heads/main - - refs/tags/** - status: - - success - - failure - -depends_on: - - docs - ---- -kind: signature -hmac: a62b604d49c98c24360bfaea313f8dba31166133620d5e7656f884e1f20b9ff6 - -... diff --git a/.github/settings.yml b/.github/settings.yml index 8672f80..7abab4c 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,8 +1,8 @@ repository: - name: drone-docker-buildx - description: Drone plugin to build multiarch Docker images with buildx - homepage: https://drone-plugin-index.geekdocs.de/plugins/drone-docker-buildx - topics: drone, drone-plugin + name: wp-docker-buildx + description: Woodpecker CI plugin to build multiarch Docker images with buildx + homepage: https://wp-plugin-index.geekdocs.de/plugins/wp-docker-buildx + topics: woodpecker, wp-plugin private: false has_issues: true @@ -43,26 +43,3 @@ labels: - name: wontfix color: ffffff description: This will not be worked on - -branches: - - name: main - protection: - required_pull_request_reviews: null - required_status_checks: - strict: false - contexts: - - continuous-integration/drone/pr - enforce_admins: true - required_linear_history: true - restrictions: null - - name: docs - protection: - required_pull_request_reviews: null - required_status_checks: null - enforce_admins: true - required_linear_history: true - restrictions: - apps: [] - users: [] - teams: - - bot diff --git a/.gitignore b/.gitignore index ad57b64..6466682 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /dist/ /release/ -/drone-docker-buildx* +/wp-docker-buildx* coverage.out CHANGELOG.md diff --git a/.prettierignore b/.prettierignore index 23a4f05..135c35d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,2 @@ -.drone.yml *.tpl.md LICENSE diff --git a/Dockerfile.multiarch b/Dockerfile.multiarch index c3717fc..f8c036e 100644 --- a/Dockerfile.multiarch +++ b/Dockerfile.multiarch @@ -12,10 +12,10 @@ FROM docker:24.0-dind@sha256:9e71442b7584518e6efefd9f325cbc5b4b9b000886cffef6e67 LABEL maintainer="Robert Kaussow " LABEL org.opencontainers.image.authors="Robert Kaussow " -LABEL org.opencontainers.image.title="drone-docker-buildx" -LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-docker-buildx" -LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-docker-buildx" -LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-docker-buildx" +LABEL org.opencontainers.image.title="wp-docker-buildx" +LABEL org.opencontainers.image.url="https://github.com/thegeeklab/wp-docker-buildx" +LABEL org.opencontainers.image.source="https://github.com/thegeeklab/wp-docker-buildx" +LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/wp-docker-buildx" ARG TARGETOS ARG TARGETARCH @@ -37,5 +37,5 @@ RUN apk --update add --virtual .build-deps curl && \ rm -rf /tmp/* COPY --from=build /src/Corefile /etc/coredns/Corefile -COPY --from=build /src/dist/drone-docker-buildx /bin/drone-docker-buildx -ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"] +COPY --from=build /src/dist/wp-docker-buildx /bin/wp-docker-buildx +ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "wp-docker-buildx"] diff --git a/Makefile b/Makefile index 01a7041..aa978a7 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOFUMPT_PACKAGE_VERSION := v0.5.0 # renovate: datasource=github-releases depName=golangci/golangci-lint GOLANGCI_LINT_PACKAGE_VERSION := v1.53.3 -EXECUTABLE := drone-docker-buildx +EXECUTABLE := wp-docker-buildx DIST := dist DIST_DIRS := $(DIST) @@ -30,8 +30,8 @@ endif TAGS ?= netgo ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) + ifneq ($(CI_COMMIT_TAG),) + VERSION ?= $(subst v,,$(CI_COMMIT_TAG)) else VERSION ?= $(shell git rev-parse --short HEAD) endif diff --git a/README.md b/README.md index 0d93135..ec388b9 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# drone-docker-buildx +# wp-docker-buildx -Drone plugin to build multiarch Docker images with buildx +Woodpecker CI plugin to build multiarch Docker images with buildx -[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-docker-buildx?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-docker-buildx) -[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-docker-buildx) -[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/drone-docker-buildx) -[![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/drone-docker-buildx)](https://goreportcard.com/report/github.com/thegeeklab/drone-docker-buildx) -[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-docker-buildx)](https://github.com/thegeeklab/drone-docker-buildx/graphs/contributors) -[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-docker-buildx) -[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/drone-docker-buildx)](https://github.com/thegeeklab/drone-docker-buildx/blob/main/LICENSE) +[![Build Status](https://img.shields.io/wp/build/thegeeklab/wp-docker-buildx?logo=wp&server=https%3A%2F%2Fwp.thegeeklab.de)](https://wp.thegeeklab.de/thegeeklab/wp-docker-buildx) +[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/wp-docker-buildx) +[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/wp-docker-buildx) +[![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/wp-docker-buildx)](https://goreportcard.com/report/github.com/thegeeklab/wp-docker-buildx) +[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/graphs/contributors) +[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/wp-docker-buildx) +[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/blob/main/LICENSE) -Drone plugin to build multiarch Docker images with buildx. This plugin is a fork of [drone-plugins/drone-docker](https://github.com/drone-plugins/drone-docker). You can find the full documentation at [https://drone-plugin-index.geekdocs.de](https://drone-plugin-index.geekdocs.de/plugins/drone-docker-buildx). +Woodpecker CI plugin to build multiarch Docker images with buildx. This plugin is a fork of [wp-plugins/wp-docker](https://github.com/wp-plugins/wp-docker). You can find the full documentation at [https://wp-plugin-index.geekdocs.de](https://wp-plugin-index.geekdocs.de/plugins/wp-docker-buildx). ## Versioning @@ -21,15 +21,15 @@ The tags follow the major version of Docker, e.g. `20`, and the minor and patch -- [BitProcessor/drone-docker-buildx-ecr](https://github.com/BitProcessor/drone-docker-buildx-ecr) by [@BitProcessor](https://github.com/BitProcessor) +- [BitProcessor/wp-docker-buildx-ecr](https://github.com/BitProcessor/wp-docker-buildx-ecr) by [@BitProcessor](https://github.com/BitProcessor) ## Contributors -Special thanks to all [contributors](https://github.com/thegeeklab/drone-docker-buildx/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/drone-docker-buildx/blob/main/CONTRIBUTING.md). +Special thanks to all [contributors](https://github.com/thegeeklab/wp-docker-buildx/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/wp-docker-buildx/blob/main/CONTRIBUTING.md). ## License -This project is licensed under the Apache-2.0 License - see the [LICENSE](https://github.com/thegeeklab/drone-docker-buildx/blob/main/LICENSE) file for details. +This project is licensed under the Apache-2.0 License - see the [LICENSE](https://github.com/thegeeklab/wp-docker-buildx/blob/main/LICENSE) file for details. diff --git a/_docs/content/_index.md b/_docs/content/_index.md index ce1585e..2a304a1 100644 --- a/_docs/content/_index.md +++ b/_docs/content/_index.md @@ -1,15 +1,15 @@ --- -title: drone-docker-buildx +title: wp-docker-buildx --- -[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-docker-buildx?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-docker-buildx) -[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-docker-buildx) -[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/drone-docker-buildx) -[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-docker-buildx)](https://github.com/thegeeklab/drone-docker-buildx/graphs/contributors) -[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-docker-buildx) -[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-docker-buildx)](https://github.com/thegeeklab/drone-docker-buildx/blob/main/LICENSE) +[![Build Status](https://img.shields.io/wp/build/thegeeklab/wp-docker-buildx?logo=wp&server=https%3A%2F%2Fwp.thegeeklab.de)](https://wp.thegeeklab.de/thegeeklab/wp-docker-buildx) +[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/wp-docker-buildx) +[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/wp-docker-buildx) +[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/graphs/contributors) +[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/wp-docker-buildx) +[![License: MIT](https://img.shields.io/github/license/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/blob/main/LICENSE) -Drone plugin to build and publish multiarch Docker images with buildx. +Woodpecker CI plugin to build and publish multiarch Docker images with buildx. @@ -24,7 +24,7 @@ The tags follow the major version of Docker, e.g. `20`, and the minor and patch ## Usage {{< hint type=important >}} -Be aware that the this plugin requires [privileged](https://docs.drone.io/pipeline/docker/syntax/steps/#privileged-mode) capabilities, otherwise the integrated Docker daemon is not able to start. +Be aware that the this plugin requires [privileged](https://docs.wp.io/pipeline/docker/syntax/steps/#privileged-mode) capabilities, otherwise the integrated Docker daemon is not able to start. {{< /hint >}} ```yaml @@ -33,7 +33,7 @@ name: default steps: - name: docker - image: thegeeklab/drone-docker-buildx:23 + image: thegeeklab/wp-docker-buildx:23 privileged: true settings: username: octocat @@ -46,7 +46,7 @@ steps: -{{< propertylist name=drone-docker-buildx.data sort=name >}} +{{< propertylist name=wp-docker-buildx.data sort=name >}} @@ -64,7 +64,7 @@ name: default steps: - name: docker - image: thegeeklab/drone-docker-buildx:23 + image: thegeeklab/wp-docker-buildx:23 privileged: true settings: registry: ghcr.io @@ -82,7 +82,7 @@ name: default steps: - name: docker - image: thegeeklab/drone-docker-buildx:23 + image: thegeeklab/wp-docker-buildx:23 privileged: true environment: AWS_ACCESS_KEY_ID: @@ -111,7 +111,7 @@ make build Build the Docker image with the following command: ```shell -docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-docker-buildx . +docker build --file docker/Dockerfile.amd64 --tag thegeeklab/wp-docker-buildx . ``` ## Test @@ -120,9 +120,9 @@ docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-docker-buildx docker run --rm \ -e PLUGIN_TAG=latest \ -e PLUGIN_REPO=octocat/hello-world \ - -e DRONE_COMMIT_SHA=00000000 \ + -e CI_COMMIT_SHA=00000000 \ -v $(pwd):$(pwd) \ -w $(pwd) \ --privileged \ - thegeeklab/drone-docker-buildx --dry-run + thegeeklab/wp-docker-buildx --dry-run ``` diff --git a/_docs/data/data.yaml b/_docs/data/data.yaml index 5981499..ff03aae 100644 --- a/_docs/data/data.yaml +++ b/_docs/data/data.yaml @@ -78,7 +78,7 @@ properties: ```yaml steps: - name: Build - image: thegeeklab/drone-docker-buildx:23 + image: thegeeklab/wp-docker-buildx:23 settings: repo: example/repo buildkit_config: | @@ -167,7 +167,7 @@ properties: ```yaml steps: - name: Build - image: thegeeklab/drone-docker-buildx:23 + image: thegeeklab/wp-docker-buildx:23 settings: repo: example/repo cache_from: @@ -276,7 +276,7 @@ properties: ```yaml steps: - name: Build - image: thegeeklab/drone-docker-buildx:23 + image: thegeeklab/wp-docker-buildx:23 privileged: true environment: SECURE_TOKEN: @@ -289,7 +289,7 @@ properties: - "id=SECRET_TOKEN" ``` - To use secrets from files a [host volume](https://docs.drone.io/pipeline/docker/syntax/volumes/host/) is required. + To use secrets from files a [host volume](https://docs.wp.io/pipeline/docker/syntax/volumes/host/) is required. This should be used with caution and avoided whenever possible. type: list required: false diff --git a/cmd/drone-docker-buildx/main.go b/cmd/drone-docker-buildx/main.go deleted file mode 100644 index 1240fcc..0000000 --- a/cmd/drone-docker-buildx/main.go +++ /dev/null @@ -1,83 +0,0 @@ -package main - -import ( - "errors" - "fmt" - "os" - - "github.com/joho/godotenv" - "github.com/sirupsen/logrus" - "github.com/thegeeklab/drone-docker-buildx/plugin" - "github.com/urfave/cli/v2" - - "github.com/thegeeklab/drone-plugin-lib/v2/drone" - "github.com/thegeeklab/drone-plugin-lib/v2/urfave" -) - -//nolint:gochecknoglobals -var ( - BuildVersion = "devel" - BuildDate = "00000000" -) - -var ErrTypeAssertionFailed = errors.New("type assertion failed") - -func main() { - settings := &plugin.Settings{} - - if _, err := os.Stat("/run/drone/env"); err == nil { - _ = godotenv.Overload("/run/drone/env") - } - - cli.VersionPrinter = func(c *cli.Context) { - fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate) - } - - app := &cli.App{ - Name: "drone-docker-buildx", - Usage: "build docker container with DinD and buildx", - Version: BuildVersion, - Flags: append(settingsFlags(settings, urfave.FlagsPluginCategory), urfave.Flags()...), - Action: run(settings), - } - - if err := app.Run(os.Args); err != nil { - logrus.Fatal(err) - } -} - -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("%w: failed to read cache-from input", ErrTypeAssertionFailed) - } - - settings.Build.CacheFrom = cacheFrom.Get() - - secrets, ok := ctx.Generic("secrets").(*drone.StringSliceFlag) - if !ok { - return fmt.Errorf("%w: failed to read secrets input", ErrTypeAssertionFailed) - } - - settings.Build.Secrets = secrets.Get() - - plugin := plugin.New( - *settings, - urfave.PipelineFromContext(ctx), - urfave.NetworkFromContext(ctx), - ) - - if err := plugin.Validate(); err != nil { - return fmt.Errorf("validation failed: %w", err) - } - - if err := plugin.Execute(); err != nil { - return fmt.Errorf("execution failed: %w", err) - } - - return nil - } -} diff --git a/cmd/drone-docker-buildx/config.go b/cmd/wp-docker-buildx/config.go similarity index 98% rename from cmd/drone-docker-buildx/config.go rename to cmd/wp-docker-buildx/config.go index 8cc5415..f44ca58 100644 --- a/cmd/drone-docker-buildx/config.go +++ b/cmd/wp-docker-buildx/config.go @@ -1,8 +1,8 @@ package main import ( - "github.com/thegeeklab/drone-docker-buildx/plugin" - "github.com/thegeeklab/drone-plugin-lib/v2/drone" + "github.com/thegeeklab/wp-docker-buildx/plugin" + wp "github.com/thegeeklab/wp-plugin-go/plugin" "github.com/urfave/cli/v2" ) @@ -209,7 +209,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Name: "cache-from", EnvVars: []string{"PLUGIN_CACHE_FROM"}, Usage: "images to consider as cache sources", - Value: &drone.StringSliceFlag{}, + Value: &wp.StringSliceFlag{}, Category: category, }, &cli.StringFlag{ @@ -325,7 +325,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Name: "secrets", EnvVars: []string{"PLUGIN_SECRETS"}, Usage: "exposes secrets to the build", - Value: &drone.StringSliceFlag{}, + Value: &wp.StringSliceFlag{}, Category: category, }, } diff --git a/cmd/wp-docker-buildx/main.go b/cmd/wp-docker-buildx/main.go new file mode 100644 index 0000000..7fba150 --- /dev/null +++ b/cmd/wp-docker-buildx/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "errors" + "fmt" + + "github.com/thegeeklab/wp-docker-buildx/plugin" + + wp "github.com/thegeeklab/wp-plugin-go/plugin" +) + +//nolint:gochecknoglobals +var ( + BuildVersion = "devel" + BuildDate = "00000000" +) + +var ErrTypeAssertionFailed = errors.New("type assertion failed") + +func main() { + settings := &plugin.Settings{} + options := wp.Options{ + Name: "wp-docker-buildx", + Description: "Build OCI container with DinD and buildx", + Version: BuildVersion, + VersionMetadata: fmt.Sprintf("date=%s", BuildDate), + Flags: settingsFlags(settings, wp.FlagsPluginCategory), + } + + plugin.New(options, settings).Run() +} diff --git a/go.mod b/go.mod index 4557394..3736930 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,21 @@ -module github.com/thegeeklab/drone-docker-buildx +module github.com/thegeeklab/wp-docker-buildx go 1.20 require ( github.com/coreos/go-semver v0.3.1 - github.com/joho/godotenv v1.5.1 - github.com/sirupsen/logrus v1.9.3 - github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4 - github.com/urfave/cli/v2 v2.25.5 + github.com/rs/zerolog v1.30.0 + github.com/thegeeklab/wp-plugin-go v0.0.0-20230813200355-be61f319f791 + github.com/urfave/cli/v2 v2.25.7 golang.org/x/sys v0.11.0 ) require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/joho/godotenv v1.5.1 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 4bb7288..038ce5c 100644 --- a/go.sum +++ b/go.sum @@ -1,31 +1,35 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -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/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= 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/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -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/thegeeklab/wp-plugin-go v0.0.0-20230813123155-c2338b40b883 h1:Q9AQZgj8bdFxNTkngJfthDSc911Cz4LioPUFLMxzhYI= +github.com/thegeeklab/wp-plugin-go v0.0.0-20230813123155-c2338b40b883/go.mod h1:7PWAZiTnZ2fAvjsedopQJ6w873KuSxUWsAml1Yib8a0= +github.com/thegeeklab/wp-plugin-go v0.0.0-20230813200355-be61f319f791 h1:tgFeRHdH/VXqpT4ChAuAWKXmiMcF24sQd7C7TYTEJUA= +github.com/thegeeklab/wp-plugin-go v0.0.0-20230813200355-be61f319f791/go.mod h1:7PWAZiTnZ2fAvjsedopQJ6w873KuSxUWsAml1Yib8a0= +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/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/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/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= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -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= diff --git a/plugin/coredns.go b/plugin/coredns.go index 2178706..1f727fa 100644 --- a/plugin/coredns.go +++ b/plugin/coredns.go @@ -9,7 +9,7 @@ import ( func (p Plugin) startCoredns() { cmd := exec.Command("coredns", "-conf", "/etc/coredns/Corefile") - if p.settings.Daemon.Debug { + if p.Settings.Daemon.Debug { cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr } else { diff --git a/plugin/daemon.go b/plugin/daemon.go index ff15dc4..b25bd8c 100644 --- a/plugin/daemon.go +++ b/plugin/daemon.go @@ -13,8 +13,8 @@ const ( ) func (p Plugin) startDaemon() { - cmd := commandDaemon(p.settings.Daemon) - if p.settings.Daemon.Debug { + cmd := commandDaemon(p.Settings.Daemon) + if p.Settings.Daemon.Debug { cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr } else { diff --git a/plugin/impl.go b/plugin/impl.go index 6651bac..6015b59 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -1,108 +1,75 @@ package plugin import ( + "context" + "errors" "fmt" "os" "path/filepath" "time" - "github.com/sirupsen/logrus" + "github.com/rs/zerolog/log" + wp "github.com/thegeeklab/wp-plugin-go/plugin" "github.com/urfave/cli/v2" "golang.org/x/sys/execabs" ) -// 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 -} +var ErrTypeAssertionFailed = errors.New("type assertion failed") -// Login defines Docker login parameters. -type Login struct { - Registry string // Docker registry address - Username string // Docker registry username - Password string // Docker registry password - Email string // Docker registry email - Config string // Docker Auth Config -} +const strictFilePerm = 0o600 -// Build defines Docker build parameters. -type Build struct { - Ref string // Git commit ref - Branch string // Git repository branch - Dockerfile string // Docker build Dockerfile - Context string // Docker build context - TagsAuto bool // Docker build auto tag - TagsSuffix string // Docker build tags with suffix - Tags cli.StringSlice // Docker build tags - ExtraTags cli.StringSlice // Docker build tags including registry - Platforms cli.StringSlice // Docker build target platforms - Args cli.StringSlice // Docker build args - ArgsEnv cli.StringSlice // Docker build args from env - Target string // Docker build target - Pull bool // Docker build pull - CacheFrom []string // Docker build cache-from - CacheTo string // Docker build cache-to - Compress bool // Docker build compress - Repo string // Docker build repository - NoCache bool // Docker build no-cache - AddHost cli.StringSlice // Docker build add-host - Quiet bool // Docker build quiet - Output string // Docker build output folder - NamedContext cli.StringSlice // Docker build named context - Labels cli.StringSlice // Docker build labels - Provenance string // Docker build provenance attestation - SBOM string // Docker build sbom attestation - Secrets []string // Docker build secrets -} +// Execute provides the implementation of the plugin. +// +//nolint:revive +func (p *Plugin) run(ctx context.Context, cCtx *cli.Context) error { + cacheFrom, ok := cCtx.Generic("cache-from").(*wp.StringSliceFlag) + if !ok { + return fmt.Errorf("%w: failed to read cache-from input", ErrTypeAssertionFailed) + } -// Settings for the Plugin. -type Settings struct { - Daemon Daemon - Login Login - Build Build - Dryrun bool -} + p.Settings.Build.CacheFrom = cacheFrom.Get() -const strictFilePerm = 0o600 + secrets, ok := cCtx.Generic("secrets").(*wp.StringSliceFlag) + if !ok { + return fmt.Errorf("%w: failed to read secrets input", ErrTypeAssertionFailed) + } + + p.Settings.Build.Secrets = secrets.Get() + + if err := p.Validate(); err != nil { + return fmt.Errorf("validation failed: %w", err) + } + + if err := p.Execute(); err != nil { + return fmt.Errorf("execution failed: %w", err) + } + + return nil +} // Validate handles the settings validation of the plugin. func (p *Plugin) Validate() error { - p.settings.Build.Branch = p.pipeline.Repo.Branch - p.settings.Build.Ref = p.pipeline.Commit.Ref - p.settings.Daemon.Registry = p.settings.Login.Registry + p.Settings.Build.Branch = p.Metadata.Repository.Branch + p.Settings.Build.Ref = p.Metadata.Curr.Ref + p.Settings.Daemon.Registry = p.Settings.Login.Registry - if p.settings.Build.TagsAuto { + if p.Settings.Build.TagsAuto { // return true if tag event or default branch if UseDefaultTag( - p.settings.Build.Ref, - p.settings.Build.Branch, + p.Settings.Build.Ref, + p.Settings.Build.Branch, ) { tag, err := DefaultTagSuffix( - p.settings.Build.Ref, - p.settings.Build.TagsSuffix, + p.Settings.Build.Ref, + p.Settings.Build.TagsSuffix, ) if err != nil { - logrus.Infof("cannot generate tags from %s, invalid semantic version", p.settings.Build.Ref) - - return err + return fmt.Errorf("cannot generate tags from %s, invalid semantic version: %w", p.Settings.Build.Ref, err) } - p.settings.Build.Tags = *cli.NewStringSlice(tag...) + p.Settings.Build.Tags = *cli.NewStringSlice(tag...) } else { - logrus.Infof("skip auto-tagging for %s, not on default branch or tag", p.settings.Build.Ref) + log.Info().Msgf("skip auto-tagging for %s, not on default branch or tag", p.Settings.Build.Ref) return nil } @@ -117,19 +84,19 @@ func (p *Plugin) Validate() error { func (p *Plugin) Execute() error { // start the Docker daemon server //nolint: nestif - if !p.settings.Daemon.Disabled { + if !p.Settings.Daemon.Disabled { // If no custom DNS value set start internal DNS server - if len(p.settings.Daemon.DNS.Value()) == 0 { + if len(p.Settings.Daemon.DNS.Value()) == 0 { ip, err := getContainerIP() if err != nil { - logrus.Warnf("error detecting IP address: %v", err) + log.Warn().Msgf("error detecting IP address: %v", err) } if ip != "" { - logrus.Debugf("discovered IP address: %v", ip) + log.Debug().Msgf("discovered IP address: %v", ip) p.startCoredns() - if err := p.settings.Daemon.DNS.Set(ip); err != nil { + if err := p.Settings.Daemon.DNS.Set(ip); err != nil { return fmt.Errorf("error setting daemon dns: %w", err) } } @@ -152,22 +119,22 @@ func (p *Plugin) Execute() error { } // Create Auth Config File - if p.settings.Login.Config != "" { + if p.Settings.Login.Config != "" { if err := os.MkdirAll(dockerHome, strictFilePerm); err != nil { return fmt.Errorf("failed to create docker home: %w", err) } path := filepath.Join(dockerHome, "config.json") - err := os.WriteFile(path, []byte(p.settings.Login.Config), strictFilePerm) + err := os.WriteFile(path, []byte(p.Settings.Login.Config), strictFilePerm) if err != nil { return fmt.Errorf("error writing config.json: %w", err) } } // login to the Docker registry - if p.settings.Login.Password != "" { - cmd := commandLogin(p.settings.Login) + if p.Settings.Login.Password != "" { + cmd := commandLogin(p.Settings.Login) err := cmd.Run() if err != nil { @@ -175,32 +142,32 @@ func (p *Plugin) Execute() error { } } - if p.settings.Daemon.BuildkitConfig != "" { - err := os.WriteFile(buildkitConfig, []byte(p.settings.Daemon.BuildkitConfig), strictFilePerm) + if p.Settings.Daemon.BuildkitConfig != "" { + err := os.WriteFile(buildkitConfig, []byte(p.Settings.Daemon.BuildkitConfig), strictFilePerm) if err != nil { return fmt.Errorf("error writing buildkit.toml: %w", err) } } switch { - case p.settings.Login.Password != "": - logrus.Info("Detected registry credentials") - case p.settings.Login.Config != "": - logrus.Info("Detected registry credentials file") + case p.Settings.Login.Password != "": + log.Info().Msgf("Detected registry credentials") + case p.Settings.Login.Config != "": + log.Info().Msgf("Detected registry credentials file") default: - logrus.Info("Registry credentials or Docker config not provided. Guest mode enabled.") + log.Info().Msgf("Registry credentials or Docker config not provided. Guest mode enabled.") } // add proxy build args - addProxyBuildArgs(&p.settings.Build) + addProxyBuildArgs(&p.Settings.Build) var cmds []*execabs.Cmd cmds = append(cmds, commandVersion()) // docker version cmds = append(cmds, commandInfo()) // docker info - cmds = append(cmds, commandBuilder(p.settings.Daemon)) + cmds = append(cmds, commandBuilder(p.Settings.Daemon)) cmds = append(cmds, commandBuildx()) - cmds = append(cmds, commandBuild(p.settings.Build, p.settings.Dryrun)) // docker build + cmds = append(cmds, commandBuild(p.Settings.Build, p.Settings.Dryrun)) // docker build // execute all commands in batch mode. for _, cmd := range cmds { diff --git a/plugin/plugin.go b/plugin/plugin.go index 85551fc..b8ef6e8 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -1,21 +1,88 @@ package plugin import ( - "github.com/thegeeklab/drone-plugin-lib/v2/drone" + wp "github.com/thegeeklab/wp-plugin-go/plugin" + "github.com/urfave/cli/v2" ) -// Plugin implements drone.Plugin to provide the plugin implementation. +// Plugin implements provide the plugin implementation. type Plugin struct { - settings Settings - pipeline drone.Pipeline - network drone.Network + *wp.Plugin + Settings *Settings } -// New initializes a plugin from the given Settings, Pipeline, and Network. -func New(settings Settings, pipeline drone.Pipeline, network drone.Network) *Plugin { - return &Plugin{ - settings: settings, - pipeline: pipeline, - network: network, - } +// Settings for the Plugin. +type Settings struct { + Daemon Daemon + Login Login + Build Build + Dryrun bool +} + +// 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 +} + +// Login defines Docker login parameters. +type Login struct { + Registry string // Docker registry address + Username string // Docker registry username + Password string // Docker registry password + Email string // Docker registry email + Config string // Docker Auth Config +} + +// Build defines Docker build parameters. +type Build struct { + Ref string // Git commit ref + Branch string // Git repository branch + Dockerfile string // Docker build Dockerfile + Context string // Docker build context + TagsAuto bool // Docker build auto tag + TagsSuffix string // Docker build tags with suffix + Tags cli.StringSlice // Docker build tags + ExtraTags cli.StringSlice // Docker build tags including registry + Platforms cli.StringSlice // Docker build target platforms + Args cli.StringSlice // Docker build args + ArgsEnv cli.StringSlice // Docker build args from env + Target string // Docker build target + Pull bool // Docker build pull + CacheFrom []string // Docker build cache-from + CacheTo string // Docker build cache-to + Compress bool // Docker build compress + Repo string // Docker build repository + NoCache bool // Docker build no-cache + AddHost cli.StringSlice // Docker build add-host + Quiet bool // Docker build quiet + Output string // Docker build output folder + NamedContext cli.StringSlice // Docker build named context + Labels cli.StringSlice // Docker build labels + Provenance string // Docker build provenance attestation + SBOM string // Docker build sbom attestation + Secrets []string // Docker build secrets +} + +func New(options wp.Options, settings *Settings) *Plugin { + p := &Plugin{} + + options.Execute = p.run + + p.Plugin = wp.New(options) + p.Settings = settings + + return p }