0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-24 12:50:41 +00:00

ci: refactor build tools and ci setup (#90)

This commit is contained in:
Robert Kaussow 2022-04-25 12:51:42 +02:00 committed by GitHub
parent 770a1cd1ab
commit fef64f2b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 198 additions and 196 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
*
!dist/

View File

@ -1,6 +1,5 @@
local PipelineTest = { local PipelineTest = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'test', name: 'test',
platform: { platform: {
os: 'linux', os: 'linux',
@ -8,14 +7,14 @@ local PipelineTest = {
}, },
steps: [ steps: [
{ {
name: 'staticcheck', name: 'deps',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...', 'make deps',
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
path: '/go', path: '/go',
}, },
], ],
@ -24,24 +23,11 @@ local PipelineTest = {
name: 'lint', name: 'lint',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...', 'make lint',
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
path: '/go',
},
],
},
{
name: 'vet',
image: 'golang:1.18',
commands: [
'go vet ./...',
],
volumes: [
{
name: 'gopath',
path: '/go', path: '/go',
}, },
], ],
@ -50,11 +36,11 @@ local PipelineTest = {
name: 'test', name: 'test',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'go test -cover ./...', 'make test',
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
path: '/go', path: '/go',
}, },
], ],
@ -62,7 +48,7 @@ local PipelineTest = {
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
temp: {}, temp: {},
}, },
], ],
@ -74,7 +60,6 @@ local PipelineTest = {
local PipelineBuildBinaries = { local PipelineBuildBinaries = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-binaries', name: 'build-binaries',
platform: { platform: {
os: 'linux', os: 'linux',
@ -85,34 +70,14 @@ local PipelineBuildBinaries = {
name: 'build', name: 'build',
image: 'techknowlogick/xgo:go-1.18.x', image: 'techknowlogick/xgo:go-1.18.x',
commands: [ commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', 'make release',
'mkdir -p release/',
"cd cmd/drone-docker-buildx && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-docker-buildx .",
'mv /build/* /drone/src/release/',
'ls -l /drone/src/release/',
], ],
}, },
{ {
name: 'executable', name: 'executable',
image: 'alpine', image: 'alpine',
commands: [ commands: [
'$(find release/ -executable -type f | grep drone-docker-buildx-linux-amd64) --help', '$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
],
},
{
name: 'compress',
image: 'alpine',
commands: [
'apk add upx',
'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;',
'ls -lh release/',
],
},
{
name: 'checksum',
image: 'alpine',
commands: [
'cd release/ && sha256sum * > sha256sum.txt',
], ],
}, },
{ {
@ -139,7 +104,7 @@ local PipelineBuildBinaries = {
api_key: { api_key: {
from_secret: 'github_token', from_secret: 'github_token',
}, },
files: ['release/*'], files: ['dist/*'],
title: '${DRONE_TAG}', title: '${DRONE_TAG}',
note: 'CHANGELOG.md', note: 'CHANGELOG.md',
}, },
@ -160,7 +125,6 @@ local PipelineBuildBinaries = {
local PipelineBuildContainer(arch='amd64') = { local PipelineBuildContainer(arch='amd64') = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-container-' + arch, name: 'build-container-' + arch,
platform: { platform: {
os: 'linux', os: 'linux',
@ -171,20 +135,16 @@ local PipelineBuildContainer(arch='amd64') = {
name: 'build', name: 'build',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', 'make build',
'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/drone-docker-buildx ./cmd/drone-docker-buildx',
], ],
}, },
{ {
name: 'dryrun', name: 'dryrun',
image: 'plugins/docker:19', image: 'thegeeklab/drone-docker:19',
settings: { settings: {
config: { from_secret: 'docker_config' },
dry_run: true, dry_run: true,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
repo: 'thegeeklab/${DRONE_REPO_NAME}', repo: 'thegeeklab/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
}, },
depends_on: ['build'], depends_on: ['build'],
when: { when: {
@ -193,9 +153,8 @@ local PipelineBuildContainer(arch='amd64') = {
}, },
{ {
name: 'publish-dockerhub', name: 'publish-dockerhub',
image: 'plugins/docker:19', image: 'thegeeklab/drone-docker:19',
settings: { settings: {
config: { from_secret: 'docker_config' },
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
@ -210,9 +169,8 @@ local PipelineBuildContainer(arch='amd64') = {
}, },
{ {
name: 'publish-quay', name: 'publish-quay',
image: 'plugins/docker:19', image: 'thegeeklab/drone-docker:19',
settings: { settings: {
config: { from_secret: 'docker_config' },
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
@ -291,7 +249,6 @@ local PipelineDocs = {
local PipelineNotifications = { local PipelineNotifications = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'notifications', name: 'notifications',
platform: { platform: {
os: 'linux', os: 'linux',

View File

@ -7,45 +7,34 @@ platform:
arch: amd64 arch: amd64
steps: steps:
- name: staticcheck - name: deps
image: golang:1.18 image: golang:1.18
commands: commands:
- go run honnef.co/go/tools/cmd/staticcheck ./... - make deps
volumes: volumes:
- name: gopath - name: godeps
path: /go path: /go
- name: lint - name: lint
image: golang:1.18 image: golang:1.18
commands: commands:
- go run golang.org/x/lint/golint -set_exit_status ./... - make lint
volumes: volumes:
- name: gopath - name: godeps
path: /go
- name: vet
image: golang:1.18
commands:
- go vet ./...
volumes:
- name: gopath
path: /go path: /go
- name: test - name: test
image: golang:1.18 image: golang:1.18
commands: commands:
- go test -cover ./... - make test
volumes: volumes:
- name: gopath - name: godeps
path: /go path: /go
volumes: volumes:
- name: gopath - name: godeps
temp: {} temp: {}
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -64,28 +53,12 @@ steps:
- name: build - name: build
image: techknowlogick/xgo:go-1.18.x image: techknowlogick/xgo:go-1.18.x
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make release
- mkdir -p release/
- cd cmd/drone-docker-buildx && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-docker-buildx .
- mv /build/* /drone/src/release/
- ls -l /drone/src/release/
- name: executable - name: executable
image: alpine image: alpine
commands: commands:
- $(find release/ -executable -type f | grep drone-docker-buildx-linux-amd64) --help - $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
- name: compress
image: alpine
commands:
- apk add upx
- find release/ -maxdepth 1 -executable -type f -exec upx {} \;
- ls -lh release/
- name: checksum
image: alpine
commands:
- cd release/ && sha256sum * > sha256sum.txt
- name: changelog-generate - name: changelog-generate
image: thegeeklab/git-chglog image: thegeeklab/git-chglog
@ -105,7 +78,7 @@ steps:
api_key: api_key:
from_secret: github_token from_secret: github_token
files: files:
- release/* - dist/*
note: CHANGELOG.md note: CHANGELOG.md
overwrite: true overwrite: true
title: ${DRONE_TAG} title: ${DRONE_TAG}
@ -113,9 +86,6 @@ steps:
ref: ref:
- refs/tags/** - refs/tags/**
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -137,21 +107,14 @@ steps:
- name: build - name: build
image: golang:1.18 image: golang:1.18
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make build
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-docker-buildx ./cmd/drone-docker-buildx
- name: dryrun - name: dryrun
image: plugins/docker:19 image: thegeeklab/drone-docker:19
settings: settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
dry_run: true dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
@ -159,12 +122,10 @@ steps:
- build - build
- name: publish-dockerhub - name: publish-dockerhub
image: plugins/docker:19 image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
password: password:
from_secret: docker_password from_secret: docker_password
@ -179,12 +140,10 @@ steps:
- dryrun - dryrun
- name: publish-quay - name: publish-quay
image: plugins/docker:19 image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
password: password:
from_secret: quay_password from_secret: quay_password
@ -199,9 +158,6 @@ steps:
depends_on: depends_on:
- dryrun - dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -223,21 +179,14 @@ steps:
- name: build - name: build
image: golang:1.18 image: golang:1.18
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make build
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-docker-buildx ./cmd/drone-docker-buildx
- name: dryrun - name: dryrun
image: plugins/docker:19 image: thegeeklab/drone-docker:19
settings: settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
dry_run: true dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
@ -245,12 +194,10 @@ steps:
- build - build
- name: publish-dockerhub - name: publish-dockerhub
image: plugins/docker:19 image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
password: password:
from_secret: docker_password from_secret: docker_password
@ -265,12 +212,10 @@ steps:
- dryrun - dryrun
- name: publish-quay - name: publish-quay
image: plugins/docker:19 image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
password: password:
from_secret: quay_password from_secret: quay_password
@ -285,9 +230,6 @@ steps:
depends_on: depends_on:
- dryrun - dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -426,9 +368,6 @@ steps:
- success - success
- failure - failure
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -442,6 +381,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: 523e01fa310fee3429dcda85bbb388d43f40b0d47ee967730831bdfc0dd09e7d hmac: 38f817e0b5286433782c89964da2af89b3ef2dbc60db879363cc5b9b92bc85b5
... ...

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/dist/
/release/ /release/
/drone-docker-buildx* /drone-docker-buildx*

31
.golangci.yml Normal file
View File

@ -0,0 +1,31 @@
linters:
enable:
- gosimple
- deadcode
- typecheck
- govet
- errcheck
- staticcheck
- unused
- structcheck
- varcheck
- dupl
- gofmt
- misspell
- gocritic
- bidichk
- ineffassign
- revive
- gofumpt
- depguard
enable-all: false
disable-all: true
fast: false
run:
timeout: 3m
linters-settings:
gofumpt:
extra-rules: true
lang-version: "1.18"

96
Makefile Normal file
View File

@ -0,0 +1,96 @@
# renovate: datasource=github-releases depName=mvdan/gofumpt
GOFUMPT_PACKAGE_VERSION := v0.3.1
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_PACKAGE_VERSION := v1.45.2
EXECUTABLE := drone-docker-buildx
DIST := dist
DIST_DIRS := $(DIST)
IMPORT := github.com/thegeeklab/$(EXECUTABLE)
GO ?= go
CWD ?= $(shell pwd)
PACKAGES ?= $(shell go list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f)
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION)
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION)
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GENERATE ?=
XGO_VERSION := go-1.18.x
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
TAGS ?= netgo
ifndef VERSION
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
else
VERSION ?= $(shell git rev-parse --short HEAD)
endif
endif
ifndef DATE
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
endif
LDFLAGS += -s -w -X "main.BuildVersion=$(VERSION)" -X "main.BuildDate=$(DATE)"
.PHONY: all
all: clean build
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(DIST_DIRS)
.PHONY: fmt
fmt:
$(GO) run $(GOFUMPT_PACKAGE) -extra -w $(SOURCES)
.PHONY: golangci-lint
golangci-lint:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
.PHONY: lint
lint: golangci-lint
.PHONY: generate
generate:
$(GO) generate $(GENERATE)
.PHONY: test
test:
$(GO) test -v -coverprofile coverage.out $(PACKAGES)
.PHONY: build
build: $(DIST)/$(EXECUTABLE)
$(DIST)/$(EXECUTABLE): $(SOURCES)
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: xgo
xgo: | $(DIST_DIRS)
$(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
cp /build/* $(CWD)/$(DIST)
ls -l $(CWD)/$(DIST)
.PHONY: checksum
checksum:
cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
ls -l $(CWD)/$(DIST)
.PHONY: release
release: xgo checksum
.PHONY: deps
deps:
$(GO) mod download
$(GO) install $(GOFUMPT_PACKAGE)
$(GO) install $(GOLANGCI_LINT_PACKAGE)
$(GO) install $(XGO_PACKAGE)

View File

@ -31,7 +31,7 @@ export GOARCH=amd64
export CGO_ENABLED=0 export CGO_ENABLED=0
export GO111MODULE=on export GO111MODULE=on
go build -v -a -tags netgo -o release/amd64/drone-docker-buildx ./cmd/drone-docker-buildx/ make build
``` ```
Build the Docker image with the following command: Build the Docker image with the following command:

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"os" "os"
"github.com/joho/godotenv" "github.com/joho/godotenv"
@ -11,19 +12,26 @@ import (
"github.com/drone-plugins/drone-plugin-lib/urfave" "github.com/drone-plugins/drone-plugin-lib/urfave"
) )
var version = "unknown" var (
BuildVersion = "devel"
BuildDate = "00000000"
)
func main() { func main() {
settings := &plugin.Settings{} settings := &plugin.Settings{}
if _, err := os.Stat("/run/drone/env"); err == nil { if _, err := os.Stat("/run/drone/env"); err == nil {
godotenv.Overload("/run/drone/env") _ = godotenv.Overload("/run/drone/env")
}
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate)
} }
app := &cli.App{ app := &cli.App{
Name: "drone-docker-buildx", Name: "drone-docker-buildx",
Usage: "build docker container with DinD and buildx", Usage: "build docker container with DinD and buildx",
Version: version, Version: BuildVersion,
Flags: append(settingsFlags(settings), urfave.Flags()...), Flags: append(settingsFlags(settings), urfave.Flags()...),
Action: run(settings), Action: run(settings),
} }

View File

@ -1,8 +0,0 @@
// +build tools
package tools
import (
_ "golang.org/x/lint/golint"
_ "honnef.co/go/tools/cmd/staticcheck"
)

View File

@ -22,6 +22,6 @@ RUN apk --update add --virtual .build-deps curl && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \
rm -rf /tmp/* rm -rf /tmp/*
ADD release/amd64/drone-docker-buildx /bin/ ADD dist/drone-docker-buildx /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"] ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"]

View File

@ -22,6 +22,6 @@ RUN apk --update add --virtual .build-deps curl && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \
rm -rf /tmp/* rm -rf /tmp/*
ADD release/arm/drone-docker-buildx /bin/ ADD dist/drone-docker-buildx /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"] ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"]

View File

@ -22,6 +22,6 @@ RUN apk --update add --virtual .build-deps curl && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \
rm -rf /tmp/* rm -rf /tmp/*
ADD release/arm64/drone-docker-buildx /bin/ ADD dist/drone-docker-buildx /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"] ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker-buildx"]

7
go.mod
View File

@ -8,17 +8,10 @@ require (
github.com/joho/godotenv v1.4.0 github.com/joho/godotenv v1.4.0
github.com/sirupsen/logrus v1.8.1 github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli/v2 v2.4.0 github.com/urfave/cli/v2 v2.4.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
honnef.co/go/tools v0.3.0
) )
require ( require (
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
) )

21
go.sum
View File

@ -1,6 +1,4 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= 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/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@ -31,36 +29,17 @@ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2
github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I= github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I=
github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg= github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb h1:fP6C8Xutcp5AlakmT/SkQot0pMicROAsEX7OfNPuG10=
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY= golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e h1:lVQAEpHVTmp9WjosvG0WcHRqP3JZv97KkBX4YDdaDfU=
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.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 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70=

View File

@ -5,10 +5,12 @@ import (
"os" "os"
) )
const dockerExe = "/usr/local/bin/docker" const (
const dockerdExe = "/usr/local/bin/dockerd" dockerExe = "/usr/local/bin/docker"
const dockerHome = "/root/.docker/" dockerdExe = "/usr/local/bin/dockerd"
const buildkitConfig = "/tmp/buildkit.json" dockerHome = "/root/.docker/"
buildkitConfig = "/tmp/buildkit.json"
)
func (p Plugin) startDaemon() { func (p Plugin) startDaemon() {
cmd := commandDaemon(p.settings.Daemon) cmd := commandDaemon(p.settings.Daemon)
@ -21,6 +23,6 @@ func (p Plugin) startDaemon() {
} }
go func() { go func() {
trace(cmd) trace(cmd)
cmd.Run() _ = cmd.Run()
}() }()
} }

View File

@ -119,7 +119,7 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
} }
if len(build.Platforms.Value()) > 0 { if len(build.Platforms.Value()) > 0 {
args = append(args, "--platform", strings.Join(build.Platforms.Value()[:], ",")) args = append(args, "--platform", strings.Join(build.Platforms.Value(), ","))
} }
for _, arg := range build.Tags.Value() { for _, arg := range build.Tags.Value() {

View File

@ -121,10 +121,12 @@ func (p *Plugin) Execute() error {
// Create Auth Config File // Create Auth Config File
if p.settings.Login.Config != "" { if p.settings.Login.Config != "" {
os.MkdirAll(dockerHome, 0600) if err := os.MkdirAll(dockerHome, 0o600); err != nil {
return fmt.Errorf("failed to create docker home: %s", err)
}
path := filepath.Join(dockerHome, "config.json") path := filepath.Join(dockerHome, "config.json")
err := os.WriteFile(path, []byte(p.settings.Login.Config), 0600) err := os.WriteFile(path, []byte(p.settings.Login.Config), 0o600)
if err != nil { if err != nil {
return fmt.Errorf("error writing config.json: %s", err) return fmt.Errorf("error writing config.json: %s", err)
} }
@ -140,7 +142,7 @@ func (p *Plugin) Execute() error {
} }
if p.settings.Daemon.BuildkitConfig != "" { if p.settings.Daemon.BuildkitConfig != "" {
err := os.WriteFile(buildkitConfig, []byte(p.settings.Daemon.BuildkitConfig), 0600) err := os.WriteFile(buildkitConfig, []byte(p.settings.Daemon.BuildkitConfig), 0o600)
if err != nil { if err != nil {
return fmt.Errorf("error writing buildkit.json: %s", err) return fmt.Errorf("error writing buildkit.json: %s", err)
} }

View File

@ -27,7 +27,7 @@ func DefaultTagSuffix(ref, suffix string) ([]string, error) {
return tags, nil return tags, nil
} }
func splitOff(input string, delim string) string { func splitOff(input, delim string) string {
parts := strings.SplitN(input, delim, 2) parts := strings.SplitN(input, delim, 2)
if len(parts) == 2 { if len(parts) == 2 {

View File

@ -6,7 +6,7 @@ import (
) )
func Test_stripTagPrefix(t *testing.T) { func Test_stripTagPrefix(t *testing.T) {
var tests = []struct { tests := []struct {
Before string Before string
After string After string
}{ }{
@ -24,7 +24,7 @@ func Test_stripTagPrefix(t *testing.T) {
} }
func TestDefaultTags(t *testing.T) { func TestDefaultTags(t *testing.T) {
var tests = []struct { tests := []struct {
Before string Before string
After []string After []string
}{ }{
@ -50,7 +50,7 @@ func TestDefaultTags(t *testing.T) {
} }
func TestDefaultTagsError(t *testing.T) { func TestDefaultTagsError(t *testing.T) {
var tests = []string{ tests := []string{
"refs/tags/x1.0.0", "refs/tags/x1.0.0",
"refs/tags/20190203", "refs/tags/20190203",
} }
@ -64,7 +64,7 @@ func TestDefaultTagsError(t *testing.T) {
} }
func TestDefaultTagSuffix(t *testing.T) { func TestDefaultTagSuffix(t *testing.T) {
var tests = []struct { tests := []struct {
Before string Before string
Suffix string Suffix string
After []string After []string