mirror of
https://github.com/thegeeklab/wp-ansible.git
synced 2024-11-21 23:50:40 +00:00
ci: refactor build tools and ci setup (#76)
This commit is contained in:
parent
00611d6e46
commit
847f8e29a4
@ -1,2 +1,2 @@
|
||||
*
|
||||
!release/
|
||||
!dist/
|
||||
|
342
.drone.star
342
.drone.star
@ -1,13 +1,14 @@
|
||||
def main(ctx):
|
||||
before = testing(ctx)
|
||||
before = test(ctx)
|
||||
|
||||
stages = [
|
||||
linux(ctx, "amd64"),
|
||||
linux(ctx, "arm64"),
|
||||
linux(ctx, "arm"),
|
||||
docker(ctx, "amd64"),
|
||||
docker(ctx, "arm64"),
|
||||
docker(ctx, "arm"),
|
||||
build(ctx),
|
||||
]
|
||||
|
||||
after = manifest(ctx) + pushrm(ctx) + release(ctx) + notification(ctx)
|
||||
after = manifest(ctx) + pushrm(ctx)
|
||||
|
||||
for b in before:
|
||||
for s in stages:
|
||||
@ -19,26 +20,38 @@ def main(ctx):
|
||||
|
||||
return before + stages + after
|
||||
|
||||
def testing(ctx):
|
||||
def test(ctx):
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "testing",
|
||||
"name": "test",
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "amd64",
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "staticcheck",
|
||||
"name": "deps",
|
||||
"image": "golang:1.18",
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"go run honnef.co/go/tools/cmd/staticcheck ./...",
|
||||
"make deps",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "generate",
|
||||
"image": "golang:1.18",
|
||||
"commands": [
|
||||
"make generate",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
@ -47,24 +60,11 @@ def testing(ctx):
|
||||
"name": "lint",
|
||||
"image": "golang:1.18",
|
||||
"commands": [
|
||||
"go run golang.org/x/lint/golint -set_exit_status ./...",
|
||||
"make lint",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "vet",
|
||||
"image": "golang:1.18",
|
||||
"commands": [
|
||||
"go vet ./...",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
@ -73,11 +73,11 @@ def testing(ctx):
|
||||
"name": "test",
|
||||
"image": "golang:1.18",
|
||||
"commands": [
|
||||
"go test -cover ./...",
|
||||
"make test",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
@ -85,7 +85,7 @@ def testing(ctx):
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"name": "godeps",
|
||||
"temp": {},
|
||||
},
|
||||
],
|
||||
@ -98,75 +98,102 @@ def testing(ctx):
|
||||
},
|
||||
}]
|
||||
|
||||
def linux(ctx, arch):
|
||||
if ctx.build.event == "tag":
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-ansible ./cmd/drone-ansible' % (ctx.build.ref.replace("refs/tags/v", ""), arch),
|
||||
]
|
||||
else:
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-ansible ./cmd/drone-ansible' % (ctx.build.commit[0:8], arch),
|
||||
]
|
||||
|
||||
steps = [
|
||||
def build(ctx):
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "build-binaries",
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "amd64",
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "environment",
|
||||
"name": "generate",
|
||||
"image": "golang:1.18",
|
||||
"pull": "always",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": [
|
||||
"go version",
|
||||
"go env",
|
||||
"make generate",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"image": "golang:1.18",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
"image": "techknowlogick/xgo:go-1.18.x",
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"make release",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
"commands": build,
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "executable",
|
||||
"image": "golang:1.18",
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"./release/linux/%s/drone-ansible --help" % (arch),
|
||||
"$(find dist/ -executable -type f -iname drone-ansible-linux-amd64) --help",
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
if ctx.build.event != "pull_request":
|
||||
steps.append({
|
||||
"name": "docker",
|
||||
"image": "plugins/docker",
|
||||
{
|
||||
"name": "changelog",
|
||||
"image": "thegeeklab/git-chglog",
|
||||
"commands": [
|
||||
"git fetch -tq",
|
||||
"git-chglog --no-color --no-emoji %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"),
|
||||
"git-chglog --no-color --no-emoji -o CHANGELOG.md %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"),
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "publish",
|
||||
"image": "plugins/github-release",
|
||||
"pull": "always",
|
||||
"settings": {
|
||||
"dockerfile": "docker/Dockerfile.%s" % (arch),
|
||||
"repo": "owncloudci/%s" % (ctx.repo.name),
|
||||
"username": {
|
||||
"from_secret": "docker_username",
|
||||
"api_key": {
|
||||
"from_secret": "github_token",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "docker_password",
|
||||
"files": [
|
||||
"dist/*",
|
||||
],
|
||||
"note": "CHANGELOG.md",
|
||||
"title": ctx.build.ref.replace("refs/tags/", ""),
|
||||
"overwrite": True,
|
||||
},
|
||||
"auto_tag": True,
|
||||
"auto_tag_suffix": "%s" % (arch),
|
||||
"when": {
|
||||
"ref": [
|
||||
"refs/tags/**",
|
||||
],
|
||||
},
|
||||
})
|
||||
else:
|
||||
steps.append({
|
||||
"name": "dryrun",
|
||||
"image": "plugins/docker",
|
||||
"settings": {
|
||||
'dry_run': True,
|
||||
"dockerfile": "docker/Dockerfile.%s" % (arch),
|
||||
"repo": "owncloudci/%s" % (ctx.repo.name),
|
||||
"tags": "latest",
|
||||
},
|
||||
})
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"temp": {},
|
||||
},
|
||||
],
|
||||
"depends_on": [
|
||||
"test",
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def docker(ctx, arch):
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
@ -175,8 +202,87 @@ def linux(ctx, arch):
|
||||
"os": "linux",
|
||||
"arch": arch,
|
||||
},
|
||||
"steps": steps,
|
||||
"depends_on": [],
|
||||
"steps": [
|
||||
{
|
||||
"name": "generate",
|
||||
"image": "golang:1.18",
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"make generate",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"image": "golang:1.18",
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"make build",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"path": "/go",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "dryrun",
|
||||
"image": "plugins/docker:20",
|
||||
"pull": "always",
|
||||
"settings": {
|
||||
"dry_run": True,
|
||||
"dockerfile": "docker/Dockerfile.%s" % (arch),
|
||||
"repo": "owncloudci/%s" % (ctx.repo.name),
|
||||
"tags": "latest",
|
||||
},
|
||||
"when": {
|
||||
"ref": {
|
||||
"include": [
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "docker",
|
||||
"image": "plugins/docker:20",
|
||||
"pull": "always",
|
||||
"settings": {
|
||||
"username": {
|
||||
"from_secret": "registry_username",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "registry_password",
|
||||
},
|
||||
"auto_tag": True,
|
||||
"auto_tag_suffix": "%s" % (arch),
|
||||
"dockerfile": "docker/Dockerfile.%s" % (arch),
|
||||
"repo": "owncloudci/%s" % (ctx.repo.name),
|
||||
},
|
||||
"when": {
|
||||
"ref": {
|
||||
"exclude": [
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "godeps",
|
||||
"temp": {},
|
||||
},
|
||||
],
|
||||
"depends_on": [
|
||||
"test",
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
@ -250,83 +356,3 @@ def pushrm(ctx):
|
||||
"status": ["success"],
|
||||
},
|
||||
}]
|
||||
|
||||
def release(ctx):
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "release",
|
||||
"steps": [
|
||||
{
|
||||
"name": "changelog",
|
||||
"image": "thegeeklab/git-chglog",
|
||||
"commands": [
|
||||
"git fetch -tq",
|
||||
"git-chglog --no-color --no-emoji %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"),
|
||||
"git-chglog --no-color --no-emoji -o CHANGELOG.md %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"),
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"image": "plugins/github-release",
|
||||
"settings": {
|
||||
"api_key": {
|
||||
"from_secret": "github_token",
|
||||
},
|
||||
"note": "CHANGELOG.md",
|
||||
"overwrite": True,
|
||||
"title": ctx.build.ref.replace("refs/tags/", ""),
|
||||
},
|
||||
"when": {
|
||||
"ref": [
|
||||
"refs/tags/**",
|
||||
],
|
||||
},
|
||||
}
|
||||
],
|
||||
"depends_on": [
|
||||
"pushrm",
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
}]
|
||||
|
||||
def notification(ctx):
|
||||
return [{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "notify",
|
||||
"clone": {
|
||||
"disable": True,
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "notify",
|
||||
"image": "plugins/slack",
|
||||
"settings": {
|
||||
"webhook": {
|
||||
"from_secret": "private_rocketchat",
|
||||
},
|
||||
"channel": "builds",
|
||||
},
|
||||
}
|
||||
],
|
||||
"depends_on": [
|
||||
"release",
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
],
|
||||
"status": [
|
||||
"success",
|
||||
"failure",
|
||||
],
|
||||
},
|
||||
}]
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
/release/
|
||||
/dist/
|
||||
/drone-ansible*
|
||||
|
||||
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"
|
98
Makefile
Normal file
98
Makefile
Normal file
@ -0,0 +1,98 @@
|
||||
# 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
|
||||
|
||||
SHELL := bash
|
||||
NAME := drone-ansible
|
||||
IMPORT := github.com/owncloud-ci/$(NAME)
|
||||
DIST := dist
|
||||
DIST_DIRS := $(DIST)
|
||||
|
||||
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 ?= $(IMPORT)/pkg/templates
|
||||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||
XGO_VERSION := go-1.18.x
|
||||
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64
|
||||
|
||||
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: 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)/$(NAME)
|
||||
|
||||
$(DIST)/$(NAME): $(SOURCES)
|
||||
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(NAME)
|
||||
|
||||
$(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 $(NAME) --pkg cmd/$(NAME) .
|
||||
cp /build/* $(CWD)/$(DIST)
|
||||
ls -l $(CWD)/$(DIST)
|
||||
|
||||
.PHONY: checksum
|
||||
checksum:
|
||||
cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(NAME)-*),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)
|
@ -18,7 +18,7 @@ export GOARCH=amd64
|
||||
export CGO_ENABLED=0
|
||||
export GO111MODULE=on
|
||||
|
||||
go build -v -a -tags netgo -o release/linux/amd64/drone-ansible
|
||||
make build
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
@ -11,19 +12,26 @@ import (
|
||||
"github.com/drone-plugins/drone-plugin-lib/urfave"
|
||||
)
|
||||
|
||||
var version = "unknown"
|
||||
var (
|
||||
BuildVersion = "devel"
|
||||
BuildDate = "00000000"
|
||||
)
|
||||
|
||||
func main() {
|
||||
settings := &plugin.Settings{}
|
||||
|
||||
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{
|
||||
Name: "drone-ansible",
|
||||
Usage: "provision infrastructure with Ansible",
|
||||
Version: version,
|
||||
Version: BuildVersion,
|
||||
Flags: append(settingsFlags(settings), urfave.Flags()...),
|
||||
Action: run(settings),
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
//go:build tools
|
||||
// +build tools
|
||||
|
||||
package tools
|
||||
|
||||
import (
|
||||
_ "golang.org/x/lint/golint"
|
||||
_ "honnef.co/go/tools/cmd/staticcheck"
|
||||
)
|
@ -17,5 +17,6 @@ RUN apk add --no-cache bash git curl rsync openssh-client sshpass py3-pip py3-re
|
||||
pip3 install ansible=="${ANSIBLE_VERSION}" boto3 hcloud pywinrm && \
|
||||
apk del --no-cache python3-dev libffi-dev build-base
|
||||
|
||||
ADD release/linux/amd64/drone-ansible /bin/
|
||||
ADD dist/drone-ansible /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-ansible"]
|
||||
|
@ -17,5 +17,6 @@ RUN apk add --no-cache bash git curl rsync openssh-client sshpass py3-pip py3-re
|
||||
pip3 install ansible=="${ANSIBLE_VERSION}" boto3 hcloud pywinrm && \
|
||||
apk del --no-cache python3-dev libffi-dev build-base
|
||||
|
||||
ADD release/linux/arm/drone-ansible /bin/
|
||||
ADD dist/drone-ansible /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-ansible"]
|
||||
|
@ -17,5 +17,6 @@ RUN apk add --no-cache bash git curl rsync openssh-client sshpass py3-pip py3-re
|
||||
pip3 install ansible=="${ANSIBLE_VERSION}" boto3 hcloud pywinrm && \
|
||||
apk del --no-cache python3-dev libffi-dev build-base
|
||||
|
||||
ADD release/linux/arm64/drone-ansible /bin/
|
||||
ADD dist/drone-ansible /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-ansible"]
|
||||
|
7
go.mod
7
go.mod
@ -7,18 +7,11 @@ require (
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
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 (
|
||||
github.com/BurntSushi/toml v1.0.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // 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/tools v0.1.11-0.20220316014157-77aa08bb151a // 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 v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
|
||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
@ -31,35 +29,16 @@ 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/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-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-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/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-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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a h1:ofrrl6c6NG5/IOSx/R1cyiQxxjqlur0h/TvbUhkH0II=
|
||||
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/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/yaml.v2 v2.2.2/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=
|
||||
honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
|
||||
honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70=
|
||||
|
@ -13,8 +13,10 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var ansibleFolder = "/etc/ansible"
|
||||
var ansibleConfig = "/etc/ansible/ansible.cfg"
|
||||
var (
|
||||
ansibleFolder = "/etc/ansible"
|
||||
ansibleConfig = "/etc/ansible/ansible.cfg"
|
||||
)
|
||||
|
||||
var ansibleContent = `
|
||||
[defaults]
|
||||
@ -26,7 +28,7 @@ func (p *Plugin) ansibleConfig() error {
|
||||
return errors.Wrap(err, "failed to create ansible directory")
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(ansibleConfig, []byte(ansibleContent), 0600); err != nil {
|
||||
if err := ioutil.WriteFile(ansibleConfig, []byte(ansibleContent), 0o600); err != nil {
|
||||
return errors.Wrap(err, "failed to create ansible config")
|
||||
}
|
||||
|
||||
@ -35,7 +37,6 @@ func (p *Plugin) ansibleConfig() error {
|
||||
|
||||
func (p *Plugin) privateKey() error {
|
||||
tmpfile, err := ioutil.TempFile("", "privateKey")
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create private key file")
|
||||
}
|
||||
@ -54,7 +55,6 @@ func (p *Plugin) privateKey() error {
|
||||
|
||||
func (p *Plugin) vaultPass() error {
|
||||
tmpfile, err := ioutil.TempFile("", "vaultPass")
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create vault password file")
|
||||
}
|
||||
@ -72,13 +72,10 @@ func (p *Plugin) vaultPass() error {
|
||||
}
|
||||
|
||||
func (p *Plugin) playbooks() error {
|
||||
var (
|
||||
playbooks []string
|
||||
)
|
||||
var playbooks []string
|
||||
|
||||
for _, p := range p.settings.Playbooks.Value() {
|
||||
files, err := filepath.Glob(p)
|
||||
|
||||
if err != nil {
|
||||
playbooks = append(playbooks, p)
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user