From cba0bb6dabf4745d6aa237f593ec5a4e6c43d20c Mon Sep 17 00:00:00 2001 From: SuperQ Date: Tue, 29 Nov 2022 17:41:37 +0100 Subject: [PATCH] Sync Prometheus Makefile.common Fix up lint issues. Signed-off-by: SuperQ --- Makefile.common | 7 +++++-- notify/slack/slack_test.go | 3 +-- pkg/labels/matcher_test.go | 6 +++--- pkg/labels/parse.go | 11 ++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Makefile.common b/Makefile.common index 6c8e3e21..7642c448 100644 --- a/Makefile.common +++ b/Makefile.common @@ -58,16 +58,19 @@ endif PROMU_VERSION ?= 0.13.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz +SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.45.2 +GOLANGCI_LINT_VERSION ?= v1.49.0 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) # If we're in CI and there is an Actions file, that means the linter # is being run in Actions, so we don't need to run it here. - ifeq (,$(CIRCLE_JOB)) + ifneq (,$(SKIP_GOLANGCI_LINT)) + GOLANGCI_LINT := + else ifeq (,$(CIRCLE_JOB)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint else ifeq (,$(wildcard .github/workflows/golangci-lint.yml)) GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint diff --git a/notify/slack/slack_test.go b/notify/slack/slack_test.go index c61ffdb2..9a4f16cf 100644 --- a/notify/slack/slack_test.go +++ b/notify/slack/slack_test.go @@ -15,7 +15,6 @@ package slack import ( "fmt" - "io/ioutil" "os" "testing" @@ -86,7 +85,7 @@ func TestTrimmingSlackURLFromFile(t *testing.T) { ctx, u, fn := test.GetContextWithCancelingURL() defer fn() - f, err := ioutil.TempFile("", "slack_test_newline") + f, err := os.CreateTemp("", "slack_test_newline") require.NoError(t, err, "creating temp file failed") _, err = f.WriteString(u.String() + "\n\n") require.NoError(t, err, "writing to temp file failed") diff --git a/pkg/labels/matcher_test.go b/pkg/labels/matcher_test.go index bd89a2b7..21d1b7f0 100644 --- a/pkg/labels/matcher_test.go +++ b/pkg/labels/matcher_test.go @@ -177,10 +177,10 @@ line`, want: `foo="new\nline"`, }, { - name: `foo`, - op: MatchEqual, + name: `foo`, + op: MatchEqual, value: `tab stop`, - want: `foo="tab stop"`, + want: `foo="tab stop"`, }, } diff --git a/pkg/labels/parse.go b/pkg/labels/parse.go index 06a414e7..a125d59d 100644 --- a/pkg/labels/parse.go +++ b/pkg/labels/parse.go @@ -45,11 +45,12 @@ var ( // this comma and whitespace will be trimmed. // // Examples for valid input strings: -// {foo = "bar", dings != "bums", } -// foo=bar,dings!=bums -// foo=bar, dings!=bums -// {quote="She said: \"Hi, ladies! That's gender-neutral…\""} -// statuscode=~"5.." +// +// {foo = "bar", dings != "bums", } +// foo=bar,dings!=bums +// foo=bar, dings!=bums +// {quote="She said: \"Hi, ladies! That's gender-neutral…\""} +// statuscode=~"5.." // // See ParseMatcher for details on how an individual Matcher is parsed. func ParseMatchers(s string) ([]*Matcher, error) {