Skip to content

Commit

Permalink
Enable revive linter (prometheus-community#519)
Browse files Browse the repository at this point in the history
* Bump Go to 1.17
* Bump prometheus orb to 0.15.0
* Enable `revive` linter.
* Fixup linter nits.

Signed-off-by: SuperQ <superq@gmail.com>
Signed-off-by: iishabakaev <iishabakaev@gmail.com>
  • Loading branch information
SuperQ authored and iishabakaev committed Jun 8, 2022
1 parent 97b529e commit fbc11b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
version: 2.1

orbs:
prometheus: prometheus/prometheus@0.11.0
prometheus: prometheus/prometheus@0.15.0

executors:
# This must match .promu.yml.
golang:
docker:
- image: circleci/golang:1.16
- image: circleci/golang:1.17

jobs:
test:
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
linters:
enable:
- revive

issues:
exclude-rules:
- path: _test.go
Expand Down
2 changes: 1 addition & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
go:
# This must match .circle/config.yml.
version: 1.16
version: 1.17
repository:
path: github.com/prometheus-community/elasticsearch_exporter
build:
Expand Down
6 changes: 3 additions & 3 deletions collector/indices_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestIndicesSettings(t *testing.T) {
// t.Errorf("Wrong setting for cluster routing allocation enabled")
// }
var counter int
var total_fields int
var totalFields int
for key, value := range nsr {
if value.Settings.IndexInfo.Blocks.ReadOnly == "true" {
counter++
Expand All @@ -89,7 +89,7 @@ func TestIndicesSettings(t *testing.T) {
}
}
if value.Settings.IndexInfo.Mapping.TotalFields.Limit == "10000" {
total_fields++
totalFields++
if key != "instagram" {
t.Errorf("Expected 10000 total_fields only for instagram")
}
Expand All @@ -98,7 +98,7 @@ func TestIndicesSettings(t *testing.T) {
if counter != 2 {
t.Errorf("Wrong number of read_only indexes")
}
if total_fields != 1 {
if totalFields != 1 {
t.Errorf(("Wrong number of total_fields found"))
}
}
Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import (

const name = "elasticsearch_exporter"

type transportWithApiKey struct {
type transportWithAPIKey struct {
underlyingTransport http.RoundTripper
apiKey string
}

func (t *transportWithApiKey) RoundTrip(req *http.Request) (*http.Response, error) {
func (t *transportWithAPIKey) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Add("Authorization", fmt.Sprintf("ApiKey %s", t.apiKey))
return t.underlyingTransport.RoundTrip(req)
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func main() {
esInsecureSkipVerify = kingpin.Flag("es.ssl-skip-verify",
"Skip SSL verification when connecting to Elasticsearch.").
Default("false").Envar("ES_SSL_SKIP_VERIFY").Bool()
esApiKey = kingpin.Flag("es.apiKey",
esAPIKey = kingpin.Flag("es.apiKey",
"API Key to use for authenticating against Elasticsearch").
Default("").Envar("ES_API_KEY").String()
logLevel = kingpin.Flag("log.level",
Expand Down Expand Up @@ -146,10 +146,10 @@ func main() {
Proxy: http.ProxyFromEnvironment,
}

if *esApiKey != "" {
apiKey := *esApiKey
if *esAPIKey != "" {
apiKey := *esAPIKey

httpTransport = &transportWithApiKey{
httpTransport = &transportWithAPIKey{
underlyingTransport: httpTransport,
apiKey: apiKey,
}
Expand Down

0 comments on commit fbc11b1

Please sign in to comment.