Skip to content

Commit

Permalink
Update to go 1.15 (#2877)
Browse files Browse the repository at this point in the history
* Upgrade to 1.15.

Also upgrade linter and fixes some lint issues.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

* Update CI.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

* Update generated files.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

* Moar lint 🤦

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

* moar lint and tests fixes.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

* Moar tests fixes.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena authored Nov 4, 2020
1 parent dc0bd01 commit e6778e9
Show file tree
Hide file tree
Showing 31 changed files with 109 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ workflows:
# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
.defaults: &defaults
docker:
- image: grafana/loki-build-image:0.10.0
- image: grafana/loki-build-image:0.11.0
working_directory: /src/loki

jobs:
Expand Down
12 changes: 6 additions & 6 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ workspace:

steps:
- name: test
image: grafana/loki-build-image:0.10.0
image: grafana/loki-build-image:0.11.0
commands:
- make BUILD_IN_CONTAINER=false test
depends_on:
- clone

- name: lint
image: grafana/loki-build-image:0.10.0
image: grafana/loki-build-image:0.11.0
commands:
- make BUILD_IN_CONTAINER=false lint
depends_on:
- clone

- name: check-generated-files
image: grafana/loki-build-image:0.10.0
image: grafana/loki-build-image:0.11.0
commands:
- make BUILD_IN_CONTAINER=false check-generated-files
depends_on:
- clone

- name: check-mod
image: grafana/loki-build-image:0.10.0
image: grafana/loki-build-image:0.11.0
commands:
- make BUILD_IN_CONTAINER=false check-mod
depends_on:
Expand Down Expand Up @@ -814,7 +814,7 @@ platform:

steps:
- name: trigger
image: grafana/loki-build-image:0.10.0
image: grafana/loki-build-image:0.11.0
commands:
- ./tools/deploy.sh
environment:
Expand Down Expand Up @@ -842,7 +842,7 @@ platform:

steps:
- name: trigger
image: grafana/loki-build-image:0.10.0
image: grafana/loki-build-image:0.11.0
commands:
- go run ./tools/delete_tags.go -max-age=2160h -repo grafana/loki -delete
- go run ./tools/delete_tags.go -max-age=2160h -repo grafana/promtail -delete
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Please follow the [Loki Helm Chart](./production/helm/README.md).
### Dependency management

We use [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages.
This requires a working Go environment with version 1.14 or greater and git installed.
This requires a working Go environment with version 1.15 or greater and git installed.

To add or update a new dependency, use the `go get` command:

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ IMAGE_NAMES := $(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)%,
# make BUILD_IN_CONTAINER=false target
# or you can override this with an environment variable
BUILD_IN_CONTAINER ?= true
BUILD_IMAGE_VERSION := 0.10.0
BUILD_IMAGE_VERSION := 0.11.0

# Docker image info
IMAGE_PREFIX ?= grafana
Expand Down
2 changes: 1 addition & 1 deletion cmd/chunks-inspect/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/grafana/loki/cmd/chunks-inspect

go 1.14
go 1.15

require (
github.com/frankban/quicktest v1.7.2 // indirect
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-driver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=grafana/loki-build-image:0.10.0
ARG BUILD_IMAGE=grafana/loki-build-image:0.11.0
# Directories in this file are referenced from the root of the project not this folder
# This file is intended to be called from the root like so:
# docker build -t grafana/loki -f cmd/loki/Dockerfile .
Expand Down
2 changes: 1 addition & 1 deletion cmd/fluent-bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build
COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false fluent-bit-plugin
Expand Down
4 changes: 2 additions & 2 deletions cmd/logcli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build

ARG TOUCH_PROTOS
COPY . /src/loki
Expand All @@ -11,4 +11,4 @@ RUN apk add --no-cache ca-certificates

COPY --from=build /src/loki/cmd/logcli/logcli /usr/bin/logcli

ENTRYPOINT [ "/usr/bin/logcli" ]
ENTRYPOINT [ "/usr/bin/logcli" ]
2 changes: 1 addition & 1 deletion cmd/loki-canary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/loki-canary/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=grafana/loki-build-image:0.10.0
ARG BUILD_IMAGE=grafana/loki-build-image:0.11.0
# Directories in this file are referenced from the root of the project not this folder
# This file is intended to be called from the root like so:
# docker build -t grafana/promtail -f cmd/promtail/Dockerfile .
Expand Down
2 changes: 1 addition & 1 deletion cmd/loki/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/loki/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=grafana/loki-build-image:0.10.0
ARG BUILD_IMAGE=grafana/loki-build-image:0.11.0
# Directories in this file are referenced from the root of the project not this folder
# This file is intended to be called from the root like so:
# docker build -t grafana/loki -f cmd/loki/Dockerfile .
Expand Down
2 changes: 1 addition & 1 deletion cmd/promtail/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/promtail/Dockerfile.arm32
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/promtail/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=grafana/loki-build-image:0.10.0
ARG BUILD_IMAGE=grafana/loki-build-image:0.11.0
# Directories in this file are referenced from the root of the project not this folder
# This file is intended to be called from the root like so:
# docker build -t grafana/promtail -f cmd/promtail/Dockerfile .
Expand Down
2 changes: 1 addition & 1 deletion cmd/querytee/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.2 as build
FROM golang:1.15.3 as build

ARG TOUCH_PROTOS
COPY . /src/loki
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/grafana/loki

go 1.14
go 1.15

require (
github.com/aws/aws-lambda-go v1.17.0
Expand Down
8 changes: 4 additions & 4 deletions loki-build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ RUN apk add --no-cache curl && \
FROM alpine as golangci
RUN apk add --no-cache curl && \
cd / && \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.21.0
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.32.2

FROM alpine:edge as docker
RUN apk add --no-cache docker-cli

# TODO this should be fixed to download and extract the specific release binary from github as we do for golangci and helm above
# however we need a commit which hasn't been released yet: https://github.com/drone/drone-cli/commit/1fad337d74ca0ecf420993d9d2d7229a1c99f054
# Read the comment below regarding GO111MODULE=on and why it is necessary
FROM golang:1.14.2 as drone
FROM golang:1.15.3 as drone
RUN GO111MODULE=on go get github.com/drone/drone-cli/drone@1fad337d74ca0ecf420993d9d2d7229a1c99f054

# Install faillint used to lint go imports in CI.
# This collisions with the version of go tools used in the base image, thus we install it in its own image and copy it over.
# Error:
# github.com/fatih/faillint@v1.5.0 requires golang.org/x/tools@v0.0.0-20200207224406-61798d64f025
# (not golang.org/x/tools@v0.0.0-20190918214920-58d531046acd from golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69)
FROM golang:1.14.2 as faillint
FROM golang:1.15.3 as faillint
RUN GO111MODULE=on go get github.com/fatih/faillint@v1.5.0

FROM golang:1.14.2-stretch
FROM golang:1.15.3-buster
RUN apt-get update && \
apt-get install -qy \
musl gnupg \
Expand Down
2 changes: 2 additions & 0 deletions pkg/ingester/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

// The passed wireChunks slice is for re-use.
// nolint(deadcode)
func toWireChunks(descs []*chunkDesc, wireChunks []Chunk) ([]Chunk, error) {
if cap(wireChunks) < len(descs) {
wireChunks = make([]Chunk, len(descs))
Expand Down Expand Up @@ -38,6 +39,7 @@ func toWireChunks(descs []*chunkDesc, wireChunks []Chunk) ([]Chunk, error) {
return wireChunks, nil
}

// nolint(deadcode)
func fromWireChunks(conf *Config, wireChunks []Chunk) ([]*chunkDesc, error) {
descs := make([]*chunkDesc, 0, len(wireChunks))
for _, c := range wireChunks {
Expand Down
3 changes: 2 additions & 1 deletion pkg/ingester/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"testing"
"time"

"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/tsdb/record"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/pkg/logproto"
)

func Test_Encoding_Series(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/tailer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestTailer_sendRaceConditionOnSendWhileClosing(t *testing.T) {
go assert.NotPanics(t, func() {
defer routines.Done()
time.Sleep(time.Duration(rand.Intn(1000)) * time.Microsecond)
tailer.send(stream)
_ = tailer.send(stream)
})

go assert.NotPanics(t, func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (i *Ingester) transferOut(ctx context.Context) error {
return err
}

chunks := make([]*logproto.Chunk, 1, 1)
chunks := make([]*logproto.Chunk, 1)
chunks[0] = &logproto.Chunk{
Data: bb,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/logentry/stages/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func Test_validateDropConfig(t *testing.T) {
wantErr: fmt.Errorf(
ErrDropStageInvalidDuration,
dropInvalidDur,
"time: unknown unit y in duration 10y",
`time: unknown unit "y" in duration "10y"`,
),
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/logentry/stages/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func Test(t *testing.T) {
IdleDuration: &metricTestInvalidIdle,
},
},
errors.Errorf(ErrInvalidIdleDur, "time: unknown unit f in duration 10f"),
errors.Errorf(ErrInvalidIdleDur, `time: unknown unit "f" in duration "10f"`),
},
"valid": {
MetricsConfig{
Expand Down
1 change: 1 addition & 0 deletions pkg/logql/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/grafana/loki/pkg/logql/log"

"github.com/prometheus/prometheus/pkg/labels"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/logql/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"sort"
"time"

"github.com/grafana/loki/pkg/logql/log"
"github.com/prometheus/prometheus/promql"

"github.com/grafana/loki/pkg/logql/log"
)

const unsupportedErr = "unsupported range vector aggregation operation: %s"
Expand Down
1 change: 1 addition & 0 deletions pkg/promtail/targets/journal/journaltarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var defaultJournalEntryFunc = func(c sdjournal.JournalReaderConfig, cursor strin
}

// JournalTarget tails systemd journal entries.
// nolint(golint)
type JournalTarget struct {
logger log.Logger
handler api.EntryHandler
Expand Down
1 change: 1 addition & 0 deletions pkg/promtail/targets/journal/journaltargetmanager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

// JournalTargetManager manages a series of JournalTargets.
// nolint(golint)
type JournalTargetManager struct {
logger log.Logger
targets map[string]*JournalTarget
Expand Down
Loading

0 comments on commit e6778e9

Please sign in to comment.