Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Go
on:
push:
branches: [ master ]
branches: [ main ]
tags:
- v*
pull_request:
Expand All @@ -19,7 +19,8 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.26
go-version: stable
check-latest: true

- name: Vet
run: go vet ./...
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
tags:
- v*
branches:
- master
- main
pull_request:

jobs:
Expand All @@ -17,4 +17,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.2
version: v2.12.2
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ run:
tests: false
linters:
default: all
enable:
- wsl_v5
- gomodguard_v2
disable:
- wsl
- gomodguard
- cyclop
- depguard
- err113
Expand Down
5 changes: 2 additions & 3 deletions alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/NETWAYS/check_sophos_central/api"
"github.com/NETWAYS/go-check"
"github.com/NETWAYS/go-check/perfdata"
)

type AlertOverview struct {
Expand Down Expand Up @@ -80,7 +79,7 @@ func (o *AlertOverview) GetSummary() string {
return "alerts: " + strings.Join(states, ", ")
}

func (o *AlertOverview) GetStatus() int {
func (o *AlertOverview) GetStatus() check.Status {
if o.High > 0 {
return check.Critical
} else if o.Medium > 0 || o.Low > 0 {
Expand All @@ -103,7 +102,7 @@ func (o *AlertOverview) GetOutput() (s string) {
}

func (o *AlertOverview) GetPerfdata() string {
tmp := perfdata.PerfdataList{
tmp := check.PerfdataList{
{Label: "alerts", Value: o.Total},
{Label: "alerts_high", Value: o.High},
{Label: "alerts_medium", Value: o.Medium},
Expand Down
2 changes: 1 addition & 1 deletion check.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *Config) Validate() error {
return nil
}

func (c *Config) Run() (rc int, output string, err error) {
func (c *Config) Run() (rc check.Status, output string, err error) {
// Setup API client.
client := api.NewClient(c.ClientID, c.ClientSecret)
client.PageSize = c.PageSize
Expand Down
5 changes: 2 additions & 3 deletions endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/NETWAYS/check_sophos_central/api"
"github.com/NETWAYS/go-check"
"github.com/NETWAYS/go-check/perfdata"
)

type EndpointOverview struct {
Expand Down Expand Up @@ -70,7 +69,7 @@ func (o *EndpointOverview) GetSummary() (s string) {
return
}

func (o *EndpointOverview) GetStatus() int {
func (o *EndpointOverview) GetStatus() check.Status {
// nolint: gocritic
if len(o.Bad) > 0 {
return check.Critical
Expand Down Expand Up @@ -104,7 +103,7 @@ func (o *EndpointOverview) GetOutput(limit int) (s string) {
}

func (o *EndpointOverview) GetPerfdata() string {
tmp := perfdata.PerfdataList{
tmp := check.PerfdataList{
{Label: "endpoints_total", Value: o.Total},
{Label: "endpoints_good", Value: len(o.Good)},
{Label: "endpoints_bad", Value: len(o.Bad)},
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/NETWAYS/check_sophos_central

go 1.25.0
go 1.26

require (
github.com/NETWAYS/go-check v0.6.4
github.com/NETWAYS/go-check v1.0.0
github.com/jarcoal/httpmock v1.4.1
github.com/spf13/pflag v1.0.10
golang.org/x/oauth2 v0.36.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/NETWAYS/go-check v0.6.4 h1:4WETSVNZNEP0Yudcp5xlvxq6RGn920cmUKq4fz/P1GQ=
github.com/NETWAYS/go-check v0.6.4/go.mod h1:8/GWnq8SirreAixgRmcp82JG16NnEl38rHq9phICy9s=
github.com/NETWAYS/go-check v1.0.0 h1:YkzTwFfGR+Z+mK3Wsqpnu8wibzsB30im19iPNfCOsMQ=
github.com/NETWAYS/go-check v1.0.0/go.mod h1:8/GWnq8SirreAixgRmcp82JG16NnEl38rHq9phICy9s=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jarcoal/httpmock v1.4.1 h1:0Ju+VCFuARfFlhVXFc2HxlcQkfB+Xq12/EotHko+x2A=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ func main() {
check.ExitError(err)
}

check.ExitRaw(rc, output)
check.Exit(rc, output)
}
10 changes: 6 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"testing"

"github.com/NETWAYS/go-check"
)

func TestMainCheck_matches(t *testing.T) {
Expand Down Expand Up @@ -80,23 +82,23 @@ func TestMainAlerts_GetOutput(t *testing.T) {
func TestMainAlerts_GetStatus(t *testing.T) {
testcases := map[string]struct {
ao AlertOverview
expected int
expected check.Status
}{
"simple-overview": {
ao: AlertOverview{},
expected: 0,
expected: check.OK,
},
"simple-warning": {
ao: AlertOverview{
Medium: 1,
},
expected: 1,
expected: check.Warning,
},
"simple-critical": {
ao: AlertOverview{
High: 1,
},
expected: 2,
expected: check.Critical,
},
}

Expand Down