diff --git a/cmd/karma/alert_history_test.go b/cmd/karma/alert_history_test.go index 6c3cbfe4f..87d1cd702 100644 --- a/cmd/karma/alert_history_test.go +++ b/cmd/karma/alert_history_test.go @@ -12,9 +12,10 @@ import ( "github.com/google/go-cmp/cmp" "github.com/jarcoal/httpmock" "github.com/prometheus/common/model" + "github.com/rs/zerolog" + "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/regex" - "github.com/rs/zerolog" ) type prometheusAPIV1Labels struct { diff --git a/cmd/karma/assets.go b/cmd/karma/assets.go index 70fc9c887..68125ff36 100644 --- a/cmd/karma/assets.go +++ b/cmd/karma/assets.go @@ -9,8 +9,9 @@ import ( "strings" "time" - "github.com/prymitive/karma/ui" "github.com/rs/zerolog/log" + + "github.com/prymitive/karma/ui" ) func contentText(w http.ResponseWriter) { diff --git a/cmd/karma/auth_headers_test.go b/cmd/karma/auth_headers_test.go index fa6a86a35..a438541fd 100644 --- a/cmd/karma/auth_headers_test.go +++ b/cmd/karma/auth_headers_test.go @@ -8,6 +8,7 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/jarcoal/httpmock" + "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/mock" ) diff --git a/cmd/karma/benchmark_test.go b/cmd/karma/benchmark_test.go index 4788d8dfe..472f33dd2 100644 --- a/cmd/karma/benchmark_test.go +++ b/cmd/karma/benchmark_test.go @@ -9,9 +9,10 @@ import ( "runtime" "testing" + "github.com/rs/zerolog" + "github.com/prymitive/karma/internal/mock" "github.com/prymitive/karma/internal/models" - "github.com/rs/zerolog" ) func reportMemoryMetrics(b *testing.B) { diff --git a/cmd/karma/exporter.go b/cmd/karma/exporter.go index c8e080d96..6a49b80e2 100644 --- a/cmd/karma/exporter.go +++ b/cmd/karma/exporter.go @@ -10,8 +10,9 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/prometheus/client_golang/prometheus" - "github.com/prymitive/karma/internal/config" "github.com/rs/zerolog/log" + + "github.com/prymitive/karma/internal/config" ) var ( diff --git a/cmd/karma/metrics.go b/cmd/karma/metrics.go index 9958a6717..8aa4eac79 100644 --- a/cmd/karma/metrics.go +++ b/cmd/karma/metrics.go @@ -4,6 +4,7 @@ import ( "runtime" "github.com/prometheus/client_golang/prometheus" + "github.com/prymitive/karma/internal/alertmanager" ) diff --git a/cmd/karma/proxy.go b/cmd/karma/proxy.go index f76d79aa2..426ad65b5 100644 --- a/cmd/karma/proxy.go +++ b/cmd/karma/proxy.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/go-chi/chi/v5" + "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/mapper" diff --git a/cmd/karma/proxy_test.go b/cmd/karma/proxy_test.go index 3f161e4c2..8a8090ffc 100644 --- a/cmd/karma/proxy_test.go +++ b/cmd/karma/proxy_test.go @@ -15,10 +15,11 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/jarcoal/httpmock" "github.com/pmezard/go-difflib/difflib" + "github.com/rs/zerolog" + "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/mock" - "github.com/rs/zerolog" ) // httptest.NewRecorder() doesn't implement http.CloseNotifier diff --git a/cmd/karma/views.go b/cmd/karma/views.go index 7b07e101c..905eec501 100644 --- a/cmd/karma/views.go +++ b/cmd/karma/views.go @@ -15,6 +15,7 @@ import ( "github.com/cnf/structhash" "github.com/fvbommel/sortorder" + "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/filters" diff --git a/cmd/karma/views_test.go b/cmd/karma/views_test.go index 660fa939a..287678bab 100644 --- a/cmd/karma/views_test.go +++ b/cmd/karma/views_test.go @@ -18,6 +18,7 @@ import ( "github.com/beme/abide" lru "github.com/hashicorp/golang-lru" + "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/mock" diff --git a/internal/alertmanager/benchmark_test.go b/internal/alertmanager/benchmark_test.go index cfdb0e2a5..fd8fb9b58 100644 --- a/internal/alertmanager/benchmark_test.go +++ b/internal/alertmanager/benchmark_test.go @@ -3,9 +3,10 @@ package alertmanager_test import ( "testing" + "github.com/spf13/pflag" + "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/config" - "github.com/spf13/pflag" ) func BenchmarkDedupAlerts(b *testing.B) { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 01a0ce6ad..32ab810fe 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -8,10 +8,11 @@ import ( "time" "github.com/google/go-cmp/cmp" - "github.com/prymitive/karma/internal/uri" "github.com/rs/zerolog" "github.com/spf13/pflag" + "github.com/prymitive/karma/internal/uri" + "github.com/pmezard/go-difflib/difflib" yaml "gopkg.in/yaml.v3" diff --git a/internal/mapper/v017/silences.go b/internal/mapper/v017/silences.go index 4f8fc1254..ed762a767 100644 --- a/internal/mapper/v017/silences.go +++ b/internal/mapper/v017/silences.go @@ -5,6 +5,7 @@ import ( "time" "github.com/Masterminds/semver/v3" + "github.com/prymitive/karma/internal/mapper" "github.com/prymitive/karma/internal/models" ) diff --git a/internal/mapper/v017/status.go b/internal/mapper/v017/status.go index be3b8f52a..0f3c66f78 100644 --- a/internal/mapper/v017/status.go +++ b/internal/mapper/v017/status.go @@ -5,6 +5,7 @@ import ( "time" "github.com/Masterminds/semver/v3" + "github.com/prymitive/karma/internal/mapper" "github.com/prymitive/karma/internal/models" ) diff --git a/internal/models/alert.go b/internal/models/alert.go index 6683930ae..bd0e02639 100644 --- a/internal/models/alert.go +++ b/internal/models/alert.go @@ -7,6 +7,7 @@ import ( "github.com/cnf/structhash" "github.com/fvbommel/sortorder" + "github.com/prymitive/karma/internal/config" ) diff --git a/internal/models/alert_test.go b/internal/models/alert_test.go index a683ad4b8..e4354ee9b 100644 --- a/internal/models/alert_test.go +++ b/internal/models/alert_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/models" ) diff --git a/internal/models/annotation.go b/internal/models/annotation.go index e73496d82..f25f0e4f5 100644 --- a/internal/models/annotation.go +++ b/internal/models/annotation.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/fvbommel/sortorder" + "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/slices" ) diff --git a/internal/models/annotation_test.go b/internal/models/annotation_test.go index 0251848c7..b56ebddf2 100644 --- a/internal/models/annotation_test.go +++ b/internal/models/annotation_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/models" ) diff --git a/internal/uri/uri_test.go b/internal/uri/uri_test.go index d36a82384..77d6a86c5 100644 --- a/internal/uri/uri_test.go +++ b/internal/uri/uri_test.go @@ -12,8 +12,9 @@ import ( "testing" "time" - "github.com/prymitive/karma/internal/uri" "github.com/rs/zerolog" + + "github.com/prymitive/karma/internal/uri" ) type httpTransportTest struct { diff --git a/make/go.mk b/make/go.mk index 7a01895de..9f50c9d91 100644 --- a/make/go.mk +++ b/make/go.mk @@ -41,9 +41,12 @@ $(GOBIN)/golangci-lint: tools/golangci-lint/go.mod tools/golangci-lint/go.sum lint-go: $(GOBIN)/golangci-lint lint-go-looppointer $(ENV) golangci-lint run -v --timeout 5m -E staticcheck,misspell,promlinter,revive,tenv,errorlint,exportloopref,predeclared +$(GOBIN)/lint-go-goimports: tools/goimports/go.mod tools/goimports/go.sum + go install -modfile=tools/goimports/go.mod golang.org/x/tools/cmd/goimports .PHONY: format-go -format-go: +format-go: $(GOBIN)/lint-go-goimports gofmt -l -s -w . + goimports -local github.com/prymitive/karma -w . .PHONY: download-deps-go download-deps-go: diff --git a/tools/goimports/go.mod b/tools/goimports/go.mod new file mode 100644 index 000000000..de9cdef32 --- /dev/null +++ b/tools/goimports/go.mod @@ -0,0 +1,11 @@ +module _ + +go 1.17 + +require golang.org/x/tools v0.1.8 + +require ( + golang.org/x/mod v0.5.1 // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect +) diff --git a/tools/goimports/go.sum b/tools/goimports/go.sum new file mode 100644 index 000000000..b0bad9f67 --- /dev/null +++ b/tools/goimports/go.sum @@ -0,0 +1,28 @@ +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w= +golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/tools/goimports/main.go b/tools/goimports/main.go new file mode 100644 index 000000000..907433b9c --- /dev/null +++ b/tools/goimports/main.go @@ -0,0 +1,7 @@ +//go:build tools + +package tools + +import ( + _ "golang.org/x/tools/cmd/goimports" +)