From c4b5480d9800f2a050ecf2b4c9f55625d9c83452 Mon Sep 17 00:00:00 2001 From: Ian Stahnke <3182572+pr8kerl@users.noreply.github.com> Date: Sun, 29 Dec 2019 22:23:21 +1100 Subject: [PATCH] update build to use go mod and go 1.13 --- .goreleaser.yml | 14 +++--- .travis.yml | 16 +++++- Dockerfile | 14 +----- Gopkg.lock | 123 --------------------------------------------- Gopkg.toml | 42 ---------------- Makefile | 29 ++++------- docker-compose.yml | 7 ++- go.mod | 28 +++++++++++ go.sum | 54 ++++++++++++++++++++ 9 files changed, 119 insertions(+), 208 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.goreleaser.yml b/.goreleaser.yml index 25d8b14..8a242b1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,14 +13,12 @@ archive: format: binary dockers: - - + - + image_templates: + - 'pr8kerl/f5er:{{ .Tag }}' + - 'pr8kerl/f5er:latest' + binaries: + - f5er goos: linux goarch: amd64 - binary: f5er - image: pr8kerl/f5er dockerfile: Dockerfile - tag_templates: - - "{{ .Tag }}" - - "v{{ .Major }}" - - "v{{ .Major }}.{{ .Minor }}" - - latest diff --git a/.travis.yml b/.travis.yml index c1a93dc..a26f561 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,19 @@ addons: - docker-ce services: - - docker +- docker script: -- docker-compose run make all +- docker-compose run --rm make all + +after_success: +- test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" + +# calls goreleaser +deploy: +- provider: script + skip_cleanup: true + script: curl -sL https://git.io/goreleaser | bash + on: + tags: true + condition: $TRAVIS_OS_NAME = linux diff --git a/Dockerfile b/Dockerfile index f590dea..d35dc74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,4 @@ -FROM golang:1.9 as build - -RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && chmod +x /usr/local/bin/dep -RUN curl -s -L -o /tmp/goreleaser.tgz \ - "https://github.com/goreleaser/goreleaser/releases/download/v0.46.3/goreleaser_$(uname -s)_$(uname -m).tar.gz" \ - && tar -xf /tmp/goreleaser.tgz -C /usr/local/bin - -WORKDIR /go/src/github.com/pr8kerl/f5er -COPY . . -RUN make clean && make - FROM scratch -COPY --from=build /go/src/github.com/pr8kerl/f5er/f5er / - +COPY f5er /f5er ENTRYPOINT ["/f5er"] CMD [ "--help" ] diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 339ddbd..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,123 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/fatih/structs" - packages = ["."] - revision = "a720dfa8df582c51dee1b36feabb906bde1588bd" - version = "v1.0" - -[[projects]] - name = "github.com/fsnotify/fsnotify" - packages = ["."] - revision = "4da3e2cfbabc9f751898f250b49f2439785783a1" - -[[projects]] - branch = "master" - name = "github.com/hashicorp/hcl" - packages = [ - ".", - "hcl/ast", - "hcl/parser", - "hcl/scanner", - "hcl/strconv", - "hcl/token", - "json/parser", - "json/scanner", - "json/token" - ] - revision = "23c074d0eceb2b8a5bfdbb271ab780cde70f05a8" - -[[projects]] - name = "github.com/inconshreveable/mousetrap" - packages = ["."] - revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" - version = "v1.0" - -[[projects]] - name = "github.com/jmcvetta/napping" - packages = ["."] - revision = "4c7b4b235c63152afa9a1c6384e708e0fbfd77ca" - version = "v3.2.0" - -[[projects]] - branch = "master" - name = "github.com/magiconair/properties" - packages = ["."] - revision = "49d762b9817ba1c2e9d0c69183c2b4a8b8f1d934" - -[[projects]] - name = "github.com/mitchellh/mapstructure" - packages = ["."] - revision = "06020f85339e21b2478f756a78e295255ffa4d6a" - -[[projects]] - name = "github.com/pelletier/go-toml" - packages = ["."] - revision = "4e9e0ee19b60b13eb79915933f44d8ed5f268bdd" - -[[projects]] - name = "github.com/spf13/afero" - packages = [ - ".", - "mem" - ] - revision = "8d919cbe7e2627e417f3e45c3c0e489a5b7e2536" - version = "v1.0.0" - -[[projects]] - name = "github.com/spf13/cast" - packages = ["."] - revision = "acbeb36b902d72a7a4c18e8f3241075e7ab763e4" - version = "v1.1.0" - -[[projects]] - name = "github.com/spf13/cobra" - packages = ["."] - revision = "d6948b782c9f4799ea3cd225f6de4131c29c243a" - -[[projects]] - name = "github.com/spf13/jwalterweatherman" - packages = ["."] - revision = "12bd96e66386c1960ab0f74ced1362f66f552f7b" - -[[projects]] - branch = "master" - name = "github.com/spf13/pflag" - packages = ["."] - revision = "4c012f6dcd9546820e378d0bdda4d8fc772cdfea" - -[[projects]] - name = "github.com/spf13/viper" - packages = ["."] - revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7" - version = "v1.0.0" - -[[projects]] - name = "golang.org/x/sys" - packages = ["unix"] - revision = "0dd5e194bbf5eb84a39666eb4c98a4d007e4203a" - -[[projects]] - name = "golang.org/x/text" - packages = [ - "internal/gen", - "internal/triegen", - "internal/ucd", - "transform", - "unicode/cldr", - "unicode/norm" - ] - revision = "88f656faf3f37f690df1a32515b479415e1a6769" - -[[projects]] - name = "gopkg.in/yaml.v2" - packages = ["."] - revision = "287cf08546ab5e7e37d55a84f7ed3fd1db036de5" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "97f660b84fe3c604a5aa99f62cf5e9d44750e6af42c150aaf9965a73e9124675" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index bc41b38..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,42 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[[constraint]] - name = "github.com/fatih/structs" - version = "1.0.0" - -[[constraint]] - name = "github.com/jmcvetta/napping" - version = "3.2.0" - -[[constraint]] - name = "github.com/spf13/viper" - version = "1.0.0" - -[prune] - go-tests = true - unused-packages = true diff --git a/Makefile b/Makefile index 7c104aa..62a1c42 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: deps test publish clean +.PHONY: deps test clean GOPATH ?= /go GOBIN := $(GOPATH)/bin @@ -9,43 +9,34 @@ DOCKER_PASSWORD ?= Magic LDFLAGS := -ldflags "-X main.commit=`git rev-parse HEAD`" -all: deps fmt test $(PROJ) publish - -deps: - @echo "--- collecting ingredients :bento:" - GOPATH=$(GOPATH) dep ensure +all: fmt test $(PROJ) fmt: GOPATH=$(GOPATH) go fmt *.go GOPATH=$(GOPATH) go fmt f5/*.go - GOPATH=$(GOPATH) go tool vet *.go f5/*.go + GOPATH=$(GOPATH) go vet + GOPATH=$(GOPATH) go vet ./f5 -test: fmt deps +test: fmt @echo "+++ Is this thing working? :hammer_and_wrench:" GOPATH=$(GOPATH) go test -cover -v -$(PROJ): deps +$(PROJ): CGO_ENABLED=0 GOPATH=$(GOPATH) go build $(LDFLAGS) -o $@ -v touch $@ && chmod 755 $@ -linux: deps +linux: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOPATH=$(GOPATH) go build $(LDFLAGS) -o $(PROJ)-linux-amd64 -v touch $(PROJ)-linux-amd64 && chmod 755 $(PROJ)-linux-amd64 -windows: deps +windows: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 GOPATH=$(GOPATH) go build $(LDFLAGS) -o $(PROJ)-windows-amd64.exe -v touch $(PROJ)-windows-amd64.exe -darwin: deps +darwin: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 GOPATH=$(GOPATH) go build -o $(PROJ)-darwin-amd64 -v touch $(PROJ)-darwin-amd64 && chmod 755 $(PROJ)-darwin-amd64 -ifdef TRAVIS_TAG -publish: deps - @echo "+++ release :octocat:" - docker login -u "$(DOCKER_USERNAME)" -p "$(DOCKER_PASSWORD)" - goreleaser --skip-validate --rm-dist -endif - clean: rm -rf $(PROJ) $(PROJ)-windows-amd64.exe $(PROJ)-linux-amd64 $(PROJ)-darwin-amd64 dist + diff --git a/docker-compose.yml b/docker-compose.yml index 233871a..2039ac9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,10 @@ version: '3' services: base: &base - image: pr8kerl/gobuilder:1.10 + image: pr8kerl/gobuilder:1.13 volumes: - .:/go/src/github.com/pr8kerl/f5er + - $HOME/.docker:/root/.docker working_dir: /go/src/github.com/pr8kerl/f5er entrypoint: make @@ -20,3 +21,7 @@ services: environment: - GITHUB_TOKEN - TRAVIS_TAG + + goreleaser: + <<: *base + entrypoint: goreleaser diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a224289 --- /dev/null +++ b/go.mod @@ -0,0 +1,28 @@ +module github.com/pr8kerl/f5er + +go 1.13 + +require ( + github.com/BurntSushi/toml v0.3.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fatih/structs v1.0.0 + github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc // indirect + github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jmcvetta/napping v3.2.0+incompatible + github.com/jmcvetta/randutil v0.0.0-20150817122601-2bb1b664bcff // indirect + github.com/kr/pretty v0.1.0 // indirect + github.com/magiconair/properties v1.7.5-0.20171031211101-49d762b9817b // indirect + github.com/mitchellh/mapstructure v0.0.0-20171017171808-06020f85339e // indirect + github.com/pelletier/go-toml v1.0.2-0.20171024211038-4e9e0ee19b60 // indirect + github.com/spf13/afero v1.0.0 // indirect + github.com/spf13/cast v1.1.0 // indirect + github.com/spf13/cobra v0.0.2-0.20171117052459-d6948b782c9f + github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386 // indirect + github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95 // indirect + github.com/spf13/viper v1.0.0 + github.com/stretchr/testify v1.4.0 // indirect + golang.org/x/sys v0.0.0-20171117071000-0dd5e194bbf5 // indirect + golang.org/x/text v0.1.1-0.20171102192421-88f656faf3f3 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5a5a05e --- /dev/null +++ b/go.sum @@ -0,0 +1,54 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +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/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= +github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc h1:omfZI1v/Bu4YEatmRAYKISWA95u6XiN4Zorz/JPKCZA= +github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb h1:1OvvPvZkn/yCQ3xBcM8y4020wdkMXPHLB4+NfoGWh4U= +github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jmcvetta/napping v3.2.0+incompatible h1:shS22lJu18MtyRV7IqWenMmrRXCjADcUcxONAnp5zxY= +github.com/jmcvetta/napping v3.2.0+incompatible/go.mod h1:dlR6SvwNgFr2ASHFGDIO2fhkZM2rU/9B6NB6xUciyv4= +github.com/jmcvetta/randutil v0.0.0-20150817122601-2bb1b664bcff h1:6NvhExg4omUC9NfA+l4Oq3ibNNeJUdiAF3iBVB0PlDk= +github.com/jmcvetta/randutil v0.0.0-20150817122601-2bb1b664bcff/go.mod h1:ddfPX8Z28YMjiqoaJhNBzWHapTHXejnB5cDCUWDwriw= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.7.5-0.20171031211101-49d762b9817b h1:Ds0wdhIP1ByMQU6Nq4k2WrRTOb2pzNsBfzGqmtNqNlM= +github.com/magiconair/properties v1.7.5-0.20171031211101-49d762b9817b/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mitchellh/mapstructure v0.0.0-20171017171808-06020f85339e h1:PtGHLB3CX3TFPcksODQMxncoeQKWwCgTg0bJ40VLJP4= +github.com/mitchellh/mapstructure v0.0.0-20171017171808-06020f85339e/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/pelletier/go-toml v1.0.2-0.20171024211038-4e9e0ee19b60 h1:rorigtVygiguXfP5LFmZuOSQrAJUEsS5AUZuqAgtYag= +github.com/pelletier/go-toml v1.0.2-0.20171024211038-4e9e0ee19b60/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +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/spf13/afero v1.0.0 h1:Z005C09nPzwTTsDRJCQBVnpTU0bjTr/NhyWLj1nSPP4= +github.com/spf13/afero v1.0.0/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.1.0 h1:0Rhw4d6C8J9VPu6cjZLIhZ8+aAOHcDvGeKn+cq5Aq3k= +github.com/spf13/cast v1.1.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= +github.com/spf13/cobra v0.0.2-0.20171117052459-d6948b782c9f h1:ysPJYvpa67+inyweOkAP/gDJAjk0ks1UKoY3q57bXEI= +github.com/spf13/cobra v0.0.2-0.20171117052459-d6948b782c9f/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386 h1:zBoLErXXAvWnNsu+pWkRYl6Cx1KXmIfAVsIuYkPN6aY= +github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95 h1:j8jxLbQ0+T1DFggy6XoGvyUnrJWPR/JybflPvu5rwS4= +github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.0.0 h1:RUA/ghS2i64rlnn4ydTfblY8Og8QzcPtCcHvgMn+w/I= +github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/sys v0.0.0-20171117071000-0dd5e194bbf5 h1:0KTtWRo2aG4NBbRFhufXJk71ABwgU8Yztc5BFWTW8mg= +golang.org/x/sys v0.0.0-20171117071000-0dd5e194bbf5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.1.1-0.20171102192421-88f656faf3f3 h1:OxMYHd6bm+jH+TI7NBCb/CaYk6pMJnBC8GIzIi68Hk4= +golang.org/x/text v0.1.1-0.20171102192421-88f656faf3f3/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=