diff --git a/.travis.yml b/.travis.yml index ed15f1a7c..8cfb58d4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ dist: trusty sudo: required language: go -go: '1.10' +go: '1.10.3' services: - docker addons: diff --git a/Gopkg.lock b/Gopkg.lock index 0f8d9dd7b..aa4f33691 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -29,7 +29,7 @@ ".", "handlers/cli" ] - revision = "ff0f66940b829dc66c81dad34746d4349b83eb9e" + revision = "941dea75d3ebfbdd905a5d8b7b232965c5e5c684" [[projects]] name = "github.com/aws/aws-sdk-go" @@ -44,6 +44,7 @@ "aws/credentials/ec2rolecreds", "aws/credentials/endpointcreds", "aws/credentials/stscreds", + "aws/csm", "aws/defaults", "aws/ec2metadata", "aws/endpoints", @@ -54,6 +55,8 @@ "internal/sdkrand", "internal/shareddefaults", "private/protocol", + "private/protocol/eventstream", + "private/protocol/eventstream/eventstreamapi", "private/protocol/query", "private/protocol/query/queryutil", "private/protocol/rest", @@ -62,8 +65,8 @@ "service/s3", "service/sts" ] - revision = "31a85efbe3bc741eb539d6310c8e66030b7c5cb7" - version = "v1.13.47" + revision = "e4f914808a9655ef3220bb0082002239cc7f3561" + version = "v1.14.19" [[projects]] branch = "master" @@ -92,14 +95,14 @@ [[projects]] name = "github.com/fatih/color" packages = ["."] - revision = "507f6050b8568533fb3f5504de8e5205fa62a114" - version = "v1.6.0" + revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4" + version = "v1.7.0" [[projects]] name = "github.com/go-ini/ini" packages = ["."] - revision = "6529cf7c58879c08d927016dde4477f18a0634cb" - version = "v1.36.0" + revision = "06f5f3d67269ccec1fe5fe4134ba6e982984f7f5" + version = "v1.37.0" [[projects]] name = "github.com/golang/protobuf" @@ -111,7 +114,7 @@ branch = "master" name = "github.com/google/go-github" packages = ["github"] - revision = "eafdb6578137f78fe186e486a4bc633e1434cc89" + revision = "e96c8d145b73ef0bc15d2d3f0327ce6d88a17c5a" [[projects]] branch = "master" @@ -137,14 +140,14 @@ "glob", "rpm" ] - revision = "d2eaeef92bdb3ead4ee45852b10b81f4c650f4fc" - version = "v0.9.0" + revision = "25eddcb1759ae5b07e79bb55727075fe43492a17" + version = "v0.9.2" [[projects]] name = "github.com/imdario/mergo" packages = ["."] - revision = "9d5f1277e9a8ed20c3684bda8fde67c05628518c" - version = "v0.3.4" + revision = "9316a62528ac99aaecb4e47eadd6dc8aa6533d58" + version = "v0.3.5" [[projects]] name = "github.com/jmespath/go-jmespath" @@ -176,13 +179,13 @@ ".", "fastwalk" ] - revision = "9960a25705902198f55789b9b689a686682798b5" + revision = "c436403c742d0b6d8fc37e69eadf33e024fe74fa" [[projects]] branch = "master" name = "github.com/mitchellh/go-homedir" packages = ["."] - revision = "b8bc1bf767474819792c23f32d8286a45736f1c6" + revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66" [[projects]] name = "github.com/pkg/errors" @@ -202,8 +205,8 @@ "assert", "require" ] - revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71" - version = "v1.2.1" + revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" + version = "v1.2.2" [[projects]] branch = "master" @@ -212,7 +215,7 @@ "context", "context/ctxhttp" ] - revision = "640f4622ab692b87c2f3a94265e6f579fe38263d" + revision = "ed29d75add3d7c4bf7ca65aac0c6df3d1420216f" [[projects]] branch = "master" @@ -221,7 +224,7 @@ ".", "internal" ] - revision = "cdc340f7c179dbbfa4afd43b7614e8fcadde4269" + revision = "ef147856a6ddbb60760db74283d2424e98c87bff" [[projects]] branch = "master" @@ -233,7 +236,7 @@ branch = "master" name = "golang.org/x/sys" packages = ["unix"] - revision = "78d5f264b493f125018180c204871ecf58a2dce1" + revision = "7138fd3d9dc8335c567ca206f4333fb75eb05d56" [[projects]] name = "google.golang.org/appengine" @@ -246,8 +249,8 @@ "internal/urlfetch", "urlfetch" ] - revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a" - version = "v1.0.0" + revision = "b1f26356af11148e710935ed1ac8a7f5702c7612" + version = "v1.1.0" [[projects]] name = "gopkg.in/yaml.v2" diff --git a/Makefile b/Makefile index d12008023..581c469f5 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ export PATH := ./bin:$(PATH) setup: go get -u golang.org/x/tools/cmd/stringer go get -u golang.org/x/tools/cmd/cover + # TODO: temporary hack for https://github.com/golang/go/issues/21387 + (cd $$GOPATH/src/golang.org/x/tools; git checkout ae8cc594552814363a7aeeb4f2825515a771fa38; go install ./cmd/stringer/... ; go install ./cmd/cover/...) curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh curl -sfL https://install.goreleaser.com/github.com/gohugoio/hugo.sh | sh curl -sfL https://install.goreleaser.com/github.com/caarlos0/bandep.sh | sh @@ -44,7 +46,8 @@ fmt: # Run all the linters lint: - golangci-lint run --tests=false --enable-all ./... + # TODO: fix tests and lll issues + ./bin/golangci-lint run --tests=false --enable-all --disable=lll ./... find . -name '*.md' -not -wholename './vendor/*' | xargs prettier -l .PHONY: lint diff --git a/internal/builders/golang/build.go b/internal/builders/golang/build.go index 13b5311f3..2237fadac 100644 --- a/internal/builders/golang/build.go +++ b/internal/builders/golang/build.go @@ -55,7 +55,7 @@ func (*Builder) WithDefaults(build config.Build) config.Build { // Build builds a golang build func (*Builder) Build(ctx *context.Context, build config.Build, options api.Options) error { - if err := checkMain(ctx, build); err != nil { + if err := checkMain(build); err != nil { return err } cmd := []string{"go", "build"} @@ -187,7 +187,7 @@ func (b buildTarget) Env() []string { } } -func checkMain(ctx *context.Context, build config.Build) error { +func checkMain(build config.Build) error { var main = build.Main if main == "" { main = "." diff --git a/internal/builders/golang/targets.go b/internal/builders/golang/targets.go index 068e19707..856ab399a 100644 --- a/internal/builders/golang/targets.go +++ b/internal/builders/golang/targets.go @@ -19,6 +19,7 @@ func (t target) String() string { } func matrix(build config.Build) (result []string) { + // nolint:prealloc var targets []target for _, target := range allBuildTargets(build) { if !valid(target) { diff --git a/internal/git/git.go b/internal/git/git.go index 8f08cbed0..51cc37cad 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -2,7 +2,6 @@ package git import ( - "bytes" "errors" "os/exec" "strings" @@ -18,18 +17,17 @@ func IsRepo() bool { // Run runs a git command and returns its output or errors func Run(args ...string) (string, error) { + // TODO: use exex.CommandContext here and refactor. /* #nosec */ var cmd = exec.Command("git", args...) log.WithField("args", args).Debug("running git") - var stdout bytes.Buffer - var stderr bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stderr - if err := cmd.Run(); err != nil { - return "", errors.New(stderr.String()) + bts, err := cmd.CombinedOutput() + log.WithField("output", string(bts)). + Debug("git result") + if err != nil { + return "", errors.New(string(bts)) } - log.WithField("output", stdout.String()).Debug("git result") - return stdout.String(), nil + return string(bts), nil } // Clean the output diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 82491be0b..3d50cbc09 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -110,7 +110,7 @@ func doRun(ctx *context.Context, client client.Client) error { return ErrTooManyDarwin64Builds } - content, err := buildFormula(ctx, client, archives[0]) + content, err := buildFormula(ctx, archives[0]) if err != nil { return err } @@ -141,8 +141,8 @@ func doRun(ctx *context.Context, client client.Client) error { return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path, msg) } -func buildFormula(ctx *context.Context, client client.Client, artifact artifact.Artifact) (bytes.Buffer, error) { - data, err := dataFor(ctx, client, artifact) +func buildFormula(ctx *context.Context, artifact artifact.Artifact) (bytes.Buffer, error) { + data, err := dataFor(ctx, artifact) if err != nil { return bytes.Buffer{}, err } @@ -158,7 +158,7 @@ func doBuildFormula(data templateData) (out bytes.Buffer, err error) { return } -func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artifact) (result templateData, err error) { +func dataFor(ctx *context.Context, artifact artifact.Artifact) (result templateData, err error) { sum, err := checksum.SHA256(artifact.Path) if err != nil { return diff --git a/pipeline/checksums/checksums.go b/pipeline/checksums/checksums.go index 74f05732d..1973f388a 100644 --- a/pipeline/checksums/checksums.go +++ b/pipeline/checksums/checksums.go @@ -62,7 +62,7 @@ func (Pipe) Run(ctx *context.Context) (err error) { artifact := artifact g.Go(func() error { defer sem.Release() - return checksums(ctx, file, artifact) + return checksums(file, artifact) }) } ctx.Artifacts.Add(artifact.Artifact{ @@ -73,7 +73,7 @@ func (Pipe) Run(ctx *context.Context) (err error) { return g.Wait() } -func checksums(ctx *context.Context, file *os.File, artifact artifact.Artifact) error { +func checksums(file *os.File, artifact artifact.Artifact) error { log.WithField("file", artifact.Name).Info("checksumming") sha, err := checksum.SHA256(artifact.Path) if err != nil { diff --git a/pipeline/docker/docker.go b/pipeline/docker/docker.go index 9e3d9ea14..cd714d415 100644 --- a/pipeline/docker/docker.go +++ b/pipeline/docker/docker.go @@ -149,6 +149,7 @@ func tagName(ctx *context.Context, tagTemplate string) (string, error) { func process(ctx *context.Context, docker config.Docker, artifact artifact.Artifact, seed int) error { var root = filepath.Dir(artifact.Path) var dockerfile = filepath.Join(root, filepath.Base(docker.Dockerfile)) + fmt.Sprintf(".%d", seed) + // nolint:prealloc var images []string for _, tagTemplate := range docker.TagTemplates { tag, err := tagName(ctx, tagTemplate) diff --git a/pipeline/release/body.go b/pipeline/release/body.go index adab5cd29..081a1216e 100644 --- a/pipeline/release/body.go +++ b/pipeline/release/body.go @@ -27,6 +27,7 @@ func init() { func describeBody(ctx *context.Context) (bytes.Buffer, error) { var out bytes.Buffer + // nolint:prealloc var dockers []string for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() { dockers = append(dockers, a.Name) diff --git a/pipeline/scoop/scoop.go b/pipeline/scoop/scoop.go index 9106acff8..517fdce57 100644 --- a/pipeline/scoop/scoop.go +++ b/pipeline/scoop/scoop.go @@ -63,7 +63,7 @@ func doRun(ctx *context.Context, client client.Client) error { path := ctx.Config.ProjectName + ".json" - content, err := buildManifest(ctx, client, archives) + content, err := buildManifest(ctx, archives) if err != nil { return err } @@ -100,7 +100,7 @@ type Resource struct { Bin string `json:"bin"` // name of binary inside the archive } -func buildManifest(ctx *context.Context, client client.Client, artifacts []artifact.Artifact) (result bytes.Buffer, err error) { +func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (result bytes.Buffer, err error) { manifest := Manifest{ Version: ctx.Version, Architecture: make(map[string]Resource), diff --git a/pipeline/scoop/scoop_test.go b/pipeline/scoop/scoop_test.go index 03e6307d9..9a025827c 100644 --- a/pipeline/scoop/scoop_test.go +++ b/pipeline/scoop/scoop_test.go @@ -404,7 +404,7 @@ func Test_buildManifest(t *testing.T) { }, }, } - out, err := buildManifest(ctx, &DummyClient{}, []artifact.Artifact{ + out, err := buildManifest(ctx, []artifact.Artifact{ {Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64"}, {Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"}, }) diff --git a/pipeline/sign/sign.go b/pipeline/sign/sign.go index 76015789e..8fe039d52 100644 --- a/pipeline/sign/sign.go +++ b/pipeline/sign/sign.go @@ -61,6 +61,7 @@ func (Pipe) Run(ctx *context.Context) error { } func sign(ctx *context.Context, artifacts []artifact.Artifact) error { + // nolint:prealloc var sigs []string for _, a := range artifacts { sig, err := signone(ctx, a) @@ -87,6 +88,7 @@ func signone(ctx *context.Context, artifact artifact.Artifact) (string, error) { } env["signature"] = expand(cfg.Signature, env) + // nolint:prealloc var args []string for _, a := range cfg.Args { args = append(args, expand(a, env))