Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
malletgaetan committed Dec 29, 2024
1 parent 9e6673c commit 302b12a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ vet:
test:
go test ./...

lint:
golangci-lint run

fuzz:
go test -fuzz=FuzzParseConfig -fuzztime=5m ./internal/config

re: clean all

.PHONY: all clean re fmt
.PHONY: all clean re fmt lint
5 changes: 2 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@ func (c *Config) Dump() {
var t uint = 0
if cmd.Timeout != 0 {
t = cmd.Timeout
} else if cmd.Timeout != 0 {
t = cmd.Timeout
} else if c.timeout != 0 {
t = c.timeout
}
if t != 0 {
timeout += strconv.FormatUint(uint64(t), 10)
}
fmt.Printf("%s%s%s%s%s%s%s\n", eventType, delimiter, action, delimiter, timeout, delimiter, strings.Join(cmd.Args, ","))
}
}
return
}

func (c *Config) SetCmd(typ string, action string, comd *cmd.Cmd) {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func FuzzParseConfig(f *testing.F) {
f.Add(corpusBytes)

f.Fuzz(func(t *testing.T, data []byte) {
hints, _ := configVersion["1.47"]
hints := configVersion["1.47"]
scanner := bufio.NewScanner(bytes.NewReader(data))
config, err := ParseConfig(scanner, hints)

Expand Down
3 changes: 1 addition & 2 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ func Initialize(cfg Config) {
Level: cfg.Level,
}

var handler slog.Handler
handler = slog.NewTextHandler(os.Stdout, opts)
handler := slog.NewTextHandler(os.Stdout, opts)

Log = slog.New(handler)
slog.SetDefault(Log)
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"syscall"
"time"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/client"
"github.com/malletgaetan/dockermon/internal/config"
"github.com/malletgaetan/dockermon/internal/logger"
Expand Down Expand Up @@ -56,7 +56,7 @@ func handleEvents(client *client.Client, conf *config.Config) error {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()

msgs, errs := client.Events(ctx, types.EventsOptions{
msgs, errs := client.Events(ctx, events.ListOptions{
Filters: conf.Filters(),
})

Expand Down

0 comments on commit 302b12a

Please sign in to comment.