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
13 changes: 0 additions & 13 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"path"

flag "github.com/spf13/pflag"

log "github.com/sirupsen/logrus"
)

type Config struct {
Expand Down Expand Up @@ -72,7 +70,6 @@ func (c *Config) ParseArray(arguments []string) {
}

if c.DefaultHelper {
c.SetupLogging()
c.EnableTimeoutHandler()
}
}
Expand All @@ -85,13 +82,3 @@ func (c *Config) addDefaultFlags() {

c.DefaultFlags = false
}

func (c *Config) SetupLogging() {
if c.Debug {
log.SetLevel(log.DebugLevel)
} else if c.Verbose {
log.SetLevel(log.InfoLevel)
} else {
log.SetLevel(log.WarnLevel)
}
}
39 changes: 6 additions & 33 deletions convert/bytes_common_test.go
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
package convert

import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"testing"
)

func ExampleParseBytes() {
bSI, err := ParseBytes("100MB")
if err != nil {
log.Fatal(err)
}

bIEC, err := ParseBytes("100MiB")
if err != nil {
log.Fatal(err)
}

fmt.Println("SI units")
fmt.Println(bSI.Bytes())
fmt.Println(bSI)
fmt.Println(bSI.HumanReadable())

fmt.Println("IEC units")
fmt.Println(bIEC.Bytes())
fmt.Println(bIEC)
fmt.Println(bIEC.HumanReadable())
// Output:
// SI units
// 100000000
// 100MB
// 100MB
// IEC units
// 104857600
// 100MiB
// 100MiB
}

func TestParseBytes(t *testing.T) {
b, err := ParseBytes("1024")
assert.NoError(t, err)
Expand All @@ -54,6 +21,12 @@ func TestParseBytes(t *testing.T) {
assert.IsType(t, BytesIEC(0), b)
assert.Equal(t, uint64(1024*1024), b.Bytes())

b, err = ParseBytes("100MB")
assert.NoError(t, err)

b, err = ParseBytes("100MiB")
assert.NoError(t, err)

b, err = ParseBytes(" 23 GiB ")
assert.NoError(t, err)
assert.IsType(t, BytesIEC(0), b)
Expand Down
7 changes: 4 additions & 3 deletions cmd/check_example/main.go → examples/check_example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/NETWAYS/go-check"
log "github.com/sirupsen/logrus"
"log"
)

func main() {
Expand All @@ -19,8 +19,9 @@ func main() {

config.ParseArguments()

log.Info("Start logging")

if config.Debug {
log.Println("Start logging")
}
// time.Sleep(20 * time.Second)

if *value > *critical {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ module github.com/NETWAYS/go-check
go 1.14

require (
github.com/jarcoal/httpmock v1.3.0
github.com/mitchellh/go-ps v1.0.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v3 v3.0.1
)
9 changes: 0 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc=
github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down