Skip to content

Commit

Permalink
Merge pull request #55 from NETWAYS/chore/go1-23
Browse files Browse the repository at this point in the history
Bump Go to 1.23
  • Loading branch information
martialblog authored Sep 27, 2024
2 parents 5c129c5 + c2843be commit eb4b1aa
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.23

- name: Test
run: go test -v ./...
Expand All @@ -32,6 +32,6 @@ jobs:
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.61
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ linters:
- goerr113
- gofumpt
- gomnd
- mnd
- lll
- musttag
- nakedret
Expand Down
2 changes: 1 addition & 1 deletion cmd/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inactive = 0`,
\_[OK] [PrometheusTargetMissing] is inactive
\_[CRITICAL] [PrometheusAlertmanagerJobMissing] - Job: [alertmanager] is firing - value: 1.00
| total=2 firing=1 pending=0 inactive=1`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
var (
counterFiring int
counterPending int
Expand Down
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"context"
"fmt"
"errors"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -103,7 +103,7 @@ func (c *Config) NewClient() *client.Client {
if c.BasicAuth != "" {
s := strings.Split(c.BasicAuth, ":")
if len(s) != 2 {
check.ExitError(fmt.Errorf("specify the user name and password for server authentication <user:password>"))
check.ExitError(errors.New("specify the user name and password for server authentication <user:password>"))
}

var u = config.NewInlineSecret(s[0])
Expand Down
8 changes: 4 additions & 4 deletions cmd/health.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"fmt"
"errors"

"github.com/NETWAYS/go-check"
"github.com/NETWAYS/go-check/result"
Expand All @@ -20,7 +20,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
$ check_prometheus --bearer secrettoken health --ready
OK - Prometheus Server is Ready. | statuscode=200`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
var (
rc int
)
Expand All @@ -43,7 +43,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
rc, _, output, err := c.GetStatus(ctx, "ready")

if err != nil {
check.ExitError(fmt.Errorf(output))
check.ExitError(errors.New(output))
}

partialResult := result.NewPartialResult()
Expand Down Expand Up @@ -81,7 +81,7 @@ Ready: Checks the readiness of an endpoint, which returns OK if the Prometheus s
rc, _, output, err := c.GetStatus(ctx, "healthy")

if err != nil {
check.ExitError(fmt.Errorf(output))
check.ExitError(errors.New(output))
}

partialResult := result.NewPartialResult()
Expand Down
17 changes: 9 additions & 8 deletions cmd/query.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"math"
"strconv"
Expand Down Expand Up @@ -61,12 +62,12 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
\_[OK] go_gc_duration_seconds_count{instance="localhost:9090", job="prometheus"} - value: 1599
\_[CRITICAL] go_gc_duration_seconds_count{instance="node-exporter:9100", job="node-exporter"} - value: 79610
| value_go_gc_duration_seconds_count_localhost:9090_prometheus=1599 value_go_gc_duration_seconds_count_node-exporter:9100_node-exporter=79610`,
PreRun: func(cmd *cobra.Command, args []string) {
PreRun: func(_ *cobra.Command, _ []string) {
if cliQueryConfig.Warning == "" || cliQueryConfig.Critical == "" {
check.ExitError(fmt.Errorf("please specify warning and critical thresholds"))
check.ExitError(errors.New("please specify warning and critical thresholds"))
}
},
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
crit, err := check.ParseThreshold(cliQueryConfig.Critical)
if err != nil {
check.ExitError(err)
Expand All @@ -90,7 +91,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest

if err != nil {
if strings.Contains(err.Error(), "unmarshalerDecoder: unexpected value type \"string\"") {
err = fmt.Errorf("string value results are not supported")
err = errors.New("string value results are not supported")
}
check.ExitError(err)
}
Expand All @@ -99,15 +100,15 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest

switch result.Type() {
default:
check.ExitError(fmt.Errorf("none value results are not supported"))
check.ExitError(errors.New("none value results are not supported"))
// Scalar - a simple numeric floating point value
case model.ValScalar:
check.ExitError(fmt.Errorf("scalar value results are not supported"))
check.ExitError(errors.New("scalar value results are not supported"))
case model.ValNone:
check.ExitError(fmt.Errorf("none value results are not supported"))
check.ExitError(errors.New("none value results are not supported"))
case model.ValString:
// String - a simple string value; currently unused
check.ExitError(fmt.Errorf("string value results are not supported"))
check.ExitError(errors.New("string value results are not supported"))
case model.ValVector:
// Instant vector - a set of time series containing a single sample for each time series, all sharing the same timestamp
vectorVal := result.(model.Vector)
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Timeout = 30
var rootCmd = &cobra.Command{
Use: "check_prometheus",
Short: "An Icinga check plugin to check Prometheus",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(_ *cobra.Command, _ []string) {
go check.HandleTimeout(Timeout)
},
Run: Usage,
Expand Down

0 comments on commit eb4b1aa

Please sign in to comment.