From d990d2ad8667c454daaccb31ff36f10e319210a7 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sun, 6 May 2018 16:19:21 -0400 Subject: [PATCH] travis: Bump to golang 1.10 This requires breaking changes in gofmt. It is hilarious that this was changed. Oh well. This also moves to the latest stable etcd. Lastly, this changes the `go vet` testing to test by package, since the new go vet changed how it works and now fails without this change. --- .travis.yml | 6 +++--- docs/quick-start-guide.md | 4 ++-- examples/lib/exec-send-recv.go | 4 +--- examples/lib/libmgmt-subgraph0.go | 4 +--- examples/lib/libmgmt-subgraph1.go | 4 +--- examples/lib/libmgmt2.go | 4 +--- examples/lib/libmgmt3.go | 4 +--- lang/funcs/core/template_polyfunc.go | 26 +++++++++++++------------- lang/structs.go | 8 ++++---- test/test-gofmt.sh | 6 ------ test/test-govet.sh | 22 +++++++--------------- vendor/github.com/coreos/etcd | 2 +- 12 files changed, 35 insertions(+), 59 deletions(-) diff --git a/.travis.yml b/.travis.yml index af70de66..93a5dfd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: go os: - linux go: - - 1.9.x - 1.10.x + - 1.11.x - tip go_import_path: github.com/purpleidea/mgmt sudo: true @@ -26,13 +26,13 @@ script: 'make test' matrix: fast_finish: false allow_failures: - - go: 1.10.x + - go: 1.11.x - go: tip - os: osx # include only one build for osx for a quicker build as the nr. of these runners are sparse include: - os: osx - go: 1.9.x + go: 1.10.x # the "secure" channel value is the result of running: ./misc/travis-encrypt.sh # with a value of: irc.freenode.net#mgmtconfig to eliminate noise from forks... diff --git a/docs/quick-start-guide.md b/docs/quick-start-guide.md index ce9a3d58..f976adbc 100644 --- a/docs/quick-start-guide.md +++ b/docs/quick-start-guide.md @@ -13,7 +13,7 @@ Once you're familiar with the general idea, please start hacking... ### Installing golang -* You need golang version 1.9 or greater installed. +* You need golang version 1.10 or greater installed. * To install on rpm style systems: `sudo dnf install golang` * To install on apt style systems: `sudo apt install golang` * To install on macOS systems install [Homebrew](https://brew.sh) @@ -89,7 +89,7 @@ required for running the _test_ suite. ### Build -* `golang` 1.9 or higher (required, available in some distros and distributed +* `golang` 1.10 or higher (required, available in some distros and distributed as a binary officially by [golang.org](https://golang.org/dl/)) ### Runtime diff --git a/examples/lib/exec-send-recv.go b/examples/lib/exec-send-recv.go index 776f6d8c..50a4da2a 100644 --- a/examples/lib/exec-send-recv.go +++ b/examples/lib/exec-send-recv.go @@ -60,9 +60,7 @@ func (obj *MyGAPI) Cli(c *cli.Context, fs engine.Fs) (*gapi.Deploy, error) { Name: obj.Name, Noop: c.GlobalBool("noop"), Sema: c.GlobalInt("sema"), - GAPI: &MyGAPI{ - // TODO: add properties here... - }, + GAPI: &MyGAPI{}, }, nil } return nil, nil // we weren't activated! diff --git a/examples/lib/libmgmt-subgraph0.go b/examples/lib/libmgmt-subgraph0.go index e0e566c6..e680f636 100644 --- a/examples/lib/libmgmt-subgraph0.go +++ b/examples/lib/libmgmt-subgraph0.go @@ -65,9 +65,7 @@ func (obj *MyGAPI) Cli(c *cli.Context, fs engine.Fs) (*gapi.Deploy, error) { Name: obj.Name, Noop: c.GlobalBool("noop"), Sema: c.GlobalInt("sema"), - GAPI: &MyGAPI{ - // TODO: add properties here... - }, + GAPI: &MyGAPI{}, }, nil } return nil, nil // we weren't activated! diff --git a/examples/lib/libmgmt-subgraph1.go b/examples/lib/libmgmt-subgraph1.go index 9964c514..fabcc658 100644 --- a/examples/lib/libmgmt-subgraph1.go +++ b/examples/lib/libmgmt-subgraph1.go @@ -60,9 +60,7 @@ func (obj *MyGAPI) Cli(c *cli.Context, fs engine.Fs) (*gapi.Deploy, error) { Name: obj.Name, Noop: c.GlobalBool("noop"), Sema: c.GlobalInt("sema"), - GAPI: &MyGAPI{ - // TODO: add properties here... - }, + GAPI: &MyGAPI{}, }, nil } return nil, nil // we weren't activated! diff --git a/examples/lib/libmgmt2.go b/examples/lib/libmgmt2.go index ab622530..8e9a1cd6 100644 --- a/examples/lib/libmgmt2.go +++ b/examples/lib/libmgmt2.go @@ -62,9 +62,7 @@ func (obj *MyGAPI) Cli(c *cli.Context, fs engine.Fs) (*gapi.Deploy, error) { Name: obj.Name, Noop: c.GlobalBool("noop"), Sema: c.GlobalInt("sema"), - GAPI: &MyGAPI{ - // TODO: add properties here... - }, + GAPI: &MyGAPI{}, }, nil } return nil, nil // we weren't activated! diff --git a/examples/lib/libmgmt3.go b/examples/lib/libmgmt3.go index 8c211f13..bf964e35 100644 --- a/examples/lib/libmgmt3.go +++ b/examples/lib/libmgmt3.go @@ -60,9 +60,7 @@ func (obj *MyGAPI) Cli(c *cli.Context, fs engine.Fs) (*gapi.Deploy, error) { Name: obj.Name, Noop: c.GlobalBool("noop"), Sema: c.GlobalInt("sema"), - GAPI: &MyGAPI{ - // TODO: add properties here... - }, + GAPI: &MyGAPI{}, }, nil } return nil, nil // we weren't activated! diff --git a/lang/funcs/core/template_polyfunc.go b/lang/funcs/core/template_polyfunc.go index c1ad2bf1..22f88c4d 100644 --- a/lang/funcs/core/template_polyfunc.go +++ b/lang/funcs/core/template_polyfunc.go @@ -170,19 +170,19 @@ func (obj *TemplateFunc) run(templateText string, vars types.Value) (string, err // see: https://golang.org/pkg/text/template/#FuncMap for more info // note: we can override any other functions by adding them here... funcMap := map[string]interface{}{ - //"test1": func(in interface{}) (interface{}, error) { // ok - // return fmt.Sprintf("got(%T): %+v", in, in), nil - //}, - //"test2": func(in interface{}) interface{} { // NOT ok - // panic("panic") // a panic here brings down everything! - //}, - //"test3": func(foo int64) (string, error) { // ok, but errors - // return "", fmt.Errorf("i am an error") - //}, - //"test4": func(in1, in2 reflect.Value) (reflect.Value, error) { // ok - // s := fmt.Sprintf("got: %+v and: %+v", in1, in2) - // return reflect.ValueOf(s), nil - //}, + //"test1": func(in interface{}) (interface{}, error) { // ok + // return fmt.Sprintf("got(%T): %+v", in, in), nil + //}, + //"test2": func(in interface{}) interface{} { // NOT ok + // panic("panic") // a panic here brings down everything! + //}, + //"test3": func(foo int64) (string, error) { // ok, but errors + // return "", fmt.Errorf("i am an error") + //}, + //"test4": func(in1, in2 reflect.Value) (reflect.Value, error) { // ok + // s := fmt.Sprintf("got: %+v and: %+v", in1, in2) + // return reflect.ValueOf(s), nil + //}, } // FIXME: should we do this once in init() instead, or in the Register diff --git a/lang/structs.go b/lang/structs.go index baa948ca..be00d590 100644 --- a/lang/structs.go +++ b/lang/structs.go @@ -1722,10 +1722,10 @@ func (obj *ExprStr) String() string { return fmt.Sprintf("str(%s)", obj.V) } // itself. func (obj *ExprStr) Interpolate() (interfaces.Expr, error) { pos := &Pos{ - // column/line number, starting at 1 - //Column: -1, // TODO - //Line: -1, // TODO - //Filename: "", // optional source filename, if known + // column/line number, starting at 1 + //Column: -1, // TODO + //Line: -1, // TODO + //Filename: "", // optional source filename, if known } result, err := InterpolateStr(obj.V, pos) if err != nil { diff --git a/test/test-gofmt.sh b/test/test-gofmt.sh index 150d81c3..e2c7e9d0 100755 --- a/test/test-gofmt.sh +++ b/test/test-gofmt.sh @@ -11,12 +11,6 @@ ROOT=$(dirname "${BASH_SOURCE}")/.. cd "${ROOT}" . test/util.sh -#GO_VERSION=($(go version)) -# -#if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3|go1.4|go1.5|go1.6|go1.7|go1.8|go1.9|devel') ]]; then -# fail_test "Unknown go version '${GO_VERSION[2]}', failing gofmt." -#fi - find_files() { git ls-files | grep '\.go$' } diff --git a/test/test-govet.sh b/test/test-govet.sh index 7ebbaa67..73a4dbb4 100755 --- a/test/test-govet.sh +++ b/test/test-govet.sh @@ -57,21 +57,13 @@ function consistent-imports() { fi } -# loop through directories in an attempt to scan each go package -for dir in `find . -maxdepth 5 -type d -not -path './old/*' -not -path './old' -not -path './tmp/*' -not -path './tmp' -not -path './.*' -not -path './vendor/*'`; do - match="$dir/*.go" - #echo "match is: $match" - if ! ls $match &>/dev/null; then - #echo "skipping: $match" - continue # no *.go files found - fi - #echo "matching: $match" - if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3|go1.4|go1.5|go1.6|go1.7|go1.8') ]]; then - # workaround go vet issues by adding the new -source flag (go1.9+) - run-test go vet -source "$match" || fail_test "go vet -source did not pass pkg" - else - run-test go vet "$match" || fail_test "go vet did not pass pkg" # since it doesn't output an ok message on pass - fi +# run go vet on a per-package basis +base=$(go list .) +for pkg in `go list -e ./... | grep -v "^${base}/vendor/" | grep -v "^${base}/examples/" | grep -v "^${base}/test/" | grep -v "^${base}/old" | grep -v "^${base}/old/" | grep -v "^${base}/tmp" | grep -v "^${base}/tmp/"`; do + echo -e "\tgo vet: $pkg" + # workaround go vet issues by adding the new -source flag (go1.9+) + run-test go vet -source "$pkg" || fail_test "go vet -source did not pass pkg" + done # loop through individual *.go files diff --git a/vendor/github.com/coreos/etcd b/vendor/github.com/coreos/etcd index c2360678..27fc7e22 160000 --- a/vendor/github.com/coreos/etcd +++ b/vendor/github.com/coreos/etcd @@ -1 +1 @@ -Subproject commit c23606781f63d09917a1e7abfcefeb337a9608ea +Subproject commit 27fc7e2296f506182f58ce846e48f36b34fe6842