Skip to content

Commit ae9796a

Browse files
authored
use consts / linter (#1119)
Signed-off-by: James Ranson <james@ranson.org>
1 parent 10063e7 commit ae9796a

112 files changed

Lines changed: 1442 additions & 908 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ linters:
2929
- mirror
3030
- importas
3131
- perfsprint
32+
- goconst
3233
disable:
3334
- errcheck
34-
- goconst # re-enable after sudden influx of findings are addressed
3535
settings:
3636
dupl:
3737
threshold: 150 # default is 100; have brought current codebase down to 75, but leaving default at 150 for now

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# <img src="./docs/images/logos/trickster-logo.svg" width=90 />&nbsp;&nbsp;&nbsp;&nbsp;<img src="./docs/images/logos/trickster-text.svg" width=420 /> [![Follow on Twitter](https://img.shields.io/twitter/follow/trickstercache.svg?style=social&logo=twitter)](https://twitter.com/trickstercache)
1+
# <img src="./docs/images/logos/trickster-horizontal.svg" width=550 /> [![Follow on Twitter](https://img.shields.io/twitter/follow/trickstercache.svg?style=social&logo=twitter)](https://twitter.com/trickstercache)
22

33
[![License](https://img.shields.io/github/license/trickstercache/trickster)](/LICENSE)
44
[![Coverage Status](https://coveralls.io/repos/github/trickstercache/trickster/badge.svg)](https://coveralls.io/github/trickstercache/trickster)

cmd/trickster/main.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/trickstercache/trickster/v2/pkg/appinfo"
2525
"github.com/trickstercache/trickster/v2/pkg/daemon"
26+
"github.com/trickstercache/trickster/v2/pkg/observability/keys"
2627
"github.com/trickstercache/trickster/v2/pkg/observability/logging"
2728
"github.com/trickstercache/trickster/v2/pkg/observability/logging/logger"
2829
)
@@ -34,16 +35,12 @@ var (
3435
applicationVersion string
3536
)
3637

37-
const (
38-
applicationName = "trickster"
39-
)
40-
4138
func main() {
42-
appinfo.Set(applicationName, applicationVersion,
39+
appinfo.Set(appinfo.AppName, applicationVersion,
4340
applicationBuildTime, applicationGitCommitID)
4441
err := daemon.Start(context.Background(), os.Args[1:]...)
4542
if err != nil {
4643
logger.Fatal(1, "trickster daemon failed to start",
47-
logging.Pairs{"error": err})
44+
logging.Pairs{keys.Error: err})
4845
}
4946
}
-52 KB
Binary file not shown.
-109 KB
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Loading

hack/release-notes/notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# <img src="https://github.com/${REPO}/raw/v${TAG}/docs/images/logos/trickster-logo.svg" width=60 />&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://github.com/${REPO}/raw/v${TAG}/docs/images/logos/trickster-text.svg" width=280 />
1+
# <img src="https://github.com/${REPO}/raw/v${TAG}/docs/images/logos/trickster-horizontal.svg" width=400 />
22

33
Welcome to Trickster ${TAG}! :tada:
44

integration/alb_cache_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333

3434
"github.com/trickstercache/trickster/v2/integration/internal/portutil"
3535
"github.com/trickstercache/trickster/v2/integration/promstub"
36+
"github.com/trickstercache/trickster/v2/pkg/cache/status"
37+
"github.com/trickstercache/trickster/v2/pkg/proxy/headers"
3638

3739
"github.com/stretchr/testify/assert"
3840
"github.com/stretchr/testify/require"
@@ -241,7 +243,7 @@ func TestALBCache(t *testing.T) {
241243
}, 5*time.Second, 100*time.Millisecond, "alb pool never queried the bad-encoding member")
242244

243245
t.Logf("status=%d X-Trickster-Result=%q body=%s",
244-
resp.StatusCode, resp.Header.Get("X-Trickster-Result"), string(body))
246+
resp.StatusCode, resp.Header.Get(headers.NameTricksterResult), string(body))
245247

246248
require.GreaterOrEqual(t, resp.StatusCode, 200,
247249
"expected a response, got status=%d body=%s", resp.StatusCode, string(body))
@@ -265,8 +267,8 @@ func TestALBCache(t *testing.T) {
265267
require.NotEmpty(t, series,
266268
"expected merged series from members 0+1; body=%s", string(body))
267269

268-
raw := resp.Header.Get("X-Trickster-Result")
269-
hasPhit := strings.Contains(raw, "phit")
270+
raw := resp.Header.Get(headers.NameTricksterResult)
271+
hasPhit := strings.Contains(raw, status.StatusPartialHit)
270272
hasWarn := strings.Contains(string(body), `"warnings"`) ||
271273
strings.Contains(string(body), "encoding") ||
272274
strings.Contains(string(body), "unsupported")
@@ -368,13 +370,13 @@ func TestALBCache(t *testing.T) {
368370
body, _ := io.ReadAll(resp.Body)
369371
resp.Body.Close()
370372

371-
raw := resp.Header.Get("X-Trickster-Result")
373+
raw := resp.Header.Get(headers.NameTricksterResult)
372374
t.Logf("status=%d X-Trickster-Result=%q m1Hits=%d m2Hits=%d body=%s",
373375
resp.StatusCode, raw, m1Hits.Load(), m2Hits.Load(), string(body))
374376

375377
require.Equal(t, http.StatusOK, resp.StatusCode)
376378

377-
assert.Containsf(t, raw, "phit",
379+
assert.Containsf(t, raw, status.StatusPartialHit,
378380
"mixed cache hit/miss across pool members did not surface phit in X-Trickster-Result=%q",
379381
raw)
380382
})
@@ -463,7 +465,7 @@ func TestALBCache(t *testing.T) {
463465
}, 10*time.Second, 250*time.Millisecond, "proxy-only TSM pool never merged both members")
464466

465467
t.Logf("status=%d X-Trickster-Result=%q m1Hits=%d m2Hits=%d body=%s",
466-
resp.StatusCode, resp.Header.Get("X-Trickster-Result"), m1Hits.Load(), m2Hits.Load(), string(body))
468+
resp.StatusCode, resp.Header.Get(headers.NameTricksterResult), m1Hits.Load(), m2Hits.Load(), string(body))
467469

468470
var pr promResponse
469471
require.NoError(t, json.Unmarshal(body, &pr),

0 commit comments

Comments
 (0)