Merge pull request #5 from tboerger/additions
Integrate sprig for more helpers
This commit is contained in:
commit
99ad87bf1b
54
.drone.yml
54
.drone.yml
|
@ -1,18 +1,40 @@
|
|||
workspace:
|
||||
base: /go
|
||||
path: src/github.com/drone/drone-template-lib
|
||||
---
|
||||
kind: pipeline
|
||||
name: testing
|
||||
|
||||
pipeline:
|
||||
deps:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
commands:
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
- dep ensure
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
test:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
commands:
|
||||
- go vet ./...
|
||||
- go test -cover ./...
|
||||
steps:
|
||||
- name: vet
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- go vet ./...
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: test
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- go test -cover ./...
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
volumes:
|
||||
- name: gopath
|
||||
temp: {}
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/aymerick/raymond"
|
||||
packages = [
|
||||
".",
|
||||
"ast",
|
||||
"lexer",
|
||||
"parser"
|
||||
]
|
||||
revision = "2eebd0f5dd9564c0c6e439df11d8a3c7b9b9ab11"
|
||||
version = "v2.0.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/bouk/monkey"
|
||||
packages = ["."]
|
||||
revision = "5df1f207ff77e025801505ae4d903133a0b4353f"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/tkuchiki/faketime"
|
||||
packages = ["."]
|
||||
revision = "a4500a4f4643cbc8c5855ed1dbbf161d6cfc77a5"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "1ad80a88b5f0b1ddd8f2a548af68aea9c1c6e25c6fc0870a5fa5a5b03b25d414"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
15
Gopkg.toml
15
Gopkg.toml
|
@ -1,15 +0,0 @@
|
|||
[[constraint]]
|
||||
name = "github.com/aymerick/raymond"
|
||||
version = "2.0.2"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/pkg/errors"
|
||||
version = "0.8.0"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/tkuchiki/faketime"
|
|
@ -0,0 +1,15 @@
|
|||
module github.com/drone/drone-template-lib
|
||||
|
||||
require (
|
||||
github.com/Masterminds/goutils v1.1.0 // indirect
|
||||
github.com/Masterminds/semver v1.4.2 // indirect
|
||||
github.com/Masterminds/sprig v2.18.0+incompatible
|
||||
github.com/aymerick/raymond v2.0.2+incompatible
|
||||
github.com/bouk/monkey v1.0.0
|
||||
github.com/google/uuid v1.1.0 // indirect
|
||||
github.com/huandu/xstrings v1.2.0 // indirect
|
||||
github.com/imdario/mergo v0.3.7 // indirect
|
||||
github.com/pkg/errors v0.8.0
|
||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 // indirect
|
||||
)
|
|
@ -0,0 +1,22 @@
|
|||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
||||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/Masterminds/sprig v2.18.0+incompatible h1:QoGhlbC6pter1jxKnjMFxT8EqsLuDE6FEcNbWEpw+lI=
|
||||
github.com/Masterminds/sprig v2.18.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
||||
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||
github.com/bouk/monkey v1.0.0 h1:k6z8fLlPhETfn5l9rlWVE7Q6B23DoaqosTdArvNQRdc=
|
||||
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
|
||||
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
|
||||
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
|
||||
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
|
||||
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
|
||||
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643 h1:ii/sHfgFMByozryLeiDmn1ClZ/Pena4NgpJ4P7UuX9o=
|
||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
@ -23,6 +23,7 @@ import (
|
|||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/Masterminds/sprig"
|
||||
"github.com/aymerick/raymond"
|
||||
)
|
||||
|
||||
|
@ -38,13 +39,19 @@ var (
|
|||
"uppercasefirst": uppercaseFirst,
|
||||
"uppercase": strings.ToUpper,
|
||||
"lowercase": strings.ToLower,
|
||||
"trim": strings.TrimSpace,
|
||||
"title": strings.Title,
|
||||
"regexReplace": regexReplace,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
for name, function := range sprig.GenericFuncMap() {
|
||||
if invalidHelper(name) {
|
||||
continue
|
||||
}
|
||||
|
||||
funcs[name] = function
|
||||
}
|
||||
|
||||
raymond.RegisterHelpers(funcs)
|
||||
}
|
||||
|
||||
|
@ -124,3 +131,23 @@ func regexReplace(pattern string, input string, replacement string) string {
|
|||
re := regexp.MustCompile(pattern)
|
||||
return re.ReplaceAllString(input, replacement)
|
||||
}
|
||||
|
||||
func invalidHelper(name string) bool {
|
||||
invalids := []string{
|
||||
"buildCustomCert",
|
||||
"fail",
|
||||
"genSelfSignedCert",
|
||||
"genSignedCert",
|
||||
"genCA",
|
||||
"semver",
|
||||
"semverCompare",
|
||||
}
|
||||
|
||||
for _, invalid := range invalids {
|
||||
if name == invalid {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue