Skip to content

Commit

Permalink
Adjust govet findings
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Jan 15, 2025
1 parent 6aa70ea commit ef2893a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 21 deletions.
8 changes: 5 additions & 3 deletions access/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package access

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"

"github.com/echocat/caretakerd/errors"
)

// Permission represents the service's/node's permissions in caretakerd.
Expand Down Expand Up @@ -64,7 +66,7 @@ func (instance *Permission) Set(value string) error {
return nil
}
}
return errors.New("Illegal permission: " + value)
return fmt.Errorf("illegal permission type: %v", value)
}
lowerValue := strings.ToLower(value)
for _, candidate := range AllPermissions {
Expand All @@ -73,7 +75,7 @@ func (instance *Permission) Set(value string) error {
return nil
}
}
return errors.New("Illegal permission: " + value)
return fmt.Errorf("illegal permission type: %v", value)
}

// MarshalYAML is used until yaml marshalling. Do not call directly.
Expand Down
8 changes: 5 additions & 3 deletions access/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package access

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"

"github.com/echocat/caretakerd/errors"
)

// Type indicates the validation type for the access of a service/node to caretakerd.
Expand Down Expand Up @@ -73,7 +75,7 @@ func (instance *Type) Set(value string) error {
return nil
}
}
return errors.New("Illegal access type: " + value)
return fmt.Errorf("illegal access type: %v", value)
}
lowerValue := strings.ToLower(value)
for _, candidate := range AllTypes {
Expand All @@ -82,7 +84,7 @@ func (instance *Type) Set(value string) error {
return nil
}
}
return errors.New("Illegal access type: " + value)
return fmt.Errorf("illegal permission type: %v", value)
}

// MarshalYAML is used until yaml marshalling. Do not call this method directly.
Expand Down
8 changes: 5 additions & 3 deletions keyStore/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package keyStore

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"

"github.com/echocat/caretakerd/errors"
)

// # Description
Expand Down Expand Up @@ -68,7 +70,7 @@ func (instance *Type) Set(value string) error {
return nil
}
}
return errors.New("Illegal keyStore type: " + value)
return fmt.Errorf("illegal keyStore type: %v", value)
}
lowerValue := strings.ToLower(value)
for _, candidate := range AllTypes {
Expand All @@ -77,7 +79,7 @@ func (instance *Type) Set(value string) error {
return nil
}
}
return errors.New("Illegal keyStore type: " + value)
return fmt.Errorf("illegal keyStore type: %v", value)
}

// MarshalYAML is used until yaml marshalling. Do not call this method directly.
Expand Down
6 changes: 3 additions & 3 deletions logger/level.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package logger

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"
)
Expand Down Expand Up @@ -87,7 +87,7 @@ func (instance *Level) Set(value string) error {
return nil
}
}
return errors.New("Illegal level: " + value)
return fmt.Errorf("illegal level: %v", value)
}
lowerValue := strings.ToLower(value)
switch lowerValue {
Expand All @@ -104,7 +104,7 @@ func (instance *Level) Set(value string) error {
return nil
}
}
return errors.New("Illegal level: " + value)
return fmt.Errorf("illegal level: %v", value)
}

// IsIndicatingProblem returns "true" if this level indicates a problem.
Expand Down
8 changes: 5 additions & 3 deletions service/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package service

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"

"github.com/echocat/caretakerd/errors"
)

// Status represents a status of a service execution.
Expand Down Expand Up @@ -73,7 +75,7 @@ func (instance *Status) Set(value string) error {
return nil
}
}
return errors.New("Illegal status: " + value)
return fmt.Errorf("illegal status: %v", value)
}
lowerValue := strings.ToLower(value)
for _, candidate := range AllStatus {
Expand All @@ -82,7 +84,7 @@ func (instance *Status) Set(value string) error {
return nil
}
}
return errors.New("Illegal status: " + value)
return fmt.Errorf("illegal status: %v", value)
}

// MarshalJSON is used until json marshalling. Do not call this method directly.
Expand Down
8 changes: 5 additions & 3 deletions service/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package service

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"

"github.com/echocat/caretakerd/errors"
)

// # Description
Expand Down Expand Up @@ -76,7 +78,7 @@ func (instance *Type) Set(value string) error {
return nil
}
}
return errors.New("Illegal type: " + value)
return fmt.Errorf("illegal type: %v", value)
}
lowerValue := strings.ToLower(value)
for _, candidate := range AllTypes {
Expand All @@ -85,7 +87,7 @@ func (instance *Type) Set(value string) error {
return nil
}
}
return errors.New("Illegal type: " + value)
return fmt.Errorf("illegal type: %v", value)
}

// MarshalYAML is used until yaml marshalling. Do not call this method directly.
Expand Down
8 changes: 5 additions & 3 deletions values/signalTarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package values

import (
"encoding/json"
"github.com/echocat/caretakerd/errors"
"fmt"
"strconv"
"strings"

"github.com/echocat/caretakerd/errors"
)

// SignalTarget defines who have to receives a signal.
Expand Down Expand Up @@ -62,7 +64,7 @@ func (instance *SignalTarget) Set(value string) error {
return nil
}
}
return errors.New("Illegal signal target: " + value)
return fmt.Errorf("illegal signal target: %v", value)
}
lowerValue := strings.ToLower(value)
for _, candidate := range AllSignalTargets {
Expand All @@ -71,7 +73,7 @@ func (instance *SignalTarget) Set(value string) error {
return nil
}
}
return errors.New("Illegal signal target: " + value)
return fmt.Errorf("illegal signal target: %v", value)
}

// MarshalYAML is used until yaml marshalling. Do not call this method directly.
Expand Down

0 comments on commit ef2893a

Please sign in to comment.