Compare commits
31 Commits
Author | SHA1 | Date |
---|---|---|
Robert Kaussow | a45a5c4307 | |
renovate[bot] | 97cee89e12 | |
renovate[bot] | e5abbd2d67 | |
renovate[bot] | 00a13d659b | |
renovate[bot] | 40ce9ed5ae | |
renovate[bot] | 51aadf6ebd | |
renovate[bot] | 88194e8563 | |
renovate[bot] | ffb10d13dd | |
renovate[bot] | 729a5111b1 | |
renovate[bot] | 0d8e847b60 | |
Robert Kaussow | b715776ddb | |
renovate[bot] | 8d5a2c156c | |
renovate[bot] | 6f50fad667 | |
renovate[bot] | b68c348e7f | |
renovate[bot] | 2e8c83c913 | |
Robert Kaussow | d1b7baf918 | |
Robert Kaussow | 5f5cc89efb | |
Robert Kaussow | 6b1b8825af | |
renovate[bot] | 50dcca3546 | |
Robert Kaussow | 8ac84bd4c4 | |
renovate[bot] | 2c054944d9 | |
Robert Kaussow | ea3767aa9b | |
Robert Kaussow | 45c92776d1 | |
renovate[bot] | c0e70b89eb | |
Robert Kaussow | 9bf0cbdf85 | |
renovate[bot] | 83dd67c25f | |
renovate[bot] | 24c3f1b924 | |
renovate[bot] | f629ca7788 | |
renovate[bot] | 7e2f322188 | |
renovate[bot] | af7d7704a1 | |
renovate[bot] | 7828a7a881 |
178
.drone.jsonnet
178
.drone.jsonnet
|
@ -1,178 +0,0 @@
|
|||
local PipelineTest(deps=[],) = {
|
||||
kind: 'pipeline',
|
||||
name: 'test',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'deps',
|
||||
image: 'golang:1.19',
|
||||
commands: [
|
||||
'make deps',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'godeps',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'lint',
|
||||
image: 'golang:1.19',
|
||||
commands: [
|
||||
'make lint',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'godeps',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
image: 'golang:1.19',
|
||||
commands: [
|
||||
'make test',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'godeps',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'godeps',
|
||||
temp: {},
|
||||
},
|
||||
],
|
||||
depends_on: deps,
|
||||
trigger: {
|
||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineRelease(deps=[],) = {
|
||||
kind: 'pipeline',
|
||||
image_pull_secrets: ['docker_config'],
|
||||
name: 'release',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'changelog-generate',
|
||||
image: 'thegeeklab/git-chglog',
|
||||
commands: [
|
||||
'git fetch -tq',
|
||||
'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'changelog-format',
|
||||
image: 'thegeeklab/alpine-tools',
|
||||
commands: [
|
||||
'prettier CHANGELOG.md',
|
||||
'prettier -w CHANGELOG.md',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'publish',
|
||||
image: 'plugins/github-release',
|
||||
settings: {
|
||||
overwrite: true,
|
||||
api_key: {
|
||||
from_secret: 'github_token',
|
||||
},
|
||||
title: '${DRONE_TAG}',
|
||||
note: 'CHANGELOG.md',
|
||||
},
|
||||
when: {
|
||||
ref: [
|
||||
'refs/tags/**',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: deps,
|
||||
trigger: {
|
||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineDocs(deps=[],) = {
|
||||
kind: 'pipeline',
|
||||
name: 'docs',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'markdownlint',
|
||||
image: 'thegeeklab/markdownlint-cli',
|
||||
commands: [
|
||||
"markdownlint 'README.md' 'CONTRIBUTING.md'",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'spellcheck',
|
||||
image: 'thegeeklab/alpine-tools',
|
||||
commands: [
|
||||
"spellchecker --files 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
|
||||
],
|
||||
environment: {
|
||||
FORCE_COLOR: true,
|
||||
NPM_CONFIG_LOGLEVEL: 'error',
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: deps,
|
||||
trigger: {
|
||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineNotifications(deps=[],) = {
|
||||
kind: 'pipeline',
|
||||
name: 'notifications',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'matrix',
|
||||
image: 'thegeeklab/drone-matrix',
|
||||
settings: {
|
||||
homeserver: { from_secret: 'matrix_homeserver' },
|
||||
roomid: { from_secret: 'matrix_roomid' },
|
||||
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
|
||||
username: { from_secret: 'matrix_username' },
|
||||
password: { from_secret: 'matrix_password' },
|
||||
},
|
||||
when: {
|
||||
status: ['success', 'failure'],
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: deps,
|
||||
trigger: {
|
||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||
status: ['success', 'failure'],
|
||||
},
|
||||
};
|
||||
|
||||
[
|
||||
PipelineTest(),
|
||||
PipelineRelease(deps=['test'],),
|
||||
PipelineDocs(deps=['release']),
|
||||
PipelineNotifications(deps=['docs']),
|
||||
]
|
161
.drone.yml
161
.drone.yml
|
@ -1,161 +0,0 @@
|
|||
---
|
||||
kind: pipeline
|
||||
name: test
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: deps
|
||||
image: golang:1.19
|
||||
commands:
|
||||
- make deps
|
||||
volumes:
|
||||
- name: godeps
|
||||
path: /go
|
||||
|
||||
- name: lint
|
||||
image: golang:1.19
|
||||
commands:
|
||||
- make lint
|
||||
volumes:
|
||||
- name: godeps
|
||||
path: /go
|
||||
|
||||
- name: test
|
||||
image: golang:1.19
|
||||
commands:
|
||||
- make test
|
||||
volumes:
|
||||
- name: godeps
|
||||
path: /go
|
||||
|
||||
volumes:
|
||||
- name: godeps
|
||||
temp: {}
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: release
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: changelog-generate
|
||||
image: thegeeklab/git-chglog
|
||||
commands:
|
||||
- git fetch -tq
|
||||
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
|
||||
|
||||
- name: changelog-format
|
||||
image: thegeeklab/alpine-tools
|
||||
commands:
|
||||
- prettier CHANGELOG.md
|
||||
- prettier -w CHANGELOG.md
|
||||
|
||||
- name: publish
|
||||
image: plugins/github-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: github_token
|
||||
note: CHANGELOG.md
|
||||
overwrite: true
|
||||
title: ${DRONE_TAG}
|
||||
when:
|
||||
ref:
|
||||
- refs/tags/**
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: docs
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: markdownlint
|
||||
image: thegeeklab/markdownlint-cli
|
||||
commands:
|
||||
- markdownlint 'README.md' 'CONTRIBUTING.md'
|
||||
|
||||
- name: spellcheck
|
||||
image: thegeeklab/alpine-tools
|
||||
commands:
|
||||
- spellchecker --files 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions
|
||||
environment:
|
||||
FORCE_COLOR: true
|
||||
NPM_CONFIG_LOGLEVEL: error
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- release
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: notifications
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: matrix
|
||||
image: thegeeklab/drone-matrix
|
||||
settings:
|
||||
homeserver:
|
||||
from_secret: matrix_homeserver
|
||||
password:
|
||||
from_secret: matrix_password
|
||||
roomid:
|
||||
from_secret: matrix_roomid
|
||||
template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
|
||||
username:
|
||||
from_secret: matrix_username
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
- refs/tags/**
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
depends_on:
|
||||
- docs
|
||||
|
||||
---
|
||||
kind: signature
|
||||
hmac: 9cadf4dc495cf5ea9e54b4964eab9fd7a545d6b419c7cd78bc6846108428a926
|
||||
|
||||
...
|
106
.golangci.yml
106
.golangci.yml
|
@ -1,25 +1,91 @@
|
|||
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
|
||||
enable:
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- asasalint
|
||||
- asciicheck
|
||||
- bidichk
|
||||
- bodyclose
|
||||
- containedctx
|
||||
- contextcheck
|
||||
- decorder
|
||||
- dogsled
|
||||
- dupl
|
||||
- dupword
|
||||
- durationcheck
|
||||
- errchkjson
|
||||
- errname
|
||||
- errorlint
|
||||
- execinquery
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
- forcetypeassert
|
||||
- ginkgolinter
|
||||
- gocheckcompilerdirectives
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- godot
|
||||
- godox
|
||||
- goerr113
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goheader
|
||||
- goimports
|
||||
- gomnd
|
||||
- gomoddirectives
|
||||
- gomodguard
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- grouper
|
||||
- importas
|
||||
- interfacebloat
|
||||
- ireturn
|
||||
- lll
|
||||
- loggercheck
|
||||
- maintidx
|
||||
- makezero
|
||||
- misspell
|
||||
- musttag
|
||||
- nakedret
|
||||
- nestif
|
||||
- nilerr
|
||||
- nilnil
|
||||
- nlreturn
|
||||
- noctx
|
||||
- nolintlint
|
||||
- nonamedreturns
|
||||
- nosprintfhostport
|
||||
- prealloc
|
||||
- predeclared
|
||||
- promlinter
|
||||
- reassign
|
||||
- revive
|
||||
# - rowserrcheck
|
||||
# - sqlclosecheck
|
||||
# - structcheck
|
||||
- stylecheck
|
||||
- tagliatelle
|
||||
- tenv
|
||||
- testableexamples
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
# - wastedassign
|
||||
- whitespace
|
||||
- wsl
|
||||
fast: false
|
||||
|
||||
run:
|
||||
|
@ -28,4 +94,4 @@ run:
|
|||
linters-settings:
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
lang-version: "1.18"
|
||||
lang-version: "1.20"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## Security
|
||||
|
||||
If you think you have found a **security issue**, please do not mention it in this repository.
|
||||
Instead, send an email to security@thegeeklab.de with as many details as possible so it can be handled confidential.
|
||||
Instead, send an email to `security@thegeeklab.de` with as many details as possible so it can be handled confidential.
|
||||
|
||||
## Bug Reports and Feature Requests
|
||||
|
||||
|
|
15
Makefile
15
Makefile
|
@ -1,7 +1,7 @@
|
|||
# renovate: datasource=github-releases depName=mvdan/gofumpt
|
||||
GOFUMPT_PACKAGE_VERSION := v0.3.1
|
||||
GOFUMPT_PACKAGE_VERSION := v0.5.0
|
||||
# renovate: datasource=github-releases depName=golangci/golangci-lint
|
||||
GOLANGCI_LINT_PACKAGE_VERSION := v1.47.2
|
||||
GOLANGCI_LINT_PACKAGE_VERSION := v1.54.2
|
||||
|
||||
EXECUTABLE := drone-plugin-lib
|
||||
|
||||
|
@ -19,9 +19,14 @@ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(G
|
|||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||
|
||||
GENERATE ?=
|
||||
XGO_VERSION := go-1.19.x
|
||||
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
|
||||
XGO_VERSION := go-1.20.x
|
||||
XGO_TARGETS ?= linux/amd64,linux/arm64,linux/arm-6,linux/arm-7
|
||||
|
||||
TARGETOS ?= linux
|
||||
TARGETARCH ?= amd64
|
||||
ifneq ("$(TARGETVARIANT)","")
|
||||
GOARM ?= $(subst v,,$(TARGETVARIANT))
|
||||
endif
|
||||
TAGS ?= netgo
|
||||
|
||||
ifndef VERSION
|
||||
|
@ -69,7 +74,7 @@ test:
|
|||
build: $(DIST)/$(EXECUTABLE)
|
||||
|
||||
$(DIST)/$(EXECUTABLE): $(SOURCES)
|
||||
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
|
||||
GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) GOARM=$(GOARM) $(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
|
||||
|
||||
$(DIST_DIRS):
|
||||
mkdir -p $(DIST_DIRS)
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-plugin-lib)
|
||||
[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/drone-plugin-lib)](https://github.com/thegeeklab/drone-plugin-lib/blob/main/LICENSE)
|
||||
|
||||
> **DISCONTINUED:** As I don't use Drone CI anymore, this project is unmaintained. If you are interested in a free and open source CI system check out [Woodpecker CI](https://woodpecker-ci.org/).
|
||||
|
||||
Helper library to reduce the boilerplate code for writing Drone CI plugins.
|
||||
|
||||
## Usage
|
||||
|
|
|
@ -17,6 +17,7 @@ type Network struct {
|
|||
//
|
||||
// If `trace` logging is requested the context will use `httptrace` to
|
||||
// capture all network requests.
|
||||
//nolint:containedctx
|
||||
Context context.Context
|
||||
|
||||
/// Whether SSL verification is skipped
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package drone
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// StringSliceFlag is a flag type which support comma separated values and escaping to not split at unwanted lines.
|
||||
type StringSliceFlag struct {
|
||||
slice []string
|
||||
}
|
||||
|
||||
func (s *StringSliceFlag) String() string {
|
||||
return strings.Join(s.slice, " ")
|
||||
}
|
||||
|
||||
func (s *StringSliceFlag) Set(value string) error {
|
||||
s.slice = splitWithEscaping(value, ",", "\\")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *StringSliceFlag) Get() []string {
|
||||
return s.slice
|
||||
}
|
||||
|
||||
func splitWithEscaping(in, separator, escapeString string) []string {
|
||||
if len(in) == 0 {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
out := strings.Split(in, separator)
|
||||
|
||||
//nolint:gomnd
|
||||
for i := len(out) - 2; i >= 0; i-- {
|
||||
if strings.HasSuffix(out[i], escapeString) {
|
||||
out[i] = out[i][:len(out[i])-len(escapeString)] + separator + out[i+1]
|
||||
out = append(out[:i+1], out[i+2:]...)
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package drone
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplitWithEscaping(t *testing.T) {
|
||||
tests := []struct {
|
||||
Input string
|
||||
Output []string
|
||||
}{
|
||||
{"", []string{}},
|
||||
{"a,b", []string{"a", "b"}},
|
||||
{",,,", []string{"", "", "", ""}},
|
||||
{",a\\,", []string{"", "a,"}},
|
||||
{"a,b\\,c\\\\d,e", []string{"a", "b,c\\\\d", "e"}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
strings := splitWithEscaping(test.Input, ",", "\\")
|
||||
got, want := strings, test.Output
|
||||
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Got tag %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
19
go.mod
19
go.mod
|
@ -1,15 +1,26 @@
|
|||
module github.com/thegeeklab/drone-plugin-lib/v2
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/urfave/cli/v2 v2.11.1
|
||||
github.com/Masterminds/sprig/v3 v3.2.3
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/urfave/cli/v2 v2.25.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.2.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/google/uuid v1.1.1 // indirect
|
||||
github.com/huandu/xstrings v1.3.3 // indirect
|
||||
github.com/imdario/mergo v0.3.11 // indirect
|
||||
github.com/mitchellh/copystructure v1.0.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/shopspring/decimal v1.2.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
golang.org/x/crypto v0.3.0 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
)
|
||||
|
|
64
go.sum
64
go.sum
|
@ -1,23 +1,77 @@
|
|||
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
|
||||
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
||||
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
|
||||
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
|
||||
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
|
||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
|
||||
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
||||
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
|
||||
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/urfave/cli/v2 v2.11.1 h1:UKK6SP7fV3eKOefbS87iT9YHefv7iB/53ih6e+GNAsE=
|
||||
github.com/urfave/cli/v2 v2.11.1/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
|
||||
github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc=
|
||||
github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
|
||||
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/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-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["github>thegeeklab/renovate-presets:golang"]
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package template
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
)
|
||||
|
||||
func loadFuncMap() template.FuncMap {
|
||||
sprigFuncs := sprig.GenericFuncMap()
|
||||
customFuncs := template.FuncMap{}
|
||||
|
||||
for name, f := range customFuncs {
|
||||
if _, ok := sprigFuncs[name]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
sprigFuncs[name] = f
|
||||
}
|
||||
|
||||
return sprigFuncs
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
// Copyright (c) 2018, Drone.IO Inc
|
||||
// Copyright (c) 2021, Robert Kaussow <mail@thegeeklab.de>
|
||||
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package template
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// Render parses and executes a template, returning the results in string
|
||||
// format. Trailing or leading spaces or new-lines are not getting truncated. It
|
||||
// is able to read templates from remote paths, local files or directly from the
|
||||
// string.
|
||||
func Render(ctx context.Context, client http.Client, templateString string, payload interface{}) (string, error) {
|
||||
var outString bytes.Buffer
|
||||
|
||||
tpl := new(template.Template).Funcs(loadFuncMap())
|
||||
|
||||
templateURL, err := url.Parse(templateString)
|
||||
if err == nil {
|
||||
switch templateURL.Scheme {
|
||||
case "http", "https":
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, templateURL.String(), nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to fetch: %w", err)
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
|
||||
out, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to read: %w", err)
|
||||
}
|
||||
|
||||
templateString = string(out)
|
||||
case "file":
|
||||
out, err := os.ReadFile(templateURL.Path)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to read: %w", err)
|
||||
}
|
||||
|
||||
templateString = string(out)
|
||||
}
|
||||
}
|
||||
|
||||
tpl, err = tpl.Parse(templateString)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = tpl.Execute(&outString, payload)
|
||||
|
||||
return outString.String(), err
|
||||
}
|
||||
|
||||
// RenderTrim parses and executes a template, returning the results in string
|
||||
// format. The result is trimmed to remove left and right padding and newlines
|
||||
// that may be added unintentially in the template markup.
|
||||
func RenderTrim(ctx context.Context, client http.Client, template string, playload interface{}) (string, error) {
|
||||
out, err := Render(ctx, client, template, playload)
|
||||
|
||||
return strings.Trim(out, " \n"), err
|
||||
}
|
|
@ -49,6 +49,7 @@ func HTTP(ctx context.Context) context.Context {
|
|||
"code": code,
|
||||
"header": header,
|
||||
}).Trace("ClientTrace.Got1xxxResponse")
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
|
@ -83,14 +84,14 @@ func HTTP(ctx context.Context) context.Context {
|
|||
logrus.Trace("ClientTrace.TLSHandshakeStart")
|
||||
},
|
||||
|
||||
TLSHandshakeDone: func(cs tls.ConnectionState, err error) {
|
||||
TLSHandshakeDone: func(connState tls.ConnectionState, err error) {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"version": cs.Version,
|
||||
"handshake-complete": cs.HandshakeComplete,
|
||||
"did-resume": cs.DidResume,
|
||||
"cipher-suite": cs.CipherSuite,
|
||||
"negotiated-protocol": cs.NegotiatedProtocol,
|
||||
"server-name": cs.ServerName,
|
||||
"version": connState.Version,
|
||||
"handshake-complete": connState.HandshakeComplete,
|
||||
"did-resume": connState.DidResume,
|
||||
"cipher-suite": connState.CipherSuite,
|
||||
"negotiated-protocol": connState.NegotiatedProtocol,
|
||||
"server-name": connState.ServerName,
|
||||
"error": err,
|
||||
}).Trace("ClientTrace.TLSHandshakeDone")
|
||||
},
|
||||
|
|
|
@ -19,6 +19,13 @@ import (
|
|||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
NetDailerTimeout = 30 * time.Second
|
||||
HTTPTransportIdleTimeout = 90 * time.Second
|
||||
HTTPTransportTLSHandshakeTimeout = 10 * time.Second
|
||||
HTTPTransportMaxIdleConns = 100
|
||||
)
|
||||
|
||||
// networkFlags has the cli.Flags for the drone.Network.
|
||||
func networkFlags(category string) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
|
@ -32,35 +39,36 @@ func networkFlags(category string) []cli.Flag {
|
|||
}
|
||||
|
||||
// NetworkFromContext creates a drone.Network from the cli.Context.
|
||||
func NetworkFromContext(c *cli.Context) drone.Network {
|
||||
func NetworkFromContext(ctx *cli.Context) drone.Network {
|
||||
dialer := &net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
Timeout: NetDailerTimeout,
|
||||
KeepAlive: NetDailerTimeout,
|
||||
DualStack: true,
|
||||
}
|
||||
|
||||
transport := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
DialContext: dialer.DialContext,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
MaxIdleConns: HTTPTransportMaxIdleConns,
|
||||
IdleConnTimeout: HTTPTransportIdleTimeout,
|
||||
TLSHandshakeTimeout: HTTPTransportTLSHandshakeTimeout,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
skipVerify := c.Bool("transport.skip-verify")
|
||||
context := context.Background()
|
||||
skipVerify := ctx.Bool("transport.skip-verify")
|
||||
|
||||
if skipVerify {
|
||||
logrus.Warning("ssl verification is turned off")
|
||||
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
//nolint:gosec
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
}
|
||||
|
||||
if c.String("log-level") == logrus.TraceLevel.String() {
|
||||
ctx = trace.HTTP(ctx)
|
||||
if ctx.String("log-level") == logrus.TraceLevel.String() {
|
||||
context = trace.HTTP(context)
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
|
@ -68,7 +76,7 @@ func NetworkFromContext(c *cli.Context) drone.Network {
|
|||
}
|
||||
|
||||
return drone.Network{
|
||||
Context: ctx,
|
||||
Context: context,
|
||||
SkipVerify: skipVerify,
|
||||
Client: client,
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// repoFlags has the cli.Flags for the drone.Repo
|
||||
// repoFlags has the cli.Flags for the drone.Repo.
|
||||
func repoFlags(category string) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
const (
|
||||
FlagsBuildCategory = "Drone Build Flags"
|
||||
FlagsRepoCategory = "Drone Repo Flags"
|
||||
FlagsCommitCategory = "Drone Commit Flags"
|
||||
|
|
Loading…
Reference in New Issue