From 5d143db66b44c664d74e351374cb03a182062683 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 21 Apr 2026 15:59:27 +0200 Subject: [PATCH] fix formatting strings for go1.26 These started producing an error with go1.26; daemon/builder/dockerfile/dispatchers.go:478:65: fmt.Sprintf format %q has arg runConfig.Healthcheck of wrong type *github.com/moby/moby/api/types/container.HealthConfig daemon/daemon_test.go:291:23: (*testing.common).Fatalf format %q has arg 0 of wrong type int daemon/internal/streamformatter/streamformatter.go:97:44: non-constant format string in call to (github.com/moby/moby/v2/daemon/internal/streamformatter.formatProgress).formatStatus internal/testutil/daemon/daemon.go:814:128: (github.com/moby/moby/v2/internal/testutil/daemon.LogT).Logf format %d reads arg #3, but call has 2 args Signed-off-by: Sebastiaan van Stijn --- daemon/builder/dockerfile/dispatchers.go | 4 ++-- daemon/daemon_test.go | 2 +- daemon/internal/streamformatter/streamformatter.go | 2 +- internal/testutil/daemon/daemon.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/daemon/builder/dockerfile/dispatchers.go b/daemon/builder/dockerfile/dispatchers.go index c70e3bcc0f..1d90b9fefa 100644 --- a/daemon/builder/dockerfile/dispatchers.go +++ b/daemon/builder/dockerfile/dispatchers.go @@ -471,11 +471,11 @@ func dispatchHealthcheck(ctx context.Context, d dispatchRequest, c *instructions if runConfig.Healthcheck != nil { oldCmd := runConfig.Healthcheck.Test if len(oldCmd) > 0 && oldCmd[0] != "NONE" { - fmt.Fprintf(d.builder.Stdout, "Note: overriding previous HEALTHCHECK: %v\n", oldCmd) + fmt.Fprintf(d.builder.Stdout, "Note: overriding previous HEALTHCHECK: %+v\n", oldCmd) } } runConfig.Healthcheck = c.Health - return d.builder.commit(ctx, d.state, fmt.Sprintf("HEALTHCHECK %q", runConfig.Healthcheck)) + return d.builder.commit(ctx, d.state, fmt.Sprintf("HEALTHCHECK %+v", runConfig.Healthcheck)) } // ENTRYPOINT /usr/sbin/nginx diff --git a/daemon/daemon_test.go b/daemon/daemon_test.go index 84d9c2b2a4..bf48837792 100644 --- a/daemon/daemon_test.go +++ b/daemon/daemon_test.go @@ -288,7 +288,7 @@ func TestMerge(t *testing.T) { } for portSpecs := range configUser.ExposedPorts { if portSpecs.Num() != 0 && portSpecs.Num() != 1111 && portSpecs.Num() != 2222 && portSpecs.Num() != 3333 { - t.Fatalf("Expected %q or %q or %q or %q, found %s", 0, 1111, 2222, 3333, portSpecs) + t.Fatalf("Expected %d or %d or %d or %d, found %d", 0, 1111, 2222, 3333, portSpecs) } } } diff --git a/daemon/internal/streamformatter/streamformatter.go b/daemon/internal/streamformatter/streamformatter.go index 2fbf4b6942..da12745273 100644 --- a/daemon/internal/streamformatter/streamformatter.go +++ b/daemon/internal/streamformatter/streamformatter.go @@ -94,7 +94,7 @@ type progressOutput struct { func (out *progressOutput) WriteProgress(prog progress.Progress) error { var formatted []byte if prog.Message != "" { - formatted = out.sf.formatStatus(prog.ID, prog.Message) + formatted = out.sf.formatStatus(prog.ID, "%s", prog.Message) } else { jsonProgress := jsonstream.Progress{ Current: prog.Current, diff --git a/internal/testutil/daemon/daemon.go b/internal/testutil/daemon/daemon.go index 4effdb485b..0140f3afd1 100644 --- a/internal/testutil/daemon/daemon.go +++ b/internal/testutil/daemon/daemon.go @@ -811,7 +811,7 @@ out2: d.log.Logf("[%s] tried to interrupt daemon for %d times, now try to kill it", d.id, i) break out2 } - d.log.Logf("[%d] attempt #%d/5: daemon is still running with pid %d", i, d.cmd.Process.Pid) + d.log.Logf("[%s] attempt #%d/5: daemon is still running with pid %d", d.id, i, d.cmd.Process.Pid) if err := d.cmd.Process.Signal(os.Interrupt); err != nil { return errors.Wrapf(err, "[%s] attempt #%d/5 could not send signal", d.id, i) }