Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
* Update Go to 1.20.
* Update golanci-lint.
* Bump modules.
* Update CI orb.
* Fix up use of deprecated ioutil.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Mar 5, 2023
1 parent c86f549 commit 0e654d8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 735 deletions.
6 changes: 3 additions & 3 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.16.0
prometheus: prometheus/prometheus@0.17.1

executors:
# This must match .promu.yml.
golang:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20

jobs:
test:
Expand All @@ -22,7 +22,7 @@ jobs:

integration:
docker:
- image: cimg/go:1.19
- image: cimg/go:1.20
- image: << parameters.postgres_image >>
environment:
POSTGRES_DB: circle_test
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.20.x
- name: Install snmp_exporter/generator dependencies
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
if: github.repository == 'prometheus/snmp_exporter'
- name: Lint
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.45.2
version: v1.51.2
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.19
version: 1.20
repository:
path: github.com/prometheus-community/postgres_exporter
build:
Expand Down
7 changes: 3 additions & 4 deletions cmd/postgres_exporter/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package main

import (
"fmt"
"io/ioutil"
"net/url"
"os"
"regexp"
Expand Down Expand Up @@ -130,7 +129,7 @@ func getDataSources() ([]string, error) {

dataSourceUserFile := os.Getenv("DATA_SOURCE_USER_FILE")
if len(dataSourceUserFile) != 0 {
fileContents, err := ioutil.ReadFile(dataSourceUserFile)
fileContents, err := os.ReadFile(dataSourceUserFile)
if err != nil {
return nil, fmt.Errorf("failed loading data source user file %s: %s", dataSourceUserFile, err.Error())
}
Expand All @@ -141,7 +140,7 @@ func getDataSources() ([]string, error) {

dataSourcePassFile := os.Getenv("DATA_SOURCE_PASS_FILE")
if len(dataSourcePassFile) != 0 {
fileContents, err := ioutil.ReadFile(dataSourcePassFile)
fileContents, err := os.ReadFile(dataSourcePassFile)
if err != nil {
return nil, fmt.Errorf("failed loading data source pass file %s: %s", dataSourcePassFile, err.Error())
}
Expand All @@ -153,7 +152,7 @@ func getDataSources() ([]string, error) {
ui := url.UserPassword(user, pass).String()
dataSrouceURIFile := os.Getenv("DATA_SOURCE_URI_FILE")
if len(dataSrouceURIFile) != 0 {
fileContents, err := ioutil.ReadFile(dataSrouceURIFile)
fileContents, err := os.ReadFile(dataSrouceURIFile)
if err != nil {
return nil, fmt.Errorf("failed loading data source URI file %s: %s", dataSrouceURIFile, err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/postgres_exporter/postgres_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"database/sql"
"errors"
"fmt"
"io/ioutil"
"math"
"os"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -663,7 +663,7 @@ func (e *Exporter) checkMapVersions(ch chan<- prometheus.Metric, server *Server)
e.userQueriesError.Reset()

// Calculate the hashsum of the useQueries
userQueriesData, err := ioutil.ReadFile(e.userQueriesPath)
userQueriesData, err := os.ReadFile(e.userQueriesPath)
if err != nil {
level.Error(logger).Log("msg", "Failed to reload user queries", "path", e.userQueriesPath, "err", err)
e.userQueriesError.WithLabelValues(e.userQueriesPath, "").Set(1)
Expand Down
3 changes: 1 addition & 2 deletions cmd/postgres_exporter/postgres_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package main

import (
"io/ioutil"
"math"
"os"
"reflect"
Expand Down Expand Up @@ -409,7 +408,7 @@ func (s *FunctionalSuite) TestBooleanConversionToValueAndString(c *C) {
}

func (s *FunctionalSuite) TestParseUserQueries(c *C) {
userQueriesData, err := ioutil.ReadFile("./tests/user_queries_ok.yaml")
userQueriesData, err := os.ReadFile("./tests/user_queries_ok.yaml")
if err == nil {
metricMaps, newQueryOverrides, err := parseUserQueries(userQueriesData)
c.Assert(err, Equals, nil)
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/prometheus-community/postgres_exporter

go 1.17
go 1.19

require (
github.com/blang/semver/v4 v4.0.0
Expand Down Expand Up @@ -30,12 +30,12 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/prometheus/procfs v0.8.0 // indirect
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/oauth2 v0.3.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
Loading

3 comments on commit 0e654d8

@macmiranda
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SuperQ could you trigger a build from master and publish it to docker hub or any other registry? Just want to test #697

@SuperQ
Copy link
Contributor Author

@SuperQ SuperQ commented on 0e654d8 Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macmiranda This happens automatically on every push to master. But it broke recently due to changes in CircleCI. Part of this PR (The CI orb update) was to fix that.

Looks like the auto-publish works now:

https://quay.io/repository/prometheuscommunity/postgres-exporter?tab=tags&tag=master

@macmiranda
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macmiranda This happens automatically on every push to master. But it broke recently due to changes in CircleCI. Part of this PR (The CI orb update) was to fix that.

Looks like the auto-publish works now:

https://quay.io/repository/prometheuscommunity/postgres-exporter?tab=tags&tag=master

Thanks. Tested. Working fine!

Please sign in to comment.