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
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "monthly"

# Maintain dependencies for Docker Compose
- package-ecosystem: "docker-compose" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
125 changes: 62 additions & 63 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,81 @@
version: "2"
run:
timeout: 5m
issues-exit-code: 1
tests: true

modules-download-mode: vendor

# list of build tags, all linters use it. Default is empty list
build-tags:
- integration

# output configuration options
output:
# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

uniq-by-line: false

modules-download-mode: vendor
issues-exit-code: 1
tests: true
linters:
disable-all: true
default: none
enable:
- gofmt
- gosimple
- unparam
- goconst
- prealloc
- stylecheck
- unconvert
- unused
- staticcheck
- ineffassign
- gosec
- tparallel
- whitespace
- revive
- godot
- bodyclose
- dogsled
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- forcetypeassert
- goconst
- gocritic
- errname
- godot
- goprintffuncname
- gosec
- govet
- predeclared
- ineffassign
- makezero
- nestif
- exhaustive
- tenv
- gofumpt
- forcetypeassert
- nilerr
- errcheck
- bodyclose
- goimports
- durationcheck
- errchkjson
- sloglint
- dupword
- noctx
- makezero
- nilnil
- noctx
- nonamedreturns
- perfsprint
- prealloc
- predeclared
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- testifylint
- wastedassign
- rowserrcheck
- sqlclosecheck
- goprintffuncname
- staticcheck
# - tagalign
- testableexamples
- wastedassign
- nonamedreturns
- perfsprint
- dogsled
- protogetter
- testifylint
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- testableexamples
fast: false

- wastedassign
- whitespace
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- vendor
- third_party$
- builtin$
- examples$
issues:
exclude-dirs:
- vendor
max-same-issues: 10
uniq-by-line: false
formatters:
enable:
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- vendor
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ fmtcheck:

.PHONY: lint
lint: fmtcheck
docker run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint -v run
docker run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v2.0.2 golangci-lint -v run

.PHONY: deeplint
deeplint: fmtcheck
docker run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint run --exclude-use-default=false --enable-all -D dupl --build-tags integration
docker run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v2.0.2 golangci-lint run --exclude-use-default=false --enable-all -D dupl --build-tags integration

.PHONY: deps-start
deps-start:
Expand Down
18 changes: 14 additions & 4 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@

setEnvVarCacheRetention()
seedConsulAccessToken("currentaccesstoken")
setRedisOpeningBalance(ctx, "1000")
err := setRedisOpeningBalance(ctx, "1000")
if err != nil {
log.Printf("failed to set redis opening balance: %v", err)
return
}

Check warning on line 57 in examples/main.go

View check run for this annotation

Codecov / codecov/patch

examples/main.go#L53-L57

Added lines #L53 - L57 were not covered by tests

cfg := config{}

Expand All @@ -74,18 +78,24 @@
harvester.WithRedisMonitor(redisClient, 200*time.Millisecond),
)
if err != nil {
log.Fatalf("failed to create harvester: %v", err)
log.Printf("failed to create harvester: %v", err)
return

Check warning on line 82 in examples/main.go

View check run for this annotation

Codecov / codecov/patch

examples/main.go#L81-L82

Added lines #L81 - L82 were not covered by tests
}

err = h.Harvest(ctx)
if err != nil {
log.Fatalf("failed to harvest configuration: %v", err)
log.Printf("failed to harvest configuration: %v", err)
return

Check warning on line 88 in examples/main.go

View check run for this annotation

Codecov / codecov/patch

examples/main.go#L87-L88

Added lines #L87 - L88 were not covered by tests
}

log.Println(cfg.String())

seedConsulAccessToken("newtaccesstoken")
setRedisOpeningBalance(ctx, "2000")
err = setRedisOpeningBalance(ctx, "2000")
if err != nil {
log.Printf("failed to set redis opening balance: %v", err)
return
}

Check warning on line 98 in examples/main.go

View check run for this annotation

Codecov / codecov/patch

examples/main.go#L94-L98

Added lines #L94 - L98 were not covered by tests

time.Sleep(1 * time.Second) // Wait for the data to be updated async...

Expand Down
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module github.com/beatlabs/harvester

go 1.22.12

toolchain go1.24.0
go 1.24

require (
github.com/hashicorp/consul/api v1.31.2
github.com/hashicorp/consul/api v1.32.0
github.com/hashicorp/go-hclog v1.6.3
github.com/redis/go-redis/v9 v9.7.3
github.com/stretchr/testify v1.10.0
Expand All @@ -32,8 +30,8 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/sys v0.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/hashicorp/consul/api v1.31.2 h1:NicObVJHcCmyOIl7Z9iHPvvFrocgTYo9cITSGg0/7pw=
github.com/hashicorp/consul/api v1.31.2/go.mod h1:Z8YgY0eVPukT/17ejW+l+C7zJmKwgPHtjU1q16v/Y40=
github.com/hashicorp/consul/api v1.32.0 h1:5wp5u780Gri7c4OedGEPzmlUEzi0g2KyiPphSr6zjVg=
github.com/hashicorp/consul/api v1.32.0/go.mod h1:Z8YgY0eVPukT/17ejW+l+C7zJmKwgPHtjU1q16v/Y40=
github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg=
github.com/hashicorp/consul/sdk v0.16.1/go.mod h1:fSXvwxB2hmh1FMZCNl6PwX0Q/1wdWtHJcZ7Ea5tns0s=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -181,10 +181,10 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -198,8 +198,8 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -218,13 +218,13 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
Expand Down
2 changes: 1 addition & 1 deletion monitor/consul/watcher_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestWatch(t *testing.T) {
default:
assert.Fail(t, "key invalid", cng.Key())
}
assert.Positive(t, cng.Version())
assert.Positive(t, cng.Version()) //nolint:testifylint
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion seed/consul/getter_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestGetter_Get(t *testing.T) {
} else {
require.NoError(t, err)
assert.Equal(t, tt.want, got)
assert.GreaterOrEqual(t, version, uint64(0))
assert.GreaterOrEqual(t, version, uint64(0)) //nolint:testifylint
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestString_UnmarshalJSON(t *testing.T) {
var b String
err := b.UnmarshalJSON([]byte(`foo`))
require.Error(t, err)
assert.Equal(t, "", b.Get())
assert.Empty(t, b.Get())

err = b.UnmarshalJSON([]byte(`"foo"`))
require.NoError(t, err)
Expand Down Expand Up @@ -270,13 +270,13 @@ func TestRegexp_SetString(t *testing.T) {

func TestRegexp_String(t *testing.T) {
sr := Regexp{}
assert.Equal(t, "", sr.String())
assert.Empty(t, sr.String())
}

func TestRegexp_MarshalJSON(t *testing.T) {
sr := Regexp{}
json, err := sr.MarshalJSON()
assert.Equal(t, []byte(`""`), json)
assert.JSONEq(t, `""`, string(json))
require.NoError(t, err)
}

Expand All @@ -293,7 +293,7 @@ func TestStringMap(t *testing.T) {

d, err := sm.MarshalJSON()
require.NoError(t, err)
assert.Equal(t, `{"key":"value"}`, string(d))
assert.JSONEq(t, `{"key":"value"}`, string(d))
}

func TestStringMap_SetString(t *testing.T) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/hashicorp/consul/api/health.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading