Skip to content

cleanup: replace custom handleWarning() with remote.NewWarningLogger() #2314

Description

@TerryHowe

Follow-on to #2008 (phase 2.3). The v2→v3 migration (#2002) has merged; this is one of the remaining deprecation-cleanup items.

Problem

cmd/oras/internal/option/remote.go:543 hand-rolls registry warning handling, including per-registry dedup via a map[string]*sync.Map:

func (remo *Remote) handleWarning(registry string, logger logrus.FieldLogger) func(warning remote.Warning)

It is wired in three places: remote.go:574, remote.go:599, and containers_config.go:126/:158.

oras-go v3 provides the same thing, dedup included:

// oras-go registry/remote/warning.go:76
func NewWarningLogger(registry string, logger *slog.Logger) func(Warning)

Net ~−25 LOC.

Prerequisite: slog→logrus bridge

The CLI logs entirely through logrus — there is no log/slog import anywhere in the tree today, and the context logger is built in internal/trace/context.go / cmd/oras/internal/command/logger.go. NewWarningLogger takes a *slog.Logger.

This needs a small internal/logutil package: a slog.Handler that forwards records to the context's logrus.FieldLogger, preserving the registry field. Roughly 15–30 lines.

Ship the bridge in this PR, not ahead of it, so it does not land as dead code. The same bridge is the prerequisite for ClientBuilder.Logger / ClientBuilder.WarningLogger adoption in the ClientBuilder issue.

Acceptance

  • internal/logutil bridges slog → the context logrus logger
  • handleWarning deleted; all four call sites use remote.NewWarningLogger()
  • Warning dedup per registry is preserved (test it — the current behaviour logs each distinct warning value once per registry)

Activity

  1. added this to the future milestone on Nov 4, 2026
  2. added
    enhancement
    go
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgologging

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions