From d8b6b48fa34561c16680cc5787ab97b3f18b2141 Mon Sep 17 00:00:00 2001 From: Roman Voitenko Date: Wed, 30 Sep 2020 23:32:23 +0200 Subject: [PATCH 01/27] add possibility to turn on ECR image scanning for repos created by ecr plugin --- cmd/drone-ecr/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/drone-ecr/main.go b/cmd/drone-ecr/main.go index 5f1e83e..c8e512b 100644 --- a/cmd/drone-ecr/main.go +++ b/cmd/drone-ecr/main.go @@ -37,6 +37,7 @@ func main() { lifecyclePolicy = getenv("PLUGIN_LIFECYCLE_POLICY") repositoryPolicy = getenv("PLUGIN_REPOSITORY_POLICY") assumeRole = getenv("PLUGIN_ASSUME_ROLE") + scanOnPush = parseBoolOrDefault(false, getenv("PLUGIN_SCAN_ON_PUSH")) ) // set the region @@ -72,7 +73,7 @@ func main() { } if create { - err = ensureRepoExists(svc, trimHostname(repo, registry)) + err = ensureRepoExists(svc, trimHostname(repo, registry), scanOnPush) if err != nil { log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err)) } @@ -118,9 +119,10 @@ func trimHostname(repo, registry string) string { return repo } -func ensureRepoExists(svc *ecr.ECR, name string) (err error) { +func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) { input := &ecr.CreateRepositoryInput{} input.SetRepositoryName(name) + input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush}) _, err = svc.CreateRepository(input) if err != nil { if aerr, ok := err.(awserr.Error); ok && aerr.Code() == ecr.ErrCodeRepositoryAlreadyExistsException { From 3501d9a65d0f773b01cf2c1a50d13a7726bca166 Mon Sep 17 00:00:00 2001 From: Roman Voitenko Date: Thu, 1 Oct 2020 10:43:25 +0200 Subject: [PATCH 02/27] add possibility to turn on/off image scanning not only during repo creation, but when repo already created --- cmd/drone-ecr/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/drone-ecr/main.go b/cmd/drone-ecr/main.go index c8e512b..9de37a1 100644 --- a/cmd/drone-ecr/main.go +++ b/cmd/drone-ecr/main.go @@ -77,6 +77,10 @@ func main() { if err != nil { log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err)) } + err = updateImageScannningConfig(svc, trimHostname(repo, registry), scanOnPush) + if err != nil { + log.Fatal(fmt.Sprintf("error updating scan on push for ECR repo: %v", err)) + } } if lifecyclePolicy != "" { @@ -134,6 +138,15 @@ func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) { return } +func updateImageScannningConfig(svc *ecr.ECR, name string, scanOnPush bool) (err error) { + input := &ecr.PutImageScanningConfigurationInput{} + input.SetRepositoryName(name) + input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush}) + _, err = svc.PutImageScanningConfiguration(input) + + return err +} + func uploadLifeCyclePolicy(svc *ecr.ECR, lifecyclePolicy string, name string) (err error) { input := &ecr.PutLifecyclePolicyInput{} input.SetLifecyclePolicyText(lifecyclePolicy) From db5c2161febe6292386d9dc7dd8e20047219d15e Mon Sep 17 00:00:00 2001 From: TP Honey Date: Wed, 7 Jul 2021 19:37:30 +0100 Subject: [PATCH 03/27] (maint) CI, remove the dry run steps, due to rate limiting --- .drone.yml | 255 ----------------------------------------------------- 1 file changed, 255 deletions(-) diff --git a/.drone.yml b/.drone.yml index c774150..41c8676 100644 --- a/.drone.yml +++ b/.drone.yml @@ -193,23 +193,6 @@ steps: commands: - ./release/linux/amd64/drone-docker --help -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/docker/Dockerfile.linux.amd64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/docker - tags: linux-amd64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -277,23 +260,6 @@ steps: commands: - ./release/linux/arm64/drone-docker --help -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/docker/Dockerfile.linux.arm64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/docker - tags: linux-arm64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -361,23 +327,6 @@ steps: commands: - ./release/linux/arm/drone-docker --help -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/docker/Dockerfile.linux.arm - dry_run: true - password: - from_secret: docker_password - repo: plugins/docker - tags: linux-arm - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -481,23 +430,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/gcr/Dockerfile.linux.amd64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/gcr - tags: linux-amd64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -559,23 +491,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/gcr/Dockerfile.linux.arm64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/gcr - tags: linux-arm64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -637,23 +552,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/gcr/Dockerfile.linux.arm - dry_run: true - password: - from_secret: docker_password - repo: plugins/gcr - tags: linux-arm - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -754,23 +652,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/ecr/Dockerfile.linux.amd64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/ecr - tags: linux-amd64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -832,23 +713,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/ecr/Dockerfile.linux.arm64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/ecr - tags: linux-arm64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -910,23 +774,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/ecr/Dockerfile.linux.arm - dry_run: true - password: - from_secret: docker_password - repo: plugins/ecr - tags: linux-arm - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -1027,23 +874,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/heroku/Dockerfile.linux.amd64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/heroku - tags: linux-amd64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -1105,23 +935,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/heroku/Dockerfile.linux.arm64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/heroku - tags: linux-arm64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -1183,23 +996,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/heroku/Dockerfile.linux.arm - dry_run: true - password: - from_secret: docker_password - repo: plugins/heroku - tags: linux-arm - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -1300,23 +1096,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/acr/Dockerfile.linux.amd64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/acr - tags: linux-amd64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -1378,23 +1157,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/acr/Dockerfile.linux.arm64 - dry_run: true - password: - from_secret: docker_password - repo: plugins/acr - tags: linux-arm64 - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 @@ -1456,23 +1218,6 @@ steps: event: - tag -- name: dryrun - pull: always - image: plugins/docker:18 - settings: - daemon_off: false - dockerfile: docker/acr/Dockerfile.linux.arm - dry_run: true - password: - from_secret: docker_password - repo: plugins/acr - tags: linux-arm - username: - from_secret: docker_username - when: - event: - - pull_request - - name: publish pull: always image: plugins/docker:18 From dd359dfc7242b257f0f2078f1ef9027391d0bd0a Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 7 Jul 2021 15:03:54 -0400 Subject: [PATCH 04/27] Update seccomp to 20.10 docker (#322) * Update seccomp to 20.10 docker --- docker/docker/Dockerfile.linux.amd64 | 9 +++++++++ docker/docker/Dockerfile.linux.arm | 2 +- docker/docker/Dockerfile.linux.arm64 | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docker/docker/Dockerfile.linux.amd64 b/docker/docker/Dockerfile.linux.amd64 index c39c578..35dba3f 100644 --- a/docker/docker/Dockerfile.linux.amd64 +++ b/docker/docker/Dockerfile.linux.amd64 @@ -2,5 +2,14 @@ FROM docker:19.03.8-dind ENV DOCKER_HOST=unix:///var/run/docker.sock +RUN apk --update add --virtual .build-deps curl && \ + mkdir -p /etc/docker/ && \ + curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/20.10/profiles/seccomp/default.json && \ + sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \ + chmod 600 /etc/docker/default.json && \ + apk del .build-deps && \ + rm -rf /var/cache/apk/* && \ + rm -rf /tmp/* + ADD release/linux/amd64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] diff --git a/docker/docker/Dockerfile.linux.arm b/docker/docker/Dockerfile.linux.arm index 38c8992..ace5a37 100644 --- a/docker/docker/Dockerfile.linux.arm +++ b/docker/docker/Dockerfile.linux.arm @@ -4,7 +4,7 @@ ENV DOCKER_HOST=unix:///var/run/docker.sock RUN apk --update add --virtual .build-deps curl && \ mkdir -p /etc/docker/ && \ - curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/19.03/profiles/seccomp/default.json && \ + curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/20.10/profiles/seccomp/default.json && \ sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \ chmod 600 /etc/docker/default.json && \ apk del .build-deps && \ diff --git a/docker/docker/Dockerfile.linux.arm64 b/docker/docker/Dockerfile.linux.arm64 index 2a70c6a..e46b222 100644 --- a/docker/docker/Dockerfile.linux.arm64 +++ b/docker/docker/Dockerfile.linux.arm64 @@ -2,5 +2,14 @@ FROM arm64v8/docker:19.03.8-dind ENV DOCKER_HOST=unix:///var/run/docker.sock +RUN apk --update add --virtual .build-deps curl && \ + mkdir -p /etc/docker/ && \ + curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/20.10/profiles/seccomp/default.json && \ + sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \ + chmod 600 /etc/docker/default.json && \ + apk del .build-deps && \ + rm -rf /var/cache/apk/* && \ + rm -rf /tmp/* + ADD release/linux/arm64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] From c10d36754ccf53341f462a2e9f703315cc31f0cf Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sun, 11 Jul 2021 15:38:04 -0400 Subject: [PATCH 05/27] Revert "Update seccomp to 20.10 docker (#322)" This reverts commit dd359dfc7242b257f0f2078f1ef9027391d0bd0a. --- docker/docker/Dockerfile.linux.amd64 | 9 --------- docker/docker/Dockerfile.linux.arm | 2 +- docker/docker/Dockerfile.linux.arm64 | 9 --------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/docker/docker/Dockerfile.linux.amd64 b/docker/docker/Dockerfile.linux.amd64 index 35dba3f..c39c578 100644 --- a/docker/docker/Dockerfile.linux.amd64 +++ b/docker/docker/Dockerfile.linux.amd64 @@ -2,14 +2,5 @@ FROM docker:19.03.8-dind ENV DOCKER_HOST=unix:///var/run/docker.sock -RUN apk --update add --virtual .build-deps curl && \ - mkdir -p /etc/docker/ && \ - curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/20.10/profiles/seccomp/default.json && \ - sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \ - chmod 600 /etc/docker/default.json && \ - apk del .build-deps && \ - rm -rf /var/cache/apk/* && \ - rm -rf /tmp/* - ADD release/linux/amd64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] diff --git a/docker/docker/Dockerfile.linux.arm b/docker/docker/Dockerfile.linux.arm index ace5a37..38c8992 100644 --- a/docker/docker/Dockerfile.linux.arm +++ b/docker/docker/Dockerfile.linux.arm @@ -4,7 +4,7 @@ ENV DOCKER_HOST=unix:///var/run/docker.sock RUN apk --update add --virtual .build-deps curl && \ mkdir -p /etc/docker/ && \ - curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/20.10/profiles/seccomp/default.json && \ + curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/19.03/profiles/seccomp/default.json && \ sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \ chmod 600 /etc/docker/default.json && \ apk del .build-deps && \ diff --git a/docker/docker/Dockerfile.linux.arm64 b/docker/docker/Dockerfile.linux.arm64 index e46b222..2a70c6a 100644 --- a/docker/docker/Dockerfile.linux.arm64 +++ b/docker/docker/Dockerfile.linux.arm64 @@ -2,14 +2,5 @@ FROM arm64v8/docker:19.03.8-dind ENV DOCKER_HOST=unix:///var/run/docker.sock -RUN apk --update add --virtual .build-deps curl && \ - mkdir -p /etc/docker/ && \ - curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/20.10/profiles/seccomp/default.json && \ - sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \ - chmod 600 /etc/docker/default.json && \ - apk del .build-deps && \ - rm -rf /var/cache/apk/* && \ - rm -rf /tmp/* - ADD release/linux/arm64/drone-docker /bin/ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"] From d4cf9f20f175ae550b11e0eeb44604c6d71bee20 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sun, 11 Jul 2021 15:50:43 -0400 Subject: [PATCH 06/27] remove pull always --- .drone.yml | 95 ------------------------------------------------------ 1 file changed, 95 deletions(-) diff --git a/.drone.yml b/.drone.yml index 41c8676..7f43290 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,6 @@ platform: steps: - name: vet - pull: always image: golang:1.11 commands: - go vet ./... @@ -19,7 +18,6 @@ steps: path: /go - name: test - pull: always image: golang:1.11 commands: - go test -cover ./... @@ -163,7 +161,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker" @@ -176,7 +173,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker" @@ -188,13 +184,11 @@ steps: - tag - name: executable - pull: always image: golang:1.11 commands: - ./release/linux/amd64/drone-docker --help - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -230,7 +224,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker" @@ -243,7 +236,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker" @@ -255,13 +247,11 @@ steps: - tag - name: executable - pull: always image: golang:1.11 commands: - ./release/linux/arm64/drone-docker --help - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -297,7 +287,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-docker ./cmd/drone-docker" @@ -310,7 +299,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-docker ./cmd/drone-docker" @@ -322,13 +310,11 @@ steps: - tag - name: executable - pull: always image: golang:1.11 commands: - ./release/linux/arm/drone-docker --help - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -364,7 +350,6 @@ platform: steps: - name: manifest - pull: always image: plugins/manifest settings: auto_tag: true @@ -375,14 +360,6 @@ steps: username: from_secret: docker_username -- name: microbadger - pull: always - image: plugins/webhook - failure: ignore - settings: - urls: - from_secret: microbadger_docker - trigger: ref: - refs/heads/master @@ -406,7 +383,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr" @@ -419,7 +395,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr" @@ -431,7 +406,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -467,7 +441,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr" @@ -480,7 +453,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr" @@ -492,7 +464,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -528,7 +499,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gcr ./cmd/drone-gcr" @@ -541,7 +511,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gcr ./cmd/drone-gcr" @@ -553,7 +522,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -589,7 +557,6 @@ platform: steps: - name: manifest - pull: always image: plugins/manifest settings: auto_tag: true @@ -600,14 +567,6 @@ steps: username: from_secret: docker_username -- name: microbadger - pull: always - image: plugins/webhook - failure: ignore - settings: - urls: - from_secret: microbadger_gcr - trigger: ref: - refs/heads/master @@ -628,7 +587,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr" @@ -641,7 +599,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr" @@ -653,7 +610,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -689,7 +645,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr" @@ -702,7 +657,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr" @@ -714,7 +668,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -750,7 +703,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-ecr ./cmd/drone-ecr" @@ -763,7 +715,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-ecr ./cmd/drone-ecr" @@ -775,7 +726,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -811,7 +761,6 @@ platform: steps: - name: manifest - pull: always image: plugins/manifest settings: auto_tag: true @@ -822,14 +771,6 @@ steps: username: from_secret: docker_username -- name: microbadger - pull: always - image: plugins/webhook - failure: ignore - settings: - urls: - from_secret: microbadger_ecr - trigger: ref: - refs/heads/master @@ -850,7 +791,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku" @@ -863,7 +803,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku" @@ -875,7 +814,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -911,7 +849,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku" @@ -924,7 +861,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku" @@ -936,7 +872,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -972,7 +907,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-heroku ./cmd/drone-heroku" @@ -985,7 +919,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-heroku ./cmd/drone-heroku" @@ -997,7 +930,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -1033,7 +965,6 @@ platform: steps: - name: manifest - pull: always image: plugins/manifest settings: auto_tag: true @@ -1044,14 +975,6 @@ steps: username: from_secret: docker_username -- name: microbadger - pull: always - image: plugins/webhook - failure: ignore - settings: - urls: - from_secret: microbadger_heroku - trigger: ref: - refs/heads/master @@ -1072,7 +995,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr" @@ -1085,7 +1007,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr" @@ -1097,7 +1018,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -1133,7 +1053,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr" @@ -1146,7 +1065,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr" @@ -1158,7 +1076,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -1194,7 +1111,6 @@ platform: steps: - name: build-push - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr" @@ -1207,7 +1123,6 @@ steps: - tag - name: build-tag - pull: always image: golang:1.11 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr" @@ -1219,7 +1134,6 @@ steps: - tag - name: publish - pull: always image: plugins/docker:18 settings: auto_tag: true @@ -1255,7 +1169,6 @@ platform: steps: - name: manifest - pull: always image: plugins/manifest settings: ignore_missing: true @@ -1265,14 +1178,6 @@ steps: username: from_secret: docker_username -- name: microbadger - pull: always - image: plugins/webhook - failure: ignore - settings: - url: - from_secret: microbadger_acr - trigger: ref: - refs/heads/master From b1d8698d1c5eb834b0703939e1001d23152300d2 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 2 Aug 2021 21:28:37 -0400 Subject: [PATCH 07/27] print login failure reason to output --- docker.go | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/docker.go b/docker.go index a947e24..ed46d96 100644 --- a/docker.go +++ b/docker.go @@ -39,26 +39,26 @@ type ( // Build defines Docker build parameters. Build struct { - Remote string // Git remote URL - Name string // Docker build using default named tag - Dockerfile string // Docker build Dockerfile - Context string // Docker build context - Tags []string // Docker build tags - Args []string // Docker build args - ArgsEnv []string // Docker build args from env - Target string // Docker build target - Squash bool // Docker build squash - Pull bool // Docker build pull - CacheFrom []string // Docker build cache-from - Compress bool // Docker build compress - Repo string // Docker build repository - LabelSchema []string // label-schema Label map - AutoLabel bool // auto-label bool - Labels []string // Label map - Link string // Git repo link - NoCache bool // Docker build no-cache - AddHost []string // Docker build add-host - Quiet bool // Docker build quiet + Remote string // Git remote URL + Name string // Docker build using default named tag + Dockerfile string // Docker build Dockerfile + Context string // Docker build context + Tags []string // Docker build tags + Args []string // Docker build args + ArgsEnv []string // Docker build args from env + Target string // Docker build target + Squash bool // Docker build squash + Pull bool // Docker build pull + CacheFrom []string // Docker build cache-from + Compress bool // Docker build compress + Repo string // Docker build repository + LabelSchema []string // label-schema Label map + AutoLabel bool // auto-label bool + Labels []string // Label map + Link string // Git repo link + NoCache bool // Docker build no-cache + AddHost []string // Docker build add-host + Quiet bool // Docker build quiet } // Plugin defines the Docker plugin parameters. @@ -80,12 +80,16 @@ func (p Plugin) Exec() error { // poll the docker daemon until it is started. This ensures the daemon is // ready to accept connections before we proceed. - for i := 0; i < 15; i++ { + for i := 0; ; i++ { cmd := commandInfo() err := cmd.Run() if err == nil { break } + if i == 15 { + fmt.Println("Unable to reach Docker Daemon after 15 attempts.") + break + } time.Sleep(time.Second * 1) } @@ -103,9 +107,12 @@ func (p Plugin) Exec() error { // login to the Docker registry if p.Login.Password != "" { cmd := commandLogin(p.Login) - err := cmd.Run() + raw, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("Error authenticating: %s", err) + out := string(raw) + out = strings.ReplaceAll(out, "WARNING! Using --password via the CLI is insecure. Use --password-stdin.", "") + fmt.Println(out) + return fmt.Errorf("Error authenticating: exit status 1") } } From fbbeec5a2e5845e488100da3885dc630fa3468fe Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 2 Aug 2021 21:42:22 -0400 Subject: [PATCH 08/27] use Replace instead of ReplaceAll --- docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker.go b/docker.go index ed46d96..08dff98 100644 --- a/docker.go +++ b/docker.go @@ -110,7 +110,7 @@ func (p Plugin) Exec() error { raw, err := cmd.CombinedOutput() if err != nil { out := string(raw) - out = strings.ReplaceAll(out, "WARNING! Using --password via the CLI is insecure. Use --password-stdin.", "") + out = strings.Replace(out, "WARNING! Using --password via the CLI is insecure. Use --password-stdin.", "", -1) fmt.Println(out) return fmt.Errorf("Error authenticating: exit status 1") } From 72ef7b1f3fa6c47c58f33ca312bdc8c484b6c5a4 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 2 Aug 2021 22:15:39 -0400 Subject: [PATCH 09/27] log available credentials before login --- docker.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docker.go b/docker.go index 08dff98..9effe4c 100644 --- a/docker.go +++ b/docker.go @@ -93,7 +93,20 @@ func (p Plugin) Exec() error { time.Sleep(time.Second * 1) } - // Create Auth Config File + // for debugging purposes, log the type of authentication + // credentials that have been provided. + switch { + case p.Login.Password != "" && p.Login.Config != "": + fmt.Println("Detected registry credentials and registry credentials file") + case p.Login.Password != "": + fmt.Println("Detected registry credentials") + case p.Login.Config != "": + fmt.Println("Detected registry credentials file") + default: + fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.") + } + + // create Auth Config File if p.Login.Config != "" { os.MkdirAll(dockerHome, 0600) @@ -116,15 +129,6 @@ func (p Plugin) Exec() error { } } - switch { - case p.Login.Password != "": - fmt.Println("Detected registry credentials") - case p.Login.Config != "": - fmt.Println("Detected registry credentials file") - default: - fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.") - } - if p.Build.Squash && !p.Daemon.Experimental { fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...") p.Build.Squash = false From e44c2d46eafd5f223ac246eb003bc6b3427b3374 Mon Sep 17 00:00:00 2001 From: Jim Sheldon Date: Fri, 17 Sep 2021 15:33:05 -0400 Subject: [PATCH 10/27] adding support for externalId --- cmd/drone-ecr/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd/drone-ecr/main.go b/cmd/drone-ecr/main.go index 9de37a1..07450c3 100644 --- a/cmd/drone-ecr/main.go +++ b/cmd/drone-ecr/main.go @@ -37,6 +37,7 @@ func main() { lifecyclePolicy = getenv("PLUGIN_LIFECYCLE_POLICY") repositoryPolicy = getenv("PLUGIN_REPOSITORY_POLICY") assumeRole = getenv("PLUGIN_ASSUME_ROLE") + externalId = getenv("PLUGIN_EXTERNAL_ID") scanOnPush = parseBoolOrDefault(false, getenv("PLUGIN_SCAN_ON_PUSH")) ) @@ -57,7 +58,7 @@ func main() { log.Fatal(fmt.Sprintf("error creating aws session: %v", err)) } - svc := getECRClient(sess, assumeRole) + svc := getECRClient(sess, assumeRole, externalId) username, password, defaultRegistry, err := getAuthInfo(svc) if registry == "" { @@ -208,11 +209,19 @@ func getenv(key ...string) (s string) { return } -func getECRClient(sess *session.Session, role string) *ecr.ECR { +func getECRClient(sess *session.Session, role string, externalId string) *ecr.ECR { if role == "" { return ecr.New(sess) } - return ecr.New(sess, &aws.Config{ - Credentials: stscreds.NewCredentials(sess, role), - }) + if externalId != "" { + return ecr.New(sess, &aws.Config{ + Credentials: stscreds.NewCredentials(sess, role, func(p *stscreds.AssumeRoleProvider) { + p.ExternalID = &externalId + }), + }) + } else { + return ecr.New(sess, &aws.Config{ + Credentials: stscreds.NewCredentials(sess, role), + }) + } } From 2d70a1fa7cb4a8f2afe38cad3a1984804f1df464 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Wed, 13 Oct 2021 14:24:58 +0100 Subject: [PATCH 11/27] (maint) v19.03.9 release prep --- .github_changelog_generator | 2 ++ CHANGELOG.md | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github_changelog_generator create mode 100644 CHANGELOG.md diff --git a/.github_changelog_generator b/.github_changelog_generator new file mode 100644 index 0000000..155179e --- /dev/null +++ b/.github_changelog_generator @@ -0,0 +1,2 @@ +since-tag=v19.03.8 + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b811d75 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Changelog + +## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13) + +[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.8...v19.03.9) + +**Implemented enhancements:** + +- adding support for externalId [\#333](https://github.com/drone-plugins/drone-docker/pull/333) ([jimsheldon](https://github.com/jimsheldon)) +- Add support for automatic opencontainer labels [\#313](https://github.com/drone-plugins/drone-docker/pull/313) ([codrut-fc](https://github.com/codrut-fc)) +- add custom seccomp profile [\#312](https://github.com/drone-plugins/drone-docker/pull/312) ([xoxys](https://github.com/xoxys)) +- ECR: adding setting to enable image scanning while repo creation [\#300](https://github.com/drone-plugins/drone-docker/pull/300) ([rvoitenko](https://github.com/rvoitenko)) + +**Fixed bugs:** + +- Revert "Update seccomp to 20.10 docker" [\#325](https://github.com/drone-plugins/drone-docker/pull/325) ([bradrydzewski](https://github.com/bradrydzewski)) + +**Merged pull requests:** + +- \(maint\) CI, remove the dry run steps, due to rate limiting [\#323](https://github.com/drone-plugins/drone-docker/pull/323) ([tphoney](https://github.com/tphoney)) +- Update seccomp to 20.10 docker [\#322](https://github.com/drone-plugins/drone-docker/pull/322) ([techknowlogick](https://github.com/techknowlogick)) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* From 0911e6a922663d52e1d9e4dfdee51a383d2b95fa Mon Sep 17 00:00:00 2001 From: TP Honey Date: Wed, 13 Oct 2021 14:49:29 +0100 Subject: [PATCH 12/27] (maint) bump git to 1.13 for build and test --- .drone.yml | 70 +++++++++++++++++++++++----------------------- pipeline.libsonnet | 2 +- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7f43290..fba5719 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ platform: steps: - name: vet - image: golang:1.11 + image: golang:1.13 commands: - go vet ./... environment: @@ -18,7 +18,7 @@ steps: path: /go - name: test - image: golang:1.11 + image: golang:1.13 commands: - go test -cover ./... environment: @@ -161,7 +161,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker" environment: @@ -173,7 +173,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker" environment: @@ -184,7 +184,7 @@ steps: - tag - name: executable - image: golang:1.11 + image: golang:1.13 commands: - ./release/linux/amd64/drone-docker --help @@ -224,7 +224,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker" environment: @@ -236,7 +236,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker" environment: @@ -247,7 +247,7 @@ steps: - tag - name: executable - image: golang:1.11 + image: golang:1.13 commands: - ./release/linux/arm64/drone-docker --help @@ -287,7 +287,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-docker ./cmd/drone-docker" environment: @@ -299,7 +299,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-docker ./cmd/drone-docker" environment: @@ -310,7 +310,7 @@ steps: - tag - name: executable - image: golang:1.11 + image: golang:1.13 commands: - ./release/linux/arm/drone-docker --help @@ -383,7 +383,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr" environment: @@ -395,7 +395,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr" environment: @@ -441,7 +441,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr" environment: @@ -453,7 +453,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr" environment: @@ -499,7 +499,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gcr ./cmd/drone-gcr" environment: @@ -511,7 +511,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gcr ./cmd/drone-gcr" environment: @@ -587,7 +587,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr" environment: @@ -599,7 +599,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr" environment: @@ -645,7 +645,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr" environment: @@ -657,7 +657,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr" environment: @@ -703,7 +703,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-ecr ./cmd/drone-ecr" environment: @@ -715,7 +715,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-ecr ./cmd/drone-ecr" environment: @@ -791,7 +791,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku" environment: @@ -803,7 +803,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku" environment: @@ -849,7 +849,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku" environment: @@ -861,7 +861,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku" environment: @@ -907,7 +907,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-heroku ./cmd/drone-heroku" environment: @@ -919,7 +919,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-heroku ./cmd/drone-heroku" environment: @@ -995,7 +995,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr" environment: @@ -1007,7 +1007,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr" environment: @@ -1053,7 +1053,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr" environment: @@ -1065,7 +1065,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr" environment: @@ -1111,7 +1111,7 @@ platform: steps: - name: build-push - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr" environment: @@ -1123,7 +1123,7 @@ steps: - tag - name: build-tag - image: golang:1.11 + image: golang:1.13 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr" environment: diff --git a/pipeline.libsonnet b/pipeline.libsonnet index 4d44a41..08f102f 100644 --- a/pipeline.libsonnet +++ b/pipeline.libsonnet @@ -5,7 +5,7 @@ local test_pipeline_name = 'testing'; local windows(os) = os == 'windows'; local golang_image(os, version) = - 'golang:' + '1.11' + if windows(os) then '-windowsservercore-' + version else ''; + 'golang:' + '1.13' + if windows(os) then '-windowsservercore-' + version else ''; { test(os='linux', arch='amd64', version=''):: From 5490a1c24c6c1b6f201a27155c01eb4b129bcb27 Mon Sep 17 00:00:00 2001 From: Tobias Schlatter Date: Mon, 27 Sep 2021 16:20:36 +0200 Subject: [PATCH 13/27] Upgrade Docker dind to 20.10.8 for 64bit platforms This is an alternative to #327. As the discussion on that PR shows, it seems docker is not going to provide updates for the arm32 platform anymore. Fixes #326 and fixes #330. --- docker/docker/Dockerfile.linux.amd64 | 2 +- docker/docker/Dockerfile.linux.arm64 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker/Dockerfile.linux.amd64 b/docker/docker/Dockerfile.linux.amd64 index c39c578..9f854b4 100644 --- a/docker/docker/Dockerfile.linux.amd64 +++ b/docker/docker/Dockerfile.linux.amd64 @@ -1,4 +1,4 @@ -FROM docker:19.03.8-dind +FROM docker:20.10.8-dind ENV DOCKER_HOST=unix:///var/run/docker.sock diff --git a/docker/docker/Dockerfile.linux.arm64 b/docker/docker/Dockerfile.linux.arm64 index 2a70c6a..f20b5e7 100644 --- a/docker/docker/Dockerfile.linux.arm64 +++ b/docker/docker/Dockerfile.linux.arm64 @@ -1,4 +1,4 @@ -FROM arm64v8/docker:19.03.8-dind +FROM arm64v8/docker:20.10.8-dind ENV DOCKER_HOST=unix:///var/run/docker.sock From 501eae03f273467aa7195d72b798201673e179be Mon Sep 17 00:00:00 2001 From: Tobias Schlatter Date: Mon, 18 Oct 2021 16:40:41 +0200 Subject: [PATCH 14/27] Upgrade to dind 20.10.9 which has been released in the meanwhile --- docker/docker/Dockerfile.linux.amd64 | 2 +- docker/docker/Dockerfile.linux.arm64 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker/Dockerfile.linux.amd64 b/docker/docker/Dockerfile.linux.amd64 index 9f854b4..54e536e 100644 --- a/docker/docker/Dockerfile.linux.amd64 +++ b/docker/docker/Dockerfile.linux.amd64 @@ -1,4 +1,4 @@ -FROM docker:20.10.8-dind +FROM docker:20.10.9-dind ENV DOCKER_HOST=unix:///var/run/docker.sock diff --git a/docker/docker/Dockerfile.linux.arm64 b/docker/docker/Dockerfile.linux.arm64 index f20b5e7..d12c4f8 100644 --- a/docker/docker/Dockerfile.linux.arm64 +++ b/docker/docker/Dockerfile.linux.arm64 @@ -1,4 +1,4 @@ -FROM arm64v8/docker:20.10.8-dind +FROM arm64v8/docker:20.10.9-dind ENV DOCKER_HOST=unix:///var/run/docker.sock From 0244fdbc12925cdafdc80684cdcdd65c16981c2d Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Tue, 2 Nov 2021 11:23:08 +0000 Subject: [PATCH 15/27] bump to version 20.10.9: --- CHANGELOG.md | 10 ++++++++++ README.md | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b811d75..72f619f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-02) + +[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.9...v20.10.9) + +**Merged pull requests:** + +- Upgrade Docker dind to 20.10.9 for 64bit platforms [\#334](https://github.com/drone-plugins/drone-docker/pull/334) ([gzm0](https://github.com/gzm0)) + ## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13) [Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.8...v19.03.9) @@ -17,6 +25,8 @@ **Merged pull requests:** +- \(maint\) bump git to 1.13 for build and test [\#338](https://github.com/drone-plugins/drone-docker/pull/338) ([tphoney](https://github.com/tphoney)) +- \(maint\) v19.03.9 release prep [\#337](https://github.com/drone-plugins/drone-docker/pull/337) ([tphoney](https://github.com/tphoney)) - \(maint\) CI, remove the dry run steps, due to rate limiting [\#323](https://github.com/drone-plugins/drone-docker/pull/323) ([tphoney](https://github.com/tphoney)) - Update seccomp to 20.10 docker [\#322](https://github.com/drone-plugins/drone-docker/pull/322) ([techknowlogick](https://github.com/techknowlogick)) diff --git a/README.md b/README.md index 2433bcb..7a507a0 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,23 @@ docker run --rm \ --privileged \ plugins/docker --dry-run ``` + +## Release procedure + +Run the changelog generator. + +```BASH +docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone-plugins -p drone-docker -t +``` + +You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens. + +Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label. + +Run the changelog generator again with the future version according to semver. + +```BASH +docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u drone-plugins -p drone-docker -t --future-release v1.0.0 +``` + +Create your pull request for the release. Get it merged then tag the release. \ No newline at end of file From 85e715fd5d35280f387b3416db20d02e9e64af2f Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Wed, 5 Jan 2022 23:28:27 +0530 Subject: [PATCH 16/27] Support for windows images for tags (#346) --- .drone.yml | 506 ++++++++++++++---- ...ows.1803 => Dockerfile.windows.amd64.1803} | 2 +- ...ows.1809 => Dockerfile.windows.amd64.1809} | 2 +- docker/acr/Dockerfile.windows.amd64.1909 | 10 + docker/acr/manifest.tmpl | 16 +- ...ows.1803 => Dockerfile.windows.amd64.1803} | 0 ...ows.1809 => Dockerfile.windows.amd64.1809} | 0 ...ows.1903 => Dockerfile.windows.amd64.1903} | 0 ...ows.1909 => Dockerfile.windows.amd64.1909} | 0 docker/docker/manifest.tmpl | 2 +- ...ows.1803 => Dockerfile.windows.amd64.1803} | 2 +- ...ows.1809 => Dockerfile.windows.amd64.1809} | 2 +- docker/ecr/Dockerfile.windows.amd64.1909 | 10 + docker/ecr/manifest.tmpl | 16 +- ...ows.1803 => Dockerfile.windows.amd64.1803} | 2 +- ...ows.1809 => Dockerfile.windows.amd64.1809} | 2 +- docker/gcr/Dockerfile.windows.amd64.1909 | 10 + docker/gcr/manifest.tmpl | 10 +- go.mod | 16 +- go.sum | 11 +- scripts/windows/latest.ps1 | 30 ++ scripts/windows/tag.ps1 | 55 ++ 22 files changed, 570 insertions(+), 134 deletions(-) rename docker/acr/{Dockerfile.windows.1803 => Dockerfile.windows.amd64.1803} (88%) rename docker/acr/{Dockerfile.windows.1809 => Dockerfile.windows.amd64.1809} (88%) create mode 100644 docker/acr/Dockerfile.windows.amd64.1909 rename docker/docker/{Dockerfile.windows.1803 => Dockerfile.windows.amd64.1803} (100%) rename docker/docker/{Dockerfile.windows.1809 => Dockerfile.windows.amd64.1809} (100%) rename docker/docker/{Dockerfile.windows.1903 => Dockerfile.windows.amd64.1903} (100%) rename docker/docker/{Dockerfile.windows.1909 => Dockerfile.windows.amd64.1909} (100%) rename docker/ecr/{Dockerfile.windows.1803 => Dockerfile.windows.amd64.1803} (88%) rename docker/ecr/{Dockerfile.windows.1809 => Dockerfile.windows.amd64.1809} (88%) create mode 100644 docker/ecr/Dockerfile.windows.amd64.1909 rename docker/gcr/{Dockerfile.windows.1803 => Dockerfile.windows.amd64.1803} (88%) rename docker/gcr/{Dockerfile.windows.1809 => Dockerfile.windows.amd64.1809} (88%) create mode 100644 docker/gcr/Dockerfile.windows.amd64.1909 create mode 100644 scripts/windows/latest.ps1 create mode 100644 scripts/windows/tag.ps1 diff --git a/.drone.yml b/.drone.yml index fba5719..3c8692a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ platform: steps: - name: vet - image: golang:1.13 + image: golang:1.17.3 commands: - go vet ./... environment: @@ -18,7 +18,7 @@ steps: path: /go - name: test - image: golang:1.13 + image: golang:1.17.3 commands: - go test -cover ./... environment: @@ -40,7 +40,7 @@ trigger: --- kind: pipeline type: ssh -name: windows-1809-amd64-docker +name: windows-1809-docker platform: os: windows @@ -53,70 +53,194 @@ server: from_secret: windows_username steps: -- name: build - commands: - # TODO use the new DRONE_SEMVER_SHORT environment variables to - # publish docker images for tag events. - - go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker - - docker login -u $env:USERNAME -p $env:PASSWORD - - docker build -f docker/docker/Dockerfile.windows.1809 -t plugins/docker:windows-1809-amd64 . - - docker push plugins/docker:windows-1809-amd64 +- name: build_latest environment: - CGO_ENABLED: "0" + VERSION: 1809 + REGISTRY: docker USERNAME: from_secret: docker_username PASSWORD: from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] -trigger: - event: - - push +- name: build_tag + environment: + VERSION: 1809 + REGISTRY: docker + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] depends_on: -- testing + - testing -# --- -# kind: pipeline -# type: ssh -# name: windows-1903-amd64-docker - -# platform: -# os: windows - -# server: -# host: windows.1903.amd64.plugins.drone.ci -# password: -# from_secret: windows_password -# user: -# from_secret: windows_username - -# steps: -# - name: build -# commands: -# # TODO use the new DRONE_SEMVER_SHORT environment variables to -# # publish docker images for tag events. -# - go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker -# - docker login -u $env:USERNAME -p $env:PASSWORD -# - docker build -f docker/docker/Dockerfile.windows.1903 -t plugins/docker:windows-1903-amd64 . -# - docker push plugins/docker:windows-1903-amd64 -# environment: -# CGO_ENABLED: "0" -# USERNAME: -# from_secret: docker_username -# PASSWORD: -# from_secret: docker_password - -# trigger: -# event: -# - push - -# depends_on: -# - testing +trigger: + ref: + - refs/heads/master + - refs/tags/* --- kind: pipeline type: ssh -name: windows-1909-amd64-docker +name: windows-1809-ecr + +platform: + os: windows + +server: + host: windows.1809.amd64.plugins.drone.ci + password: + from_secret: windows_password + user: + from_secret: windows_username + +steps: +- name: build_latest + environment: + VERSION: 1809 + REGISTRY: ecr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] + +- name: build_tag + environment: + VERSION: 1809 + REGISTRY: ecr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] + +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/* + +--- +kind: pipeline +type: ssh +name: windows-1809-gcr + +platform: + os: windows + +server: + host: windows.1809.amd64.plugins.drone.ci + password: + from_secret: windows_password + user: + from_secret: windows_username + +steps: +- name: build_latest + environment: + VERSION: 1809 + REGISTRY: gcr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] + +- name: build_tag + environment: + VERSION: 1809 + REGISTRY: gcr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] + +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/* + +--- +kind: pipeline +type: ssh +name: windows-1809-acr + +platform: + os: windows + +server: + host: windows.1809.amd64.plugins.drone.ci + password: + from_secret: windows_password + user: + from_secret: windows_username + +steps: +- name: build_latest + environment: + VERSION: 1809 + REGISTRY: acr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] + +- name: build_tag + environment: + VERSION: 1809 + REGISTRY: acr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] + +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/* + +--- +kind: pipeline +type: ssh +name: windows-1909-docker platform: os: windows @@ -129,28 +253,190 @@ server: from_secret: windows_username steps: - - name: build - commands: - # TODO use the new DRONE_SEMVER_SHORT environment variables to - # publish docker images for tag events. - - go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker - - docker login -u $env:USERNAME -p $env:PASSWORD - - docker build -f docker/docker/Dockerfile.windows.1909 -t plugins/docker:windows-1909-amd64 . - - docker push plugins/docker:windows-1909-amd64 - environment: - CGO_ENABLED: "0" - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password +- name: build_latest + environment: + VERSION: 1909 + REGISTRY: docker + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] -trigger: - event: - - push +- name: build_tag + environment: + VERSION: 1909 + REGISTRY: docker + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] depends_on: - testing +trigger: + ref: + - refs/heads/master + - refs/tags/* + +--- +kind: pipeline +type: ssh +name: windows-1909-ecr + +platform: + os: windows + +server: + host: windows.1909.amd64.plugins.drone.ci + password: + from_secret: windows_password + user: + from_secret: windows_username + +steps: +- name: build_latest + environment: + VERSION: 1909 + REGISTRY: ecr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] + +- name: build_tag + environment: + VERSION: 1909 + REGISTRY: ecr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] + +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/* + +--- +kind: pipeline +type: ssh +name: windows-1909-gcr + +platform: + os: windows + +server: + host: windows.1909.amd64.plugins.drone.ci + password: + from_secret: windows_password + user: + from_secret: windows_username + +steps: +- name: build_latest + environment: + VERSION: 1909 + REGISTRY: gcr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] + +- name: build_tag + environment: + VERSION: 1909 + REGISTRY: gcr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] + +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/* + +--- +kind: pipeline +type: ssh +name: windows-1909-acr + +platform: + os: windows + +server: + host: windows.1909.amd64.plugins.drone.ci + password: + from_secret: windows_password + user: + from_secret: windows_username + +steps: +- name: build_latest + environment: + VERSION: 1909 + REGISTRY: acr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/latest.ps1 + when: + event: [ push ] + +- name: build_tag + environment: + VERSION: 1909 + REGISTRY: acr + USERNAME: + from_secret: docker_username + PASSWORD: + from_secret: docker_password + commands: + - powershell.exe scripts/windows/tag.ps1 + when: + event: [ tag ] + +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/* + --- kind: pipeline name: linux-amd64-docker @@ -161,7 +447,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker" environment: @@ -173,7 +459,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker" environment: @@ -184,7 +470,7 @@ steps: - tag - name: executable - image: golang:1.13 + image: golang:1.17.3 commands: - ./release/linux/amd64/drone-docker --help @@ -224,7 +510,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker" environment: @@ -236,7 +522,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-docker ./cmd/drone-docker" environment: @@ -247,7 +533,7 @@ steps: - tag - name: executable - image: golang:1.13 + image: golang:1.17.3 commands: - ./release/linux/arm64/drone-docker --help @@ -287,7 +573,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-docker ./cmd/drone-docker" environment: @@ -299,7 +585,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-docker ./cmd/drone-docker" environment: @@ -310,7 +596,7 @@ steps: - tag - name: executable - image: golang:1.13 + image: golang:1.17.3 commands: - ./release/linux/arm/drone-docker --help @@ -366,12 +652,11 @@ trigger: - "refs/tags/**" depends_on: -- windows-1809-amd64-docker -- windows-1909-amd64-docker +- windows-1809-docker +- windows-1909-docker - linux-amd64-docker - linux-arm64-docker - linux-arm-docker -# - windows-1903-amd64-dfocker --- kind: pipeline @@ -383,7 +668,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr" environment: @@ -395,7 +680,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr" environment: @@ -441,7 +726,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr" environment: @@ -453,7 +738,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gcr ./cmd/drone-gcr" environment: @@ -499,7 +784,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gcr ./cmd/drone-gcr" environment: @@ -511,7 +796,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gcr ./cmd/drone-gcr" environment: @@ -573,6 +858,8 @@ trigger: - "refs/tags/**" depends_on: +- windows-1809-gcr +- windows-1909-gcr - linux-amd64-gcr - linux-arm64-gcr - linux-arm-gcr @@ -587,7 +874,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr" environment: @@ -599,7 +886,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr" environment: @@ -645,7 +932,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr" environment: @@ -657,7 +944,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-ecr ./cmd/drone-ecr" environment: @@ -703,7 +990,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-ecr ./cmd/drone-ecr" environment: @@ -715,7 +1002,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-ecr ./cmd/drone-ecr" environment: @@ -777,6 +1064,8 @@ trigger: - "refs/tags/**" depends_on: +- windows-1809-ecr +- windows-1909-ecr - linux-amd64-ecr - linux-arm64-ecr - linux-arm-ecr @@ -791,7 +1080,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku" environment: @@ -803,7 +1092,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku" environment: @@ -849,7 +1138,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku" environment: @@ -861,7 +1150,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-heroku ./cmd/drone-heroku" environment: @@ -907,7 +1196,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-heroku ./cmd/drone-heroku" environment: @@ -919,7 +1208,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-heroku ./cmd/drone-heroku" environment: @@ -995,7 +1284,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr" environment: @@ -1007,7 +1296,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr" environment: @@ -1053,7 +1342,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr" environment: @@ -1065,7 +1354,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr" environment: @@ -1111,7 +1400,7 @@ platform: steps: - name: build-push - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr" environment: @@ -1123,7 +1412,7 @@ steps: - tag - name: build-tag - image: golang:1.13 + image: golang:1.17.3 commands: - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr" environment: @@ -1184,9 +1473,10 @@ trigger: - "refs/tags/**" depends_on: +- windows-1809-acr +- windows-1909-acr - linux-amd64-acr - linux-arm64-acr - linux-arm-acr - ... diff --git a/docker/acr/Dockerfile.windows.1803 b/docker/acr/Dockerfile.windows.amd64.1803 similarity index 88% rename from docker/acr/Dockerfile.windows.1803 rename to docker/acr/Dockerfile.windows.amd64.1803 index f7b3fdd..755fe9e 100644 --- a/docker/acr/Dockerfile.windows.1803 +++ b/docker/acr/Dockerfile.windows.amd64.1803 @@ -1,5 +1,5 @@ # escape=` -FROM plugins/docker:windows-1803 +FROM plugins/docker:windows-1803-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone ACR" ` diff --git a/docker/acr/Dockerfile.windows.1809 b/docker/acr/Dockerfile.windows.amd64.1809 similarity index 88% rename from docker/acr/Dockerfile.windows.1809 rename to docker/acr/Dockerfile.windows.amd64.1809 index dfa264d..c03c17c 100644 --- a/docker/acr/Dockerfile.windows.1809 +++ b/docker/acr/Dockerfile.windows.amd64.1809 @@ -1,5 +1,5 @@ # escape=` -FROM plugins/docker:windows-1809 +FROM plugins/docker:windows-1809-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone ACR" ` diff --git a/docker/acr/Dockerfile.windows.amd64.1909 b/docker/acr/Dockerfile.windows.amd64.1909 new file mode 100644 index 0000000..9b94ccd --- /dev/null +++ b/docker/acr/Dockerfile.windows.amd64.1909 @@ -0,0 +1,10 @@ +# escape=` +FROM plugins/docker:windows-1909-amd64 + +LABEL maintainer="Drone.IO Community " ` + org.label-schema.name="Drone ACR" ` + org.label-schema.vendor="Drone.IO Community" ` + org.label-schema.schema-version="1.0" + +ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe +ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ] diff --git a/docker/acr/manifest.tmpl b/docker/acr/manifest.tmpl index d1acb34..c84e3c6 100644 --- a/docker/acr/manifest.tmpl +++ b/docker/acr/manifest.tmpl @@ -24,14 +24,26 @@ manifests: os: linux variant: v7 - - image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803 + image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64 platform: architecture: amd64 os: windows version: 1803 - - image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809 + image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 platform: architecture: amd64 os: windows version: 1809 + - + image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64 + platform: + architecture: amd64 + os: windows + version: 1903 + - + image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64 + platform: + architecture: amd64 + os: windows + version: 1909 diff --git a/docker/docker/Dockerfile.windows.1803 b/docker/docker/Dockerfile.windows.amd64.1803 similarity index 100% rename from docker/docker/Dockerfile.windows.1803 rename to docker/docker/Dockerfile.windows.amd64.1803 diff --git a/docker/docker/Dockerfile.windows.1809 b/docker/docker/Dockerfile.windows.amd64.1809 similarity index 100% rename from docker/docker/Dockerfile.windows.1809 rename to docker/docker/Dockerfile.windows.amd64.1809 diff --git a/docker/docker/Dockerfile.windows.1903 b/docker/docker/Dockerfile.windows.amd64.1903 similarity index 100% rename from docker/docker/Dockerfile.windows.1903 rename to docker/docker/Dockerfile.windows.amd64.1903 diff --git a/docker/docker/Dockerfile.windows.1909 b/docker/docker/Dockerfile.windows.amd64.1909 similarity index 100% rename from docker/docker/Dockerfile.windows.1909 rename to docker/docker/Dockerfile.windows.amd64.1909 diff --git a/docker/docker/manifest.tmpl b/docker/docker/manifest.tmpl index 4766c36..915e3d0 100644 --- a/docker/docker/manifest.tmpl +++ b/docker/docker/manifest.tmpl @@ -24,7 +24,7 @@ manifests: os: linux variant: v7 - - image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803 + image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64 platform: architecture: amd64 os: windows diff --git a/docker/ecr/Dockerfile.windows.1803 b/docker/ecr/Dockerfile.windows.amd64.1803 similarity index 88% rename from docker/ecr/Dockerfile.windows.1803 rename to docker/ecr/Dockerfile.windows.amd64.1803 index 367cfb2..c1bbd53 100644 --- a/docker/ecr/Dockerfile.windows.1803 +++ b/docker/ecr/Dockerfile.windows.amd64.1803 @@ -1,5 +1,5 @@ # escape=` -FROM plugins/docker:windows-1803 +FROM plugins/docker:windows-1803-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone ECR" ` diff --git a/docker/ecr/Dockerfile.windows.1809 b/docker/ecr/Dockerfile.windows.amd64.1809 similarity index 88% rename from docker/ecr/Dockerfile.windows.1809 rename to docker/ecr/Dockerfile.windows.amd64.1809 index 4d12228..67803aa 100644 --- a/docker/ecr/Dockerfile.windows.1809 +++ b/docker/ecr/Dockerfile.windows.amd64.1809 @@ -1,5 +1,5 @@ # escape=` -FROM plugins/docker:windows-1809 +FROM plugins/docker:windows-1809-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone ECR" ` diff --git a/docker/ecr/Dockerfile.windows.amd64.1909 b/docker/ecr/Dockerfile.windows.amd64.1909 new file mode 100644 index 0000000..ae6e96f --- /dev/null +++ b/docker/ecr/Dockerfile.windows.amd64.1909 @@ -0,0 +1,10 @@ +# escape=` +FROM plugins/docker:windows-1909-amd64 + +LABEL maintainer="Drone.IO Community " ` + org.label-schema.name="Drone ECR" ` + org.label-schema.vendor="Drone.IO Community" ` + org.label-schema.schema-version="1.0" + +ADD release/windows/amd64/drone-ecr.exe C:/bin/drone-ecr.exe +ENTRYPOINT [ "C:\\bin\\drone-ecr.exe" ] diff --git a/docker/ecr/manifest.tmpl b/docker/ecr/manifest.tmpl index 8af16c7..36bde04 100644 --- a/docker/ecr/manifest.tmpl +++ b/docker/ecr/manifest.tmpl @@ -24,14 +24,26 @@ manifests: os: linux variant: v7 - - image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803 + image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64 platform: architecture: amd64 os: windows version: 1803 - - image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809 + image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 platform: architecture: amd64 os: windows version: 1809 + - + image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64 + platform: + architecture: amd64 + os: windows + version: 1903 + - + image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64 + platform: + architecture: amd64 + os: windows + version: 1909 diff --git a/docker/gcr/Dockerfile.windows.1803 b/docker/gcr/Dockerfile.windows.amd64.1803 similarity index 88% rename from docker/gcr/Dockerfile.windows.1803 rename to docker/gcr/Dockerfile.windows.amd64.1803 index 76bac6f..fc03bb4 100644 --- a/docker/gcr/Dockerfile.windows.1803 +++ b/docker/gcr/Dockerfile.windows.amd64.1803 @@ -1,5 +1,5 @@ # escape=` -FROM plugins/docker:windows-1803 +FROM plugins/docker:windows-1803-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone GCR" ` diff --git a/docker/gcr/Dockerfile.windows.1809 b/docker/gcr/Dockerfile.windows.amd64.1809 similarity index 88% rename from docker/gcr/Dockerfile.windows.1809 rename to docker/gcr/Dockerfile.windows.amd64.1809 index 1b1134b..447013d 100644 --- a/docker/gcr/Dockerfile.windows.1809 +++ b/docker/gcr/Dockerfile.windows.amd64.1809 @@ -1,5 +1,5 @@ # escape=` -FROM plugins/docker:windows-1809 +FROM plugins/docker:windows-1809-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone GCR" ` diff --git a/docker/gcr/Dockerfile.windows.amd64.1909 b/docker/gcr/Dockerfile.windows.amd64.1909 new file mode 100644 index 0000000..faf2274 --- /dev/null +++ b/docker/gcr/Dockerfile.windows.amd64.1909 @@ -0,0 +1,10 @@ +# escape=` +FROM plugins/docker:windows-1909-amd64 + +LABEL maintainer="Drone.IO Community " ` + org.label-schema.name="Drone GCR" ` + org.label-schema.vendor="Drone.IO Community" ` + org.label-schema.schema-version="1.0" + +ADD release/windows/amd64/drone-gcr.exe C:/bin/drone-gcr.exe +ENTRYPOINT [ "C:\\bin\\drone-gcr.exe" ] diff --git a/docker/gcr/manifest.tmpl b/docker/gcr/manifest.tmpl index 8b9231a..1c83f07 100644 --- a/docker/gcr/manifest.tmpl +++ b/docker/gcr/manifest.tmpl @@ -24,14 +24,20 @@ manifests: os: linux variant: v7 - - image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803 + image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64 platform: architecture: amd64 os: windows version: 1803 - - image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809 + image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 platform: architecture: amd64 os: windows version: 1809 + - + image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64 + platform: + architecture: amd64 + os: windows + version: 1909 diff --git a/go.mod b/go.mod index 36080ec..b040264 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,20 @@ module github.com/drone-plugins/drone-docker require ( github.com/aws/aws-sdk-go v1.26.7 - github.com/coreos/go-semver v0.2.0 + github.com/coreos/go-semver v0.3.0 github.com/joho/godotenv v1.3.0 github.com/sirupsen/logrus v1.3.0 github.com/urfave/cli v1.22.2 - golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e // indirect - golang.org/x/text v0.3.0 // indirect ) -go 1.13 +require ( + github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect + github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect + github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 // indirect + golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 // indirect +) + +go 1.17 diff --git a/go.sum b/go.sum index e684144..2e8569c 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg= github.com/aws/aws-sdk-go v1.26.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -24,19 +24,12 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -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 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/scripts/windows/latest.ps1 b/scripts/windows/latest.ps1 new file mode 100644 index 0000000..1a9a26b --- /dev/null +++ b/scripts/windows/latest.ps1 @@ -0,0 +1,30 @@ +# this script is used by the continuous integration server to +# build and publish the docker image for a commit to master. + +$env:GOOS="windows" +$env:GOARCH="amd64" +$env:CGO_ENABLED="0" + +if (-not (Test-Path env:VERSION)) { + $env:VERSION="1809" +} + +if (-not (Test-Path env:REGISTRY)) { + $env:REGISTRY="docker" +} + + +echo $env:GOOS +echo $env:GOARCH +echo $env:VERSION + +# build the binary +go build -o release/windows/amd64/drone-$env:REGISTRY.exe + +# build and publish the docker image +docker login -u $env:USERNAME -p $env:PASSWORD +docker build -f docker/$env:REGISTRY/Dockerfile.windows.amd64.$env:VERSION -t plugins/$env:REGISTRY:windows-$env:VERSION-amd64 . +docker push plugins/$env:REGISTRY:windows-$env:VERSION-amd64 + +# remove images from local cache +docker rmi plugins/$env:REGISTRY:windows-$env:VERSION-amd64 diff --git a/scripts/windows/tag.ps1 b/scripts/windows/tag.ps1 new file mode 100644 index 0000000..a8468b6 --- /dev/null +++ b/scripts/windows/tag.ps1 @@ -0,0 +1,55 @@ +# this script is used by the continuous integration server to +# build and publish the docker image for a tagged revsision. + +$env:GOOS="windows" +$env:GOARCH="amd64" +$env:CGO_ENABLED="0" + +if (-not (Test-Path env:VERSION)) { + $env:VERSION="1809" +} + +if (-not (Test-Path env:DRONE_SEMVER_SHORT)) { + echo "missing semver" + exit 1 +} + +if (-not (Test-Path env:REGISTRY)) { + $env:REGISTRY="docker" +} + +# define the image tags +$env:IMAGE_PATCH="plugins/$env:REGISTRY:$env:DRONE_SEMVER_SHORT-windows-$env:VERSION-amd64" +$env:IMAGE_MAJOR="plugins/$env:REGISTRY:$env:DRONE_SEMVER_MAJOR-windows-$env:VERSION-amd64" +$env:IMAGE_MINOR="plugins/$env:REGISTRY:$env:DRONE_SEMVER_MAJOR.$env:DRONE_SEMVER_MINOR-windows-$env:VERSION-amd64" + +echo "build environment:" +echo $env:GOOS +echo $env:GOARCH +echo $env:VERSION + +# build the binary +go build -o release/windows/amd64/drone-$env:REGISTRY.exe + +# authenticate with the docker registry +docker login -u $env:USERNAME -p $env:PASSWORD + +echo "building images:" +echo $env:IMAGE_PATCH +echo $env:IMAGE_MINOR +echo $env:IMAGE_MAJOR + +# build and tag the docker images +docker build -f docker/$env:REGISTRY/Dockerfile.windows.amd64.$env:VERSION -t $env:IMAGE_PATCH . +docker tag $env:IMAGE_PATCH $env:IMAGE_MAJOR +docker tag $env:IMAGE_PATCH $env:IMAGE_MINOR + +# publish the docker images +docker push $env:IMAGE_MAJOR +docker push $env:IMAGE_MINOR +docker push $env:IMAGE_PATCH + +# remove images after from local cache +docker rmi $env:IMAGE_MAJOR +docker rmi $env:IMAGE_MINOR +docker rmi $env:IMAGE_PATCH From 28175f400303178dcb9baad842766e532ab22fc0 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Thu, 6 Jan 2022 13:28:00 +0530 Subject: [PATCH 17/27] Serialize windows 1809 pipelines --- .drone.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.drone.yml b/.drone.yml index 3c8692a..a355d6b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -131,6 +131,7 @@ steps: depends_on: - testing + - windows-1809-docker trigger: ref: @@ -181,6 +182,7 @@ steps: depends_on: - testing + - windows-1809-ecr trigger: ref: @@ -231,6 +233,7 @@ steps: depends_on: - testing + - windows-1809-gcr trigger: ref: From 74ec8ac7613d6e5dfb4718ad431b6d3df737df6d Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Fri, 7 Jan 2022 11:41:11 +0530 Subject: [PATCH 18/27] Fix powershell script to publish windows images --- scripts/windows/latest.ps1 | 17 +++++++++----- scripts/windows/tag.ps1 | 45 ++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/scripts/windows/latest.ps1 b/scripts/windows/latest.ps1 index 1a9a26b..7e8b3b5 100644 --- a/scripts/windows/latest.ps1 +++ b/scripts/windows/latest.ps1 @@ -1,5 +1,6 @@ # this script is used by the continuous integration server to # build and publish the docker image for a commit to master. +$ErrorActionPreference = "Stop" $env:GOOS="windows" $env:GOARCH="amd64" @@ -13,18 +14,22 @@ if (-not (Test-Path env:REGISTRY)) { $env:REGISTRY="docker" } - echo $env:GOOS echo $env:GOARCH echo $env:VERSION +echo $env:REGISTRY # build the binary -go build -o release/windows/amd64/drone-$env:REGISTRY.exe +Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe"; +go build -o release/windows/amd64/drone-${env:REGISTRY}.exe # build and publish the docker image -docker login -u $env:USERNAME -p $env:PASSWORD -docker build -f docker/$env:REGISTRY/Dockerfile.windows.amd64.$env:VERSION -t plugins/$env:REGISTRY:windows-$env:VERSION-amd64 . -docker push plugins/$env:REGISTRY:windows-$env:VERSION-amd64 +docker login -u ${env:USERNAME} -p ${env:PASSWORD} +Write-Host "+ docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64 ."; +docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64 . +Write-Host "+ docker push plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64" +docker push plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64 # remove images from local cache -docker rmi plugins/$env:REGISTRY:windows-$env:VERSION-amd64 +Write-Host "+ docker rmi plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64" +docker rmi plugins/${env:REGISTRY}:windows-${env:VERSION}-amd64 diff --git a/scripts/windows/tag.ps1 b/scripts/windows/tag.ps1 index a8468b6..6d895ae 100644 --- a/scripts/windows/tag.ps1 +++ b/scripts/windows/tag.ps1 @@ -1,5 +1,6 @@ # this script is used by the continuous integration server to # build and publish the docker image for a tagged revsision. +$ErrorActionPreference = "Stop" $env:GOOS="windows" $env:GOARCH="amd64" @@ -19,9 +20,9 @@ if (-not (Test-Path env:REGISTRY)) { } # define the image tags -$env:IMAGE_PATCH="plugins/$env:REGISTRY:$env:DRONE_SEMVER_SHORT-windows-$env:VERSION-amd64" -$env:IMAGE_MAJOR="plugins/$env:REGISTRY:$env:DRONE_SEMVER_MAJOR-windows-$env:VERSION-amd64" -$env:IMAGE_MINOR="plugins/$env:REGISTRY:$env:DRONE_SEMVER_MAJOR.$env:DRONE_SEMVER_MINOR-windows-$env:VERSION-amd64" +$env:IMAGE_PATCH="plugins/${env:REGISTRY}:${env:DRONE_SEMVER_SHORT}-windows-${env:VERSION}-amd64" +$env:IMAGE_MAJOR="plugins/${env:REGISTRY}:${env:DRONE_SEMVER_MAJOR}-windows-${env:VERSION}-amd64" +$env:IMAGE_MINOR="plugins/${env:REGISTRY}:${env:DRONE_SEMVER_MAJOR}.${env:DRONE_SEMVER_MINOR}-windows-${env:VERSION}-amd64" echo "build environment:" echo $env:GOOS @@ -29,27 +30,37 @@ echo $env:GOARCH echo $env:VERSION # build the binary -go build -o release/windows/amd64/drone-$env:REGISTRY.exe +Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe" +go build -o release/windows/amd64/drone-${env:REGISTRY}.exe # authenticate with the docker registry -docker login -u $env:USERNAME -p $env:PASSWORD +docker login -u ${env:USERNAME} -p ${env:PASSWORD} echo "building images:" -echo $env:IMAGE_PATCH -echo $env:IMAGE_MINOR -echo $env:IMAGE_MAJOR +echo ${env:IMAGE_PATCH} +echo ${env:IMAGE_MINOR} +echo ${env:IMAGE_MAJOR} # build and tag the docker images -docker build -f docker/$env:REGISTRY/Dockerfile.windows.amd64.$env:VERSION -t $env:IMAGE_PATCH . -docker tag $env:IMAGE_PATCH $env:IMAGE_MAJOR -docker tag $env:IMAGE_PATCH $env:IMAGE_MINOR +Write-Host "+ docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t ${env:IMAGE_PATCH} ." +docker build -f docker/${env:REGISTRY}/Dockerfile.windows.amd64.${env:VERSION} -t ${env:IMAGE_PATCH} . +Write-Host "+ docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MAJOR}" +docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MAJOR} +Write-Host "+ docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MINOR}" +docker tag ${env:IMAGE_PATCH} ${env:IMAGE_MINOR} # publish the docker images -docker push $env:IMAGE_MAJOR -docker push $env:IMAGE_MINOR -docker push $env:IMAGE_PATCH +Write-Host "+ docker push ${env:IMAGE_MAJOR}" +docker push ${env:IMAGE_MAJOR} +Write-Host "+ docker push ${env:IMAGE_MINOR}" +docker push ${env:IMAGE_MINOR} +Write-Host "+ docker push ${env:IMAGE_PATCH}" +docker push ${env:IMAGE_PATCH} # remove images after from local cache -docker rmi $env:IMAGE_MAJOR -docker rmi $env:IMAGE_MINOR -docker rmi $env:IMAGE_PATCH +Write-Host "+ docker rmi ${env:IMAGE_MAJOR}" +docker rmi ${env:IMAGE_MAJOR} +Write-Host "+ docker rmi ${env:IMAGE_MINOR}" +docker rmi ${env:IMAGE_MINOR} +Write-Host "+ docker rmi ${env:IMAGE_PATCH}" +docker rmi ${env:IMAGE_PATCH} From 80d227e13846429a80bd34a446fe16ed6aaab1a2 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Sat, 8 Jan 2022 00:31:45 +0530 Subject: [PATCH 19/27] Fix windows docker builds --- scripts/windows/latest.ps1 | 2 +- scripts/windows/tag.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/windows/latest.ps1 b/scripts/windows/latest.ps1 index 7e8b3b5..8663c63 100644 --- a/scripts/windows/latest.ps1 +++ b/scripts/windows/latest.ps1 @@ -21,7 +21,7 @@ echo $env:REGISTRY # build the binary Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe"; -go build -o release/windows/amd64/drone-${env:REGISTRY}.exe +go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY} # build and publish the docker image docker login -u ${env:USERNAME} -p ${env:PASSWORD} diff --git a/scripts/windows/tag.ps1 b/scripts/windows/tag.ps1 index 6d895ae..d1cac5b 100644 --- a/scripts/windows/tag.ps1 +++ b/scripts/windows/tag.ps1 @@ -31,7 +31,7 @@ echo $env:VERSION # build the binary Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe" -go build -o release/windows/amd64/drone-${env:REGISTRY}.exe +go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY} # authenticate with the docker registry docker login -u ${env:USERNAME} -p ${env:PASSWORD} From 47dc8555ad13d56ad6d28d6b5ae7ba63628e93f6 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Wed, 12 Jan 2022 22:32:57 +0530 Subject: [PATCH 20/27] Fix ECR & GCR docker publish on windows (#352) --- cmd/drone-acr/main.go | 7 ++++-- cmd/drone-docker/main.go | 49 ++++++++++++++++++++++---------------- cmd/drone-ecr/main.go | 7 ++++-- cmd/drone-gcr/main.go | 7 ++++-- docker.go | 9 +++++++ scripts/windows/latest.ps1 | 2 +- scripts/windows/tag.ps1 | 2 +- 7 files changed, 55 insertions(+), 28 deletions(-) diff --git a/cmd/drone-acr/main.go b/cmd/drone-acr/main.go index 62e65c5..6a7f097 100644 --- a/cmd/drone-acr/main.go +++ b/cmd/drone-acr/main.go @@ -7,6 +7,9 @@ import ( "strings" "github.com/joho/godotenv" + "github.com/sirupsen/logrus" + + docker "github.com/drone-plugins/drone-docker" ) func main() { @@ -40,12 +43,12 @@ func main() { os.Setenv("DOCKER_PASSWORD", password) // invoke the base docker plugin binary - cmd := exec.Command("drone-docker") + cmd := exec.Command(docker.GetDroneDockerExecCmd()) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err := cmd.Run() if err != nil { - os.Exit(1) + logrus.Fatal(err) } } diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index 3385bb8..b76cd6b 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -2,6 +2,7 @@ package main import ( "os" + "runtime" "github.com/joho/godotenv" "github.com/sirupsen/logrus" @@ -267,26 +268,26 @@ func run(c *cli.Context) error { Config: c.String("docker.config"), }, Build: docker.Build{ - Remote: c.String("remote.url"), - Name: c.String("commit.sha"), - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - Args: c.StringSlice("args"), - ArgsEnv: c.StringSlice("args-from-env"), - Target: c.String("target"), - Squash: c.Bool("squash"), - Pull: c.BoolT("pull-image"), - CacheFrom: c.StringSlice("cache-from"), - Compress: c.Bool("compress"), - Repo: c.String("repo"), - Labels: c.StringSlice("custom-labels"), - LabelSchema: c.StringSlice("label-schema"), - AutoLabel: c.BoolT("auto-label"), - Link: c.String("link"), - NoCache: c.Bool("no-cache"), - AddHost: c.StringSlice("add-host"), - Quiet: c.Bool("quiet"), + Remote: c.String("remote.url"), + Name: c.String("commit.sha"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + Args: c.StringSlice("args"), + ArgsEnv: c.StringSlice("args-from-env"), + Target: c.String("target"), + Squash: c.Bool("squash"), + Pull: c.BoolT("pull-image"), + CacheFrom: c.StringSlice("cache-from"), + Compress: c.Bool("compress"), + Repo: c.String("repo"), + Labels: c.StringSlice("custom-labels"), + LabelSchema: c.StringSlice("label-schema"), + AutoLabel: c.BoolT("auto-label"), + Link: c.String("link"), + NoCache: c.Bool("no-cache"), + AddHost: c.StringSlice("add-host"), + Quiet: c.Bool("quiet"), }, Daemon: docker.Daemon{ Registry: c.String("docker.registry"), @@ -327,3 +328,11 @@ func run(c *cli.Context) error { return plugin.Exec() } + +func GetExecCmd() string { + if runtime.GOOS == "windows" { + return "C:/bin/drone-docker.exe" + } + + return "drone-docker" +} diff --git a/cmd/drone-ecr/main.go b/cmd/drone-ecr/main.go index 07450c3..f91e4b5 100644 --- a/cmd/drone-ecr/main.go +++ b/cmd/drone-ecr/main.go @@ -11,12 +11,15 @@ import ( "strings" "github.com/joho/godotenv" + "github.com/sirupsen/logrus" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials/stscreds" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ecr" + + docker "github.com/drone-plugins/drone-docker" ) const defaultRegion = "us-east-1" @@ -110,11 +113,11 @@ func main() { os.Setenv("DOCKER_PASSWORD", password) // invoke the base docker plugin binary - cmd := exec.Command("drone-docker") + cmd := exec.Command(docker.GetDroneDockerExecCmd()) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err = cmd.Run(); err != nil { - os.Exit(1) + logrus.Fatal(err) } } diff --git a/cmd/drone-gcr/main.go b/cmd/drone-gcr/main.go index addddcb..92ecd9c 100644 --- a/cmd/drone-gcr/main.go +++ b/cmd/drone-gcr/main.go @@ -8,6 +8,9 @@ import ( "strings" "github.com/joho/godotenv" + "github.com/sirupsen/logrus" + + docker "github.com/drone-plugins/drone-docker" ) // gcr default username @@ -54,12 +57,12 @@ func main() { os.Setenv("DOCKER_PASSWORD", password) // invoke the base docker plugin binary - cmd := exec.Command("drone-docker") + cmd := exec.Command(docker.GetDroneDockerExecCmd()) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err = cmd.Run() if err != nil { - os.Exit(1) + logrus.Fatal(err) } } diff --git a/docker.go b/docker.go index 9effe4c..5de6d58 100644 --- a/docker.go +++ b/docker.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "time" ) @@ -416,3 +417,11 @@ func commandRmi(tag string) *exec.Cmd { func trace(cmd *exec.Cmd) { fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " ")) } + +func GetDroneDockerExecCmd() string { + if runtime.GOOS == "windows" { + return "C:/bin/drone-docker.exe" + } + + return "drone-docker" +} diff --git a/scripts/windows/latest.ps1 b/scripts/windows/latest.ps1 index 8663c63..870e255 100644 --- a/scripts/windows/latest.ps1 +++ b/scripts/windows/latest.ps1 @@ -20,7 +20,7 @@ echo $env:VERSION echo $env:REGISTRY # build the binary -Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe"; +Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}"; go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY} # build and publish the docker image diff --git a/scripts/windows/tag.ps1 b/scripts/windows/tag.ps1 index d1cac5b..65c32a6 100644 --- a/scripts/windows/tag.ps1 +++ b/scripts/windows/tag.ps1 @@ -30,7 +30,7 @@ echo $env:GOARCH echo $env:VERSION # build the binary -Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe" +Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}" go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY} # authenticate with the docker registry From 3922dcfea5404156ebf98142c7bf2a48aabf1bd2 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 13 Jan 2022 11:08:47 +0000 Subject: [PATCH 21/27] release prep for 20.10.9.1 --- CHANGELOG.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72f619f..426577a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,27 @@ # Changelog -## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-02) +## [v20.10.9.1](https://github.com/drone-plugins/drone-docker/tree/v20.10.9.1) (2022-01-13) + +[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.10.9...v20.10.9.1) + +**Implemented enhancements:** + +- Serialize windows 1809 pipelines [\#348](https://github.com/drone-plugins/drone-docker/pull/348) ([shubham149](https://github.com/shubham149)) +- Support for windows images for tags [\#346](https://github.com/drone-plugins/drone-docker/pull/346) ([shubham149](https://github.com/shubham149)) + +**Fixed bugs:** + +- Fix ECR & GCR docker publish on windows [\#352](https://github.com/drone-plugins/drone-docker/pull/352) ([shubham149](https://github.com/shubham149)) +- Fix windows docker builds [\#351](https://github.com/drone-plugins/drone-docker/pull/351) ([shubham149](https://github.com/shubham149)) +- Fix powershell script to publish windows images [\#350](https://github.com/drone-plugins/drone-docker/pull/350) ([shubham149](https://github.com/shubham149)) + +## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-03) [Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.9...v20.10.9) **Merged pull requests:** +- bump to version 20.10.9: [\#342](https://github.com/drone-plugins/drone-docker/pull/342) ([eoinmcafee00](https://github.com/eoinmcafee00)) - Upgrade Docker dind to 20.10.9 for 64bit platforms [\#334](https://github.com/drone-plugins/drone-docker/pull/334) ([gzm0](https://github.com/gzm0)) ## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13) From 246dfb3c0e45d2963501b378353745ab05838844 Mon Sep 17 00:00:00 2001 From: Eoin McAfee <83226740+eoinmcafee00@users.noreply.github.com> Date: Thu, 13 Jan 2022 12:14:53 +0000 Subject: [PATCH 22/27] (feat) publish docker data to create drone card (#347) * plugin logic to write card data to publish drone card --- card.go | 63 +++++++++++++++++++++ cmd/drone-docker/main.go | 6 ++ docker.go | 58 +++++++++++++++---- docs/card.json | 118 +++++++++++++++++++++++++++++++++++++++ docs/index.json | 0 go.mod | 2 + go.sum | 7 +++ 7 files changed, 244 insertions(+), 10 deletions(-) create mode 100644 card.go create mode 100644 docs/card.json create mode 100644 docs/index.json diff --git a/card.go b/card.go new file mode 100644 index 0000000..e9bd76a --- /dev/null +++ b/card.go @@ -0,0 +1,63 @@ +package docker + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "os/exec" + "time" + + "github.com/drone/drone-go/drone" + + "github.com/inhies/go-bytesize" +) + +func (p Plugin) writeCard() error { + cmd := exec.Command("docker", "inspect", p.Build.Name) + data, err := cmd.CombinedOutput() + if err != nil { + return err + } + + out := Inspect{} + if err := json.Unmarshal(data, &out); err != nil { + return err + } + + inspect := out[0] + inspect.SizeString = fmt.Sprint(bytesize.New(float64(inspect.Size))) + inspect.VirtualSizeString = fmt.Sprint(bytesize.New(float64(inspect.VirtualSize))) + inspect.Time = fmt.Sprint(inspect.Metadata.LastTagTime.Format(time.RFC3339)) + cardData, _ := json.Marshal(inspect) + + card := drone.CardInput{ + Schema: "https://drone-plugins.github.io/drone-docker/card.json", + Data: cardData, + } + + writeCard(p.CardPath, &card) + return nil +} + +func writeCard(path string, card interface{}) { + data, _ := json.Marshal(card) + switch { + case path == "/dev/stdout": + writeCardTo(os.Stdout, data) + case path == "/dev/stderr": + writeCardTo(os.Stderr, data) + case path != "": + ioutil.WriteFile(path, data, 0644) + } +} + +func writeCardTo(out io.Writer, data []byte) { + encoded := base64.StdEncoding.EncodeToString(data) + io.WriteString(out, "\u001B]1338;") + io.WriteString(out, encoded) + io.WriteString(out, "\u001B]0m") + io.WriteString(out, "\n") +} diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index b76cd6b..ce652fe 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -249,6 +249,11 @@ func main() { Usage: "additional host:IP mapping", EnvVar: "PLUGIN_ADD_HOST", }, + cli.StringFlag{ + Name: "drone-card-path", + Usage: "card path location to write to", + EnvVar: "DRONE_CARD_PATH", + }, } if err := app.Run(os.Args); err != nil { @@ -267,6 +272,7 @@ func run(c *cli.Context) error { Email: c.String("docker.email"), Config: c.String("docker.config"), }, + CardPath: c.String("drone-card-path"), Build: docker.Build{ Remote: c.String("remote.url"), Name: c.String("commit.sha"), diff --git a/docker.go b/docker.go index 5de6d58..d80bdf6 100644 --- a/docker.go +++ b/docker.go @@ -64,11 +64,34 @@ type ( // Plugin defines the Docker plugin parameters. Plugin struct { - Login Login // Docker login configuration - Build Build // Docker build configuration - Daemon Daemon // Docker daemon configuration - Dryrun bool // Docker push is skipped - Cleanup bool // Docker purge is enabled + Login Login // Docker login configuration + Build Build // Docker build configuration + Daemon Daemon // Docker daemon configuration + Dryrun bool // Docker push is skipped + Cleanup bool // Docker purge is enabled + CardPath string // Card path to write file to + } + + Inspect []struct { + ID string `json:"Id"` + RepoTags []string `json:"RepoTags"` + RepoDigests []interface{} `json:"RepoDigests"` + Parent string `json:"Parent"` + Comment string `json:"Comment"` + Created time.Time `json:"Created"` + Container string `json:"Container"` + DockerVersion string `json:"DockerVersion"` + Author string `json:"Author"` + Architecture string `json:"Architecture"` + Os string `json:"Os"` + Size int `json:"Size"` + VirtualSize int `json:"VirtualSize"` + Metadata struct { + LastTagTime time.Time `json:"LastTagTime"` + } `json:"Metadata"` + SizeString string + VirtualSizeString string + Time string } ) @@ -157,11 +180,6 @@ func (p Plugin) Exec() error { } } - if p.Cleanup { - cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi - cmds = append(cmds, commandPrune()) // docker system prune -f - } - // execute all commands in batch mode. for _, cmd := range cmds { cmd.Stdout = os.Stdout @@ -180,6 +198,26 @@ func (p Plugin) Exec() error { } } + // output the adaptive card + if err := p.writeCard(); err != nil { + fmt.Printf("Could not create adaptive card. %s\n", err) + } + + // execute cleanup routines in batch mode + if p.Cleanup { + // clear the slice + cmds = nil + + cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi + cmds = append(cmds, commandPrune()) // docker system prune -f + + for _, cmd := range cmds { + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + trace(cmd) + } + } + return nil } diff --git a/docs/card.json b/docs/card.json new file mode 100644 index 0000000..de02706 --- /dev/null +++ b/docs/card.json @@ -0,0 +1,118 @@ +{ + "type": "AdaptiveCard", + "body": [ + { + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "items": [ + { + "type": "Image", + "url": "https://d36jcksde1wxzq.cloudfront.net/be7833db9bddb4494d2a7c3dd659199a.png", + "size": "Medium" + } + ], + "width": "auto" + }, + { + "type": "Column", + "items": [ + { + "type": "TextBlock", + "text": "${RepoTags[0]}", + "size": "Medium" + }, + { + "type": "TextBlock", + "text": "DIGEST: ${RepoDigests[0]}", + "wrap": true, + "size": "Small", + "weight": "Lighter", + "isSubtle": true, + "spacing": "Small" + }, + { + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "items": [ + { + "type": "TextBlock", + "weight": "Lighter", + "text": "OS/ARCH", + "wrap": true, + "size": "Small", + "isSubtle": true, + "spacing": "Medium" + }, + { + "type": "TextBlock", + "text": "${OS}/${Architecture}", + "wrap": true, + "size": "Small", + "spacing": "Small" + } + ], + "separator": true, + "width": "auto" + }, + { + "type": "Column", + "items": [ + { + "type": "TextBlock", + "weight": "Lighter", + "text": "SIZE", + "wrap": true, + "size": "Small", + "isSubtle": true + }, + { + "type": "TextBlock", + "spacing": "Small", + "text": "${SizeString}", + "wrap": true, + "size": "Small" + } + ], + "width": "auto", + "separator": true, + "spacing": "Medium" + }, + { + "type": "Column", + "items": [ + { + "type": "TextBlock", + "weight": "Lighter", + "text": "LAST PUSHED", + "wrap": true, + "size": "Small", + "isSubtle": true + }, + { + "type": "TextBlock", + "spacing": "Small", + "text": "{{DATE(${Time})}} - {{TIME(${Time})}}", + "wrap": true, + "size": "Small" + } + ], + "width": "auto", + "separator": true, + "spacing": "Medium" + } + ], + "style": "default" + } + ], + "width": "stretch" + } + ] + } + ], + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "version": "1.0" +} \ No newline at end of file diff --git a/docs/index.json b/docs/index.json new file mode 100644 index 0000000..e69de29 diff --git a/go.mod b/go.mod index b040264..4ab477e 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,8 @@ module github.com/drone-plugins/drone-docker require ( github.com/aws/aws-sdk-go v1.26.7 github.com/coreos/go-semver v0.3.0 + github.com/drone/drone-go v1.7.1 + github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743 github.com/joho/godotenv v1.3.0 github.com/sirupsen/logrus v1.3.0 github.com/urfave/cli v1.22.2 diff --git a/go.sum b/go.sum index 2e8569c..53c1733 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e/go.mod h1:Xa6lInWHNQnuWoF0YPSsx+INFA9qk7/7pTjwb3PInkY= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg= github.com/aws/aws-sdk-go v1.26.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -7,6 +8,12 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSY github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 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/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw= +github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg= +github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743 h1:X3Xxno5Ji8idrNiUoFc7QyXpqhSYlDRYQmc7mlpMBzU= +github.com/inhies/go-bytesize v0.0.0-20210819104631-275770b98743/go.mod h1:KrtyD5PFj++GKkFS/7/RRrfnRhAMGQwy75GLCHWrCNs= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= From dc9bf3bc79de0fd85b71e840e6b8ee81e1e852ca Mon Sep 17 00:00:00 2001 From: Eoin McAfee <83226740+eoinmcafee00@users.noreply.github.com> Date: Wed, 19 Jan 2022 09:45:56 +0000 Subject: [PATCH 23/27] fixes window semver error (#354) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 426577a..47925ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [v20.11.0](https://github.com/drone-plugins/drone-docker/tree/v20.11.0) (2022-01-19) + +[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.10.9.1...v20.11.0) + +**Merged pull requests:** + +- \(feat\) publish docker data to create drone card [\#347](https://github.com/drone-plugins/drone-docker/pull/347) ([eoinmcafee00](https://github.com/eoinmcafee00)) + ## [v20.10.9.1](https://github.com/drone-plugins/drone-docker/tree/v20.10.9.1) (2022-01-13) [Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v20.10.9...v20.10.9.1) @@ -15,6 +23,10 @@ - Fix windows docker builds [\#351](https://github.com/drone-plugins/drone-docker/pull/351) ([shubham149](https://github.com/shubham149)) - Fix powershell script to publish windows images [\#350](https://github.com/drone-plugins/drone-docker/pull/350) ([shubham149](https://github.com/shubham149)) +**Merged pull requests:** + +- release prep for 20.10.9.1 [\#353](https://github.com/drone-plugins/drone-docker/pull/353) ([eoinmcafee00](https://github.com/eoinmcafee00)) + ## [v20.10.9](https://github.com/drone-plugins/drone-docker/tree/v20.10.9) (2021-11-03) [Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.9...v20.10.9) From 96ee8a4ebf33bfbf4348cb9823da322daebdf06a Mon Sep 17 00:00:00 2001 From: TP Honey Date: Wed, 19 Jan 2022 16:06:21 +0000 Subject: [PATCH 24/27] (fix) Update card.json with UX (#355) * Update card.json --- docs/card.json | 223 +++++++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 107 deletions(-) diff --git a/docs/card.json b/docs/card.json index de02706..fd55544 100644 --- a/docs/card.json +++ b/docs/card.json @@ -1,118 +1,127 @@ { - "type": "AdaptiveCard", - "body": [ - { - "type": "ColumnSet", - "columns": [ + "type": "AdaptiveCard", + "body": [ { - "type": "Column", - "items": [ - { - "type": "Image", - "url": "https://d36jcksde1wxzq.cloudfront.net/be7833db9bddb4494d2a7c3dd659199a.png", - "size": "Medium" - } - ], - "width": "auto" + "type": "ColumnSet", + "columns": [ + { + "type": "Column", + "items": [ + { + "type": "Image", + "url": "https://d36jcksde1wxzq.cloudfront.net/be7833db9bddb4494d2a7c3dd659199a.png", + "size": "small" + } + ], + "width": "auto" + }, + { + "type": "Column", + "items": [ + { + "type": "TextBlock", + "text": "Plugin: Drone Docker", + "wrap": true, + "size": "Small", + "weight": "Bolder", + "isSubtle": false, + "spacing": "Small" + }, + { + "type": "TextBlock", + "text": "DIGEST: ${RepoDigests[0]}", + "wrap": true, + "size": "Small", + "weight": "Lighter", + "isSubtle": true, + "spacing": "Small" + } + ], + "width": "stretch" + } + ], + "style": "default" }, { - "type": "Column", - "items": [ - { - "type": "TextBlock", - "text": "${RepoTags[0]}", - "size": "Medium" - }, - { - "type": "TextBlock", - "text": "DIGEST: ${RepoDigests[0]}", - "wrap": true, - "size": "Small", - "weight": "Lighter", - "isSubtle": true, - "spacing": "Small" - }, - { - "type": "ColumnSet", - "columns": [ + "type": "ColumnSet", + "columns": [ { - "type": "Column", - "items": [ - { - "type": "TextBlock", - "weight": "Lighter", - "text": "OS/ARCH", - "wrap": true, - "size": "Small", - "isSubtle": true, - "spacing": "Medium" - }, - { - "type": "TextBlock", - "text": "${OS}/${Architecture}", - "wrap": true, - "size": "Small", - "spacing": "Small" - } - ], - "separator": true, - "width": "auto" + "type": "Column", + "items": [ + { + "type": "TextBlock", + "weight": "Lighter", + "text": "OS/ARCH", + "wrap": true, + "size": "Small", + "isSubtle": true, + "spacing": "Medium" + }, + { + "type": "TextBlock", + "text": "${OS}/${Architecture}", + "wrap": true, + "size": "Small", + "spacing": "Small", + "weight": "Bolder" + } + ], + "separator": true, + "width": "auto" }, { - "type": "Column", - "items": [ - { - "type": "TextBlock", - "weight": "Lighter", - "text": "SIZE", - "wrap": true, - "size": "Small", - "isSubtle": true - }, - { - "type": "TextBlock", - "spacing": "Small", - "text": "${SizeString}", - "wrap": true, - "size": "Small" - } - ], - "width": "auto", - "separator": true, - "spacing": "Medium" + "type": "Column", + "items": [ + { + "type": "TextBlock", + "weight": "Lighter", + "text": "SIZE", + "wrap": true, + "size": "Small", + "isSubtle": true + }, + { + "type": "TextBlock", + "spacing": "Small", + "text": "${SizeString}", + "wrap": true, + "size": "Small", + "weight": "Bolder" + } + ], + "width": "auto", + "separator": true, + "spacing": "Medium" }, { - "type": "Column", - "items": [ - { - "type": "TextBlock", - "weight": "Lighter", - "text": "LAST PUSHED", - "wrap": true, - "size": "Small", - "isSubtle": true - }, - { - "type": "TextBlock", - "spacing": "Small", - "text": "{{DATE(${Time})}} - {{TIME(${Time})}}", - "wrap": true, - "size": "Small" - } - ], - "width": "auto", - "separator": true, - "spacing": "Medium" + "type": "Column", + "items": [ + { + "type": "TextBlock", + "weight": "Lighter", + "text": "LAST PUSHED", + "wrap": true, + "size": "Small", + "isSubtle": true + }, + { + "type": "TextBlock", + "spacing": "Small", + "text": "{{DATE(${Time})}} - {{TIME(${Time})}}", + "wrap": true, + "size": "Small", + "weight": "Bolder" + } + ], + "width": "auto", + "separator": true, + "spacing": "Medium" } - ], - "style": "default" - } - ], - "width": "stretch" + ], + "style": "default", + "separator": true } - ] - } - ], - "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", - "version": "1.0" -} \ No newline at end of file + ], + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "version": "1.5" +} From ad28b4d0f6256a9970c05c611b0e7245f7ca4a66 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Wed, 19 Jan 2022 16:15:08 +0000 Subject: [PATCH 25/27] (maint) add sample_data.json for adaptive cards --- docs/sample_data.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/sample_data.json diff --git a/docs/sample_data.json b/docs/sample_data.json new file mode 100644 index 0000000..2398fbc --- /dev/null +++ b/docs/sample_data.json @@ -0,0 +1,26 @@ +{ + "Id": "sha256:fec8cfc9f8eb4ed6bda3e83cea97c1365c53e261d07b9f47f3429c5fa879c414", + "RepoTags": [ + "7ee96c0c66e9fa7905952b5fcf5b07461bdde833:latest", + "tphoney/test:latest" + ], + "RepoDigests": [ + "tphoney/test@sha256:96e93bd69d3b4a3863a34800db2f2aa087a861d5ce0460b5932f2b7474f10a0a" + ], + "Parent": "sha256:618905d1de06873c5c59dee713977d68973fc2b497bc073108c9ce35c79019b1", + "Comment": "", + "Created": "2022-01-19T12:16:27.4679394Z", + "Container": "e09f5b26c8d454e24b738a2b38ec8ebda740bddfb872e512ace1cca3ea2d40a1", + "DockerVersion": "20.10.9", + "Author": "", + "Architecture": "amd64", + "Os": "linux", + "Size": 13195839, + "VirtualSize": 13195839, + "Metadata": { + "LastTagTime": "2022-01-19T12:16:27.5085833Z" + }, + "SizeString": "12.58MB", + "VirtualSizeString": "12.58MB", + "Time": "2022-01-19T12:16:27Z" +} From 05357ea3905f814d8ec934da0b5cbde9da9af882 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Fri, 11 Feb 2022 10:49:42 +0000 Subject: [PATCH 26/27] (DRON-232) enable build-kit for secrets consumption --- card.go | 8 +++++++- cmd/drone-docker/main.go | 6 ++++++ docker.go | 44 +++++++++++++++++++++++++--------------- docs/card.data.json | 40 ++++++++++++++++++++++++++++++++++++ docs/card.json | 17 +++++++++------- docs/sample_data.json | 26 ------------------------ 6 files changed, 91 insertions(+), 50 deletions(-) create mode 100644 docs/card.data.json delete mode 100644 docs/sample_data.json diff --git a/card.go b/card.go index e9bd76a..edb2a4f 100644 --- a/card.go +++ b/card.go @@ -22,7 +22,7 @@ func (p Plugin) writeCard() error { return err } - out := Inspect{} + out := Card{} if err := json.Unmarshal(data, &out); err != nil { return err } @@ -31,6 +31,12 @@ func (p Plugin) writeCard() error { inspect.SizeString = fmt.Sprint(bytesize.New(float64(inspect.Size))) inspect.VirtualSizeString = fmt.Sprint(bytesize.New(float64(inspect.VirtualSize))) inspect.Time = fmt.Sprint(inspect.Metadata.LastTagTime.Format(time.RFC3339)) + // change slice of tags to slice of TagStruct + var sliceTagStruct []TagStruct + for _, tag := range inspect.RepoTags { + sliceTagStruct = append(sliceTagStruct, TagStruct{Tag: tag}) + } + inspect.ParsedRepoTags = sliceTagStruct cardData, _ := json.Marshal(inspect) card := drone.CardInput{ diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index ce652fe..a5447a0 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -249,6 +249,11 @@ func main() { Usage: "additional host:IP mapping", EnvVar: "PLUGIN_ADD_HOST", }, + cli.StringFlag{ + Name: "secret", + Usage: "secret key value pair eg id=MYSECRET", + EnvVar: "PLUGIN_SECRET", + }, cli.StringFlag{ Name: "drone-card-path", Usage: "card path location to write to", @@ -292,6 +297,7 @@ func run(c *cli.Context) error { AutoLabel: c.BoolT("auto-label"), Link: c.String("link"), NoCache: c.Bool("no-cache"), + Secret: c.String("secret"), AddHost: c.StringSlice("add-host"), Quiet: c.Bool("quiet"), }, diff --git a/docker.go b/docker.go index d80bdf6..cf86afa 100644 --- a/docker.go +++ b/docker.go @@ -58,6 +58,7 @@ type ( Labels []string // Label map Link string // Git repo link NoCache bool // Docker build no-cache + Secret string // secret keypair AddHost []string // Docker build add-host Quiet bool // Docker build quiet } @@ -72,27 +73,31 @@ type ( CardPath string // Card path to write file to } - Inspect []struct { - ID string `json:"Id"` - RepoTags []string `json:"RepoTags"` - RepoDigests []interface{} `json:"RepoDigests"` - Parent string `json:"Parent"` - Comment string `json:"Comment"` - Created time.Time `json:"Created"` - Container string `json:"Container"` - DockerVersion string `json:"DockerVersion"` - Author string `json:"Author"` - Architecture string `json:"Architecture"` - Os string `json:"Os"` - Size int `json:"Size"` - VirtualSize int `json:"VirtualSize"` - Metadata struct { + Card []struct { + ID string `json:"Id"` + RepoTags []string `json:"RepoTags"` + ParsedRepoTags []TagStruct `json:"ParsedRepoTags"` + RepoDigests []interface{} `json:"RepoDigests"` + Parent string `json:"Parent"` + Comment string `json:"Comment"` + Created time.Time `json:"Created"` + Container string `json:"Container"` + DockerVersion string `json:"DockerVersion"` + Author string `json:"Author"` + Architecture string `json:"Architecture"` + Os string `json:"Os"` + Size int `json:"Size"` + VirtualSize int `json:"VirtualSize"` + Metadata struct { LastTagTime time.Time `json:"LastTagTime"` } `json:"Metadata"` SizeString string VirtualSizeString string Time string } + TagStruct struct { + Tag string `json:"Tag"` + } ) // Exec executes the plugin step @@ -175,7 +180,7 @@ func (p Plugin) Exec() error { for _, tag := range p.Build.Tags { cmds = append(cmds, commandTag(p.Build, tag)) // docker tag - if p.Dryrun == false { + if !p.Dryrun { cmds = append(cmds, commandPush(p.Build, tag)) // docker push } } @@ -297,6 +302,9 @@ func commandBuild(build Build) *exec.Cmd { for _, host := range build.AddHost { args = append(args, "--add-host", host) } + if build.Secret != "" { + args = append(args, "--secret", build.Secret) + } if build.Target != "" { args = append(args, "--target", build.Target) } @@ -328,6 +336,10 @@ func commandBuild(build Build) *exec.Cmd { } } + // we need to enable buildkit, for secret support + if build.Secret != "" { + os.Setenv("DOCKER_BUILDKIT", "1") + } return exec.Command(dockerExe, args...) } diff --git a/docs/card.data.json b/docs/card.data.json new file mode 100644 index 0000000..3deeebf --- /dev/null +++ b/docs/card.data.json @@ -0,0 +1,40 @@ +{ + "Id": "sha256:3b0709c9afb41629c79c93355feed114d08a8c1bedd975eb53af08f4b867fd91", + "RepoTags": [ + "798a0dae10d63d281eff4c06eaa12001ffd23740:latest", + "tphoney/test:latest" + ], + "ParsedRepoTags": [ + { + "Tag": "" + }, + { + "Tag": "" + }, + { + "Tag": "798a0dae10d63d281eff4c06eaa12001ffd23740:latest" + }, + { + "Tag": "tphoney/test:latest" + } + ], + "RepoDigests": [ + "tphoney/test@sha256:93f8b95aaae7d194208b72e94a3a90544b00c8f2ad45aeb89d81a0c6ccbc5e19" + ], + "Parent": "sha256:493aa330a5929027dd8ecded9fa8c473a1508d17c0fd7d6a94a7f197f8d22c60", + "Comment": "", + "Created": "2022-02-16T11:13:40.8956582Z", + "Container": "a57c0ca4dd2e081df8758e00549f7abe83803f1a1a7aaaf1cd8e685a5eb5a097", + "DockerVersion": "20.10.9", + "Author": "", + "Architecture": "amd64", + "Os": "linux", + "Size": 14045949, + "VirtualSize": 14045949, + "Metadata": { + "LastTagTime": "2022-02-16T11:13:40.9433973Z" + }, + "SizeString": "13.40MB", + "VirtualSizeString": "13.40MB", + "Time": "2022-02-16T11:13:40Z" +} \ No newline at end of file diff --git a/docs/card.json b/docs/card.json index fd55544..65f612a 100644 --- a/docs/card.json +++ b/docs/card.json @@ -51,19 +51,22 @@ { "type": "TextBlock", "weight": "Lighter", - "text": "OS/ARCH", + "text": "TAGS", "wrap": true, "size": "Small", "isSubtle": true, "spacing": "Medium" }, { - "type": "TextBlock", - "text": "${OS}/${Architecture}", - "wrap": true, - "size": "Small", + "type": "FactSet", + "facts": [ + { + "title": "-", + "value": "${Tag}" + } + ], "spacing": "Small", - "weight": "Bolder" + "$data": "${ParsedRepoTags}" } ], "separator": true, @@ -124,4 +127,4 @@ ], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.5" -} +} \ No newline at end of file diff --git a/docs/sample_data.json b/docs/sample_data.json deleted file mode 100644 index 2398fbc..0000000 --- a/docs/sample_data.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "Id": "sha256:fec8cfc9f8eb4ed6bda3e83cea97c1365c53e261d07b9f47f3429c5fa879c414", - "RepoTags": [ - "7ee96c0c66e9fa7905952b5fcf5b07461bdde833:latest", - "tphoney/test:latest" - ], - "RepoDigests": [ - "tphoney/test@sha256:96e93bd69d3b4a3863a34800db2f2aa087a861d5ce0460b5932f2b7474f10a0a" - ], - "Parent": "sha256:618905d1de06873c5c59dee713977d68973fc2b497bc073108c9ce35c79019b1", - "Comment": "", - "Created": "2022-01-19T12:16:27.4679394Z", - "Container": "e09f5b26c8d454e24b738a2b38ec8ebda740bddfb872e512ace1cca3ea2d40a1", - "DockerVersion": "20.10.9", - "Author": "", - "Architecture": "amd64", - "Os": "linux", - "Size": 13195839, - "VirtualSize": 13195839, - "Metadata": { - "LastTagTime": "2022-01-19T12:16:27.5085833Z" - }, - "SizeString": "12.58MB", - "VirtualSizeString": "12.58MB", - "Time": "2022-01-19T12:16:27Z" -} From 332b73d3b0b9df14ab9d9fcd6418138f9b910aec Mon Sep 17 00:00:00 2001 From: TP Honey Date: Wed, 23 Feb 2022 11:55:46 +0000 Subject: [PATCH 27/27] (DRON-237) cards add link to image repo, minor cleanup --- card.go | 21 ++++++++++++++++++++- docker.go | 1 + docs/card.data.json | 3 ++- docs/card.json | 18 +++++++++++++----- go.mod | 1 + go.sum | 3 ++- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/card.go b/card.go index edb2a4f..9702f52 100644 --- a/card.go +++ b/card.go @@ -8,6 +8,8 @@ import ( "io/ioutil" "os" "os/exec" + "path" + "strings" "time" "github.com/drone/drone-go/drone" @@ -36,7 +38,9 @@ func (p Plugin) writeCard() error { for _, tag := range inspect.RepoTags { sliceTagStruct = append(sliceTagStruct, TagStruct{Tag: tag}) } - inspect.ParsedRepoTags = sliceTagStruct + inspect.ParsedRepoTags = sliceTagStruct[1:] // remove the first tag which is always "hash:latest" + // create the url from repo and registry + inspect.URL = mapRegistryToURL(p.Daemon.Registry, p.Build.Repo) cardData, _ := json.Marshal(inspect) card := drone.CardInput{ @@ -67,3 +71,18 @@ func writeCardTo(out io.Writer, data []byte) { io.WriteString(out, "\u001B]0m") io.WriteString(out, "\n") } + +func mapRegistryToURL(registry, repo string) (url string) { + url = "https://" + var domain string + if strings.Contains(registry, "amazonaws.com") { + domain = "gallery.ecr.aws/" + } else if strings.Contains(registry, "gcr.io") { + domain = "console.cloud.google.com/gcr/images" + } else { + // default to docker hub + domain = "hub.docker.com/r/" + } + url = path.Join(url, domain, repo) + return url +} diff --git a/docker.go b/docker.go index cf86afa..9d53c24 100644 --- a/docker.go +++ b/docker.go @@ -94,6 +94,7 @@ type ( SizeString string VirtualSizeString string Time string + URL string `json:"URL"` } TagStruct struct { Tag string `json:"Tag"` diff --git a/docs/card.data.json b/docs/card.data.json index 3deeebf..fbfecb7 100644 --- a/docs/card.data.json +++ b/docs/card.data.json @@ -36,5 +36,6 @@ }, "SizeString": "13.40MB", "VirtualSizeString": "13.40MB", - "Time": "2022-02-16T11:13:40Z" + "Time": "2022-02-16T11:13:40Z", + "URL": "http://hub.docker.com/repositories/tphoney/test/" } \ No newline at end of file diff --git a/docs/card.json b/docs/card.json index 65f612a..01861f9 100644 --- a/docs/card.json +++ b/docs/card.json @@ -61,12 +61,15 @@ "type": "FactSet", "facts": [ { - "title": "-", - "value": "${Tag}" + "title": "${Tag}", + "value": "" } ], "spacing": "Small", - "$data": "${ParsedRepoTags}" + "$data": "${ParsedRepoTags}", + "wrap": true, + "size": "Small", + "weight": "Bolder" } ], "separator": true, @@ -88,7 +91,6 @@ "spacing": "Small", "text": "${SizeString}", "wrap": true, - "size": "Small", "weight": "Bolder" } ], @@ -112,7 +114,6 @@ "spacing": "Small", "text": "{{DATE(${Time})}} - {{TIME(${Time})}}", "wrap": true, - "size": "Small", "weight": "Bolder" } ], @@ -125,6 +126,13 @@ "separator": true } ], + "actions": [ + { + "type": "Action.OpenUrl", + "title": "Go to image", + "url": "${url}" + } + ], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.5" } \ No newline at end of file diff --git a/go.mod b/go.mod index 4ab477e..95a4720 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 // indirect golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect ) go 1.17 diff --git a/go.sum b/go.sum index 53c1733..795ef38 100644 --- a/go.sum +++ b/go.sum @@ -38,5 +38,6 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=