Skip to content

Commit

Permalink
clean up linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: James Ranson <[email protected]>
  • Loading branch information
jranson committed May 18, 2024
1 parent c363908 commit d119922
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pkg/backends/alb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package alb

import (
"errors"
"fmt"
"net/http"
"strings"
Expand All @@ -29,6 +28,7 @@ import (
"github.com/trickstercache/trickster/v2/pkg/backends/providers"
"github.com/trickstercache/trickster/v2/pkg/backends/providers/registration/types"
"github.com/trickstercache/trickster/v2/pkg/cache"
"github.com/trickstercache/trickster/v2/pkg/errors"
"github.com/trickstercache/trickster/v2/pkg/proxy/methods"
"github.com/trickstercache/trickster/v2/pkg/proxy/paths/matching"
po "github.com/trickstercache/trickster/v2/pkg/proxy/paths/options"
Expand Down Expand Up @@ -157,7 +157,7 @@ func (c *Client) ValidatePool(clients backends.Backends) error {
// validate and map out the pool configuration
func (c *Client) ValidateAndStartPool(clients backends.Backends, hcs healthcheck.StatusLookup) error {
if c.Configuration() == nil || c.Configuration().ALBOptions == nil {
return errors.New("invalid options")
return errors.ErrInvalidOptions
}

o := c.Configuration().ALBOptions
Expand All @@ -172,7 +172,7 @@ func (c *Client) ValidateAndStartPool(clients backends.Backends, hcs healthcheck
if !ok {
return fmt.Errorf("invalid pool member name [%s] in backend [%s]", n, c.Name())
}
hc, _ := hcs[n]
hc := hcs[n]
targets = append(targets, pool.NewTarget(tc.Router(), hc))
}
c.pool = pool.New(m, targets, o.HealthyFloor)
Expand Down
8 changes: 4 additions & 4 deletions pkg/backends/alb/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ func TestHandlers(t *testing.T) {
}

a.MechanismName = "fgr"
cl, err = NewClient("test", o, nil, nil, nil, nil)
_, err = NewClient("test", o, nil, nil, nil, nil)
if err != nil {
t.Error(err)
}

a.MechanismName = "nlm"
cl, err = NewClient("test", o, nil, nil, nil, nil)
_, err = NewClient("test", o, nil, nil, nil, nil)
if err != nil {
t.Error(err)
}

a.MechanismName = "tsm"
cl, err = NewClient("test", o, nil, nil, nil, types.Lookup{"prometheus": prometheus.NewClient})
_, err = NewClient("test", o, nil, nil, nil, types.Lookup{"prometheus": prometheus.NewClient})
if err != nil {
t.Error(err)
}

a.MechanismName = "rr"
cl, err = NewClient("test", o, nil, nil, nil, nil)
_, err = NewClient("test", o, nil, nil, nil, nil)
if err != nil {
t.Error(err)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/backends/irondb/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ func TestDefaultHealthCheckConfig(t *testing.T) {
dho := c.DefaultHealthCheckConfig()
if dho == nil {
t.Error("expected non-nil result")
}

if dho.Path != "" {
} else if dho.Path != "" {
t.Error("expected / for path", dho.Path)
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/backends/irondb/irondb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"testing"

"github.com/trickstercache/trickster/v2/pkg/backends"
"github.com/trickstercache/trickster/v2/pkg/backends/irondb/model"
bo "github.com/trickstercache/trickster/v2/pkg/backends/options"
cr "github.com/trickstercache/trickster/v2/pkg/cache/registration"
"github.com/trickstercache/trickster/v2/pkg/config"
Expand Down Expand Up @@ -48,8 +47,6 @@ func TestIRONdbClientInterfacing(t *testing.T) {
}
}

var testModeler = model.NewModeler()

func TestNewClient(t *testing.T) {
conf, _, err := config.Load("trickster", "test",
[]string{"-origin-url", "http://example.com", "-provider", "TEST_CLIENT"})
Expand Down
6 changes: 3 additions & 3 deletions pkg/backends/irondb/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package irondb

import (
"errors"
"fmt"
"net/http"

tkerr "github.com/trickstercache/trickster/v2/pkg/errors"
terr "github.com/trickstercache/trickster/v2/pkg/proxy/errors"
"github.com/trickstercache/trickster/v2/pkg/proxy/request"
"github.com/trickstercache/trickster/v2/pkg/timeseries"
Expand All @@ -45,7 +45,7 @@ func (c *Client) FastForwardRequest(r *http.Request) (*http.Request, error) {

rsc := request.GetResources(r)
if rsc == nil || rsc.PathConfig == nil {
return nil, errors.New("missing path config")
return nil, tkerr.ErrMissingPathconfig
}

switch rsc.PathConfig.HandlerName {
Expand All @@ -68,7 +68,7 @@ func (c *Client) ParseTimeRangeQuery(

rsc := request.GetResources(r)
if rsc == nil || rsc.PathConfig == nil {
return nil, nil, false, errors.New("missing path config")
return nil, nil, false, tkerr.ErrMissingPathconfig
}

var trq *timeseries.TimeRangeQuery
Expand Down
6 changes: 6 additions & 0 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ import "errors"

// ErrNilWriter is an error for a nil writer when a non-nil writer was expected
var ErrNilWriter = errors.New("nil writer")

// ErrInvalidOptions is an error for when a configuration is invalid
var ErrInvalidOptions = errors.New("invalid options")

// ErrMissingPathconfig is an error for when a configuration is missing a path value
var ErrMissingPathconfig = errors.New("missing path config")

0 comments on commit d119922

Please sign in to comment.