mirror of
https://github.com/thegeeklab/drone-docker.git
synced 2024-11-23 13:20:40 +00:00
ci: refactor build tools and ci setup (#40)
This commit is contained in:
parent
5174f15dcc
commit
c9165a9eea
@ -8,14 +8,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 +24,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 +37,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 +49,7 @@ local PipelineTest = {
|
|||||||
],
|
],
|
||||||
volumes: [
|
volumes: [
|
||||||
{
|
{
|
||||||
name: 'gopath',
|
name: 'godeps',
|
||||||
temp: {},
|
temp: {},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -85,34 +72,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 && 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 .",
|
|
||||||
'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-linux-amd64) --help',
|
'$(find dist/ -executable -type f | grep drone-docker-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 +106,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',
|
||||||
},
|
},
|
||||||
@ -171,8 +138,7 @@ 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 ./cmd/drone-docker',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
57
.drone.yml
57
.drone.yml
@ -7,40 +7,32 @@ 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:
|
image_pull_secrets:
|
||||||
@ -64,28 +56,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 && 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 .
|
|
||||||
- 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-linux-amd64) --help
|
- $(find dist/ -executable -type f | grep drone-docker-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 +81,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}
|
||||||
@ -137,8 +113,7 @@ 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 ./cmd/drone-docker
|
|
||||||
|
|
||||||
- name: dryrun
|
- name: dryrun
|
||||||
image: plugins/docker:19
|
image: plugins/docker:19
|
||||||
@ -223,8 +198,7 @@ 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 ./cmd/drone-docker
|
|
||||||
|
|
||||||
- name: dryrun
|
- name: dryrun
|
||||||
image: plugins/docker:19
|
image: plugins/docker:19
|
||||||
@ -309,8 +283,7 @@ 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/arm/drone-docker ./cmd/drone-docker
|
|
||||||
|
|
||||||
- name: dryrun
|
- name: dryrun
|
||||||
image: plugins/docker:19
|
image: plugins/docker:19
|
||||||
@ -529,6 +502,6 @@ depends_on:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: db76ecc04bcecfd0bb265ed1bb5aba33a805c5977fa84e5d158eea6abec4aebc
|
hmac: 9ee9ec07028e26d74e30bb239266b01dd105621178225d50bf2a214712d816e9
|
||||||
|
|
||||||
...
|
...
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
/release/
|
/dist/
|
||||||
/drone-docker*
|
/drone-docker*
|
||||||
|
|
||||||
coverage.out
|
coverage.out
|
||||||
|
31
.golangci.yml
Normal file
31
.golangci.yml
Normal 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
96
Makefile
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# renovate: datasource=github-releases depName=mvdan/gofumpt
|
||||||
|
GOFUMPT_PACKAGE_VERSION := v0.3.0
|
||||||
|
# renovate: datasource=github-releases depName=golangci/golangci-lint
|
||||||
|
GOLANGCI_LINT_PACKAGE_VERSION := v1.45.1
|
||||||
|
|
||||||
|
EXECUTABLE := drone-docker
|
||||||
|
|
||||||
|
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)
|
@ -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",
|
Name: "drone-docker",
|
||||||
Usage: "build docker container with DinD",
|
Usage: "build docker container with DinD",
|
||||||
Version: version,
|
Version: BuildVersion,
|
||||||
Flags: append(settingsFlags(settings), urfave.Flags()...),
|
Flags: append(settingsFlags(settings), urfave.Flags()...),
|
||||||
Action: run(settings),
|
Action: run(settings),
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
// +build tools
|
|
||||||
|
|
||||||
package tools
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "golang.org/x/lint/golint"
|
|
||||||
_ "honnef.co/go/tools/cmd/staticcheck"
|
|
||||||
)
|
|
@ -18,6 +18,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 /bin/
|
ADD dist/drone-docker /bin/
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]
|
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]
|
||||||
|
@ -18,6 +18,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 /bin/
|
ADD dist/drone-docker /bin/
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]
|
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]
|
||||||
|
@ -18,6 +18,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 /bin/
|
ADD dist/drone-docker /bin/
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]
|
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]
|
||||||
|
7
go.mod
7
go.mod
@ -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
21
go.sum
@ -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=
|
|
||||||
|
@ -5,9 +5,11 @@ 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"
|
||||||
|
dockerHome = "/root/.docker/"
|
||||||
|
)
|
||||||
|
|
||||||
func (p Plugin) startDaemon() {
|
func (p Plugin) startDaemon() {
|
||||||
cmd := commandDaemon(p.settings.Daemon)
|
cmd := commandDaemon(p.settings.Daemon)
|
||||||
@ -20,6 +22,6 @@ func (p Plugin) startDaemon() {
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
trace(cmd)
|
trace(cmd)
|
||||||
cmd.Run()
|
_ = cmd.Run()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -125,10 +125,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 := ioutil.WriteFile(path, []byte(p.settings.Login.Config), 0600)
|
err := ioutil.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)
|
||||||
}
|
}
|
||||||
@ -186,13 +188,15 @@ func (p *Plugin) Execute() error {
|
|||||||
trace(cmd)
|
trace(cmd)
|
||||||
|
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil && isCommandPull(cmd.Args) {
|
|
||||||
|
switch {
|
||||||
|
case err != nil && isCommandPull(cmd.Args):
|
||||||
fmt.Printf("Could not pull cache-from image %s. Ignoring...\n", cmd.Args[2])
|
fmt.Printf("Could not pull cache-from image %s. Ignoring...\n", cmd.Args[2])
|
||||||
} else if err != nil && isCommandPrune(cmd.Args) {
|
case err != nil && isCommandPrune(cmd.Args):
|
||||||
fmt.Printf("Could not prune system containers. Ignoring...\n")
|
fmt.Printf("Could not prune system containers. Ignoring...\n")
|
||||||
} else if err != nil && isCommandRmi(cmd.Args) {
|
case err != nil && isCommandRmi(cmd.Args):
|
||||||
fmt.Printf("Could not remove image %s. Ignoring...\n", cmd.Args[2])
|
fmt.Printf("Could not remove image %s. Ignoring...\n", cmd.Args[2])
|
||||||
} else if err != nil {
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user