Skip to content

Commit 06e085c

Browse files
committed
Add Fields type alias to log package
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent ce21597 commit 06e085c

File tree

21 files changed

+35
-46
lines changed

21 files changed

+35
-46
lines changed

cmd/containerd/command/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ can be used and modified as necessary as a custom configuration.`
174174
log.G(ctx).WithError(w).Warn("cleanup temp mount")
175175
}
176176

177-
log.G(ctx).WithFields(logrus.Fields{
177+
log.G(ctx).WithFields(log.Fields{
178178
"version": version.Version,
179179
"revision": version.Revision,
180180
}).Info("starting containerd")

cmd/ctr/commands/content/prune.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var pruneReferencesCommand = cli.Command{
8181

8282
for k := range info.Labels {
8383
if isLayerLabel(k) {
84-
log.G(ctx).WithFields(logrus.Fields{
84+
log.G(ctx).WithFields(log.Fields{
8585
"digest": info.Digest,
8686
"label": k,
8787
}).Debug("Removing label")

diff/apply/apply.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/containerd/containerd/mount"
2929
digest "github.com/opencontainers/go-digest"
3030
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
31-
"github.com/sirupsen/logrus"
3231
)
3332

3433
// NewFileSystemApplier returns an applier which simply mounts
@@ -52,7 +51,7 @@ func (s *fsApplier) Apply(ctx context.Context, desc ocispec.Descriptor, mounts [
5251
t1 := time.Now()
5352
defer func() {
5453
if err == nil {
55-
log.G(ctx).WithFields(logrus.Fields{
54+
log.G(ctx).WithFields(log.Fields{
5655
"d": time.Since(t1),
5756
"digest": desc.Digest,
5857
"size": desc.Size,

diff/lcow/lcow.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
"github.com/containerd/containerd/plugin"
4040
digest "github.com/opencontainers/go-digest"
4141
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
42-
"github.com/sirupsen/logrus"
4342
)
4443

4544
const (
@@ -99,7 +98,7 @@ func (s windowsLcowDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mou
9998
t1 := time.Now()
10099
defer func() {
101100
if err == nil {
102-
log.G(ctx).WithFields(logrus.Fields{
101+
log.G(ctx).WithFields(log.Fields{
103102
"d": time.Since(t1),
104103
"digest": desc.Digest,
105104
"size": desc.Size,

diff/windows/windows.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
"github.com/containerd/containerd/plugin"
4343
"github.com/opencontainers/go-digest"
4444
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
45-
"github.com/sirupsen/logrus"
4645
)
4746

4847
func init() {
@@ -94,7 +93,7 @@ func (s windowsDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts
9493
t1 := time.Now()
9594
defer func() {
9695
if err == nil {
97-
log.G(ctx).WithFields(logrus.Fields{
96+
log.G(ctx).WithFields(log.Fields{
9897
"d": time.Since(t1),
9998
"digest": desc.Digest,
10099
"size": desc.Size,
@@ -295,7 +294,7 @@ func (s windowsDiff) Compare(ctx context.Context, lower, upper []mount.Mount, op
295294
Digest: info.Digest,
296295
}
297296

298-
log.G(ctx).WithFields(logrus.Fields{
297+
log.G(ctx).WithFields(log.Fields{
299298
"d": time.Since(t1),
300299
"dgst": desc.Digest,
301300
"size": desc.Size,

events/exchange/exchange.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/containerd/containerd/namespaces"
3131
"github.com/containerd/typeurl/v2"
3232
goevents "github.com/docker/go-events"
33-
"github.com/sirupsen/logrus"
3433
)
3534

3635
// Exchange broadcasts events
@@ -59,7 +58,7 @@ func (e *Exchange) Forward(ctx context.Context, envelope *events.Envelope) (err
5958
}
6059

6160
defer func() {
62-
logger := log.G(ctx).WithFields(logrus.Fields{
61+
logger := log.G(ctx).WithFields(log.Fields{
6362
"topic": envelope.Topic,
6463
"ns": envelope.Namespace,
6564
"type": envelope.Event.GetTypeUrl(),
@@ -103,7 +102,7 @@ func (e *Exchange) Publish(ctx context.Context, topic string, event events.Event
103102
envelope.Event = encoded
104103

105104
defer func() {
106-
logger := log.G(ctx).WithFields(logrus.Fields{
105+
logger := log.G(ctx).WithFields(log.Fields{
107106
"topic": envelope.Topic,
108107
"ns": envelope.Namespace,
109108
"type": envelope.Event.GetTypeUrl(),

integration/client/client_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828

2929
"github.com/opencontainers/go-digest"
3030
"github.com/opencontainers/image-spec/identity"
31-
"github.com/sirupsen/logrus"
3231
"github.com/stretchr/testify/require"
3332
"go.opentelemetry.io/otel"
3433
exec "golang.org/x/sys/execabs"
@@ -123,7 +122,7 @@ func TestMain(m *testing.M) {
123122
}
124123

125124
// allow comparison with containerd under test
126-
log.G(ctx).WithFields(logrus.Fields{
125+
log.G(ctx).WithFields(log.Fields{
127126
"version": version.Version,
128127
"revision": version.Revision,
129128
"runtime": os.Getenv("TEST_RUNTIME"),

integration/client/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/opencontainers/go-digest v1.0.0
1515
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
1616
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
17-
github.com/sirupsen/logrus v1.9.0
17+
github.com/sirupsen/logrus v1.9.0 // indirect
1818
github.com/stretchr/testify v1.8.1
1919
go.opentelemetry.io/otel v1.12.0
2020
go.opentelemetry.io/otel/sdk v1.12.0

log/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ var (
3535

3636
type (
3737
loggerKey struct{}
38+
39+
// Fields type to pass to `WithFields`, alias from `logrus`.
40+
Fields = logrus.Fields
3841
)
3942

4043
const (

pkg/transfer/local/pull.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/containerd/containerd/remotes"
3030
"github.com/containerd/containerd/remotes/docker"
3131
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
32-
"github.com/sirupsen/logrus"
3332
)
3433

3534
func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error {
@@ -223,7 +222,7 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch
223222

224223
func fetchHandler(ingester content.Ingester, fetcher remotes.Fetcher, pt *ProgressTracker) images.HandlerFunc {
225224
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
226-
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{
225+
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{
227226
"digest": desc.Digest,
228227
"mediatype": desc.MediaType,
229228
"size": desc.Size,

0 commit comments

Comments
 (0)