Skip to content

Commit 10c5ad5

Browse files
authored
Update linter for slog (#907)
This enforces that we always use attributes and context. This turned up a callsite that wasn't using attributes, which is now fixed. This sets up the linter settings in a proper file, instead of relying on flag-passing. This should give more consistency and configuration options.
1 parent 5214df8 commit 10c5ad5

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
2525
with:
2626
version: v2.10.1
27-
args: --timeout=8m --enable=sloglint
27+
args: --timeout=8m

.golangci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "2"
2+
3+
linters:
4+
enable:
5+
- depguard
6+
- sloglint
7+
settings:
8+
depguard:
9+
rules:
10+
main:
11+
deny:
12+
- pkg: "k8s.io/klog/v2"
13+
desc: "klog is forbidden, use log/slog instead"
14+
- pkg: "k8s.io/klog"
15+
desc: "klog is forbidden, use log/slog instead"
16+
sloglint:
17+
attr-only: true
18+
context: all

storage/gcp/gcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func (a *Appender) publishCheckpointJob(ctx context.Context, pubInterval, republ
380380
}
381381
return nil
382382
}); err != nil {
383-
slog.ErrorContext(ctx, "publishCheckpoint failed", "error", err)
383+
slog.ErrorContext(ctx, "publishCheckpoint failed", slog.Any("error", err))
384384
}
385385
}
386386
}

0 commit comments

Comments
 (0)