fix non-constant format string (caught by go1.24)#49201
fix non-constant format string (caught by go1.24)#49201thaJeztah merged 3 commits intomoby:masterfrom
Conversation
caught by go1.24
# github.com/docker/docker/distribution
# github.com/docker/docker/distribution/pull_v2_windows.go:145:35: non-constant format string in call to (*github.com/docker/docker/vendor/github.com/sirupsen/logrus.Entry).Debugf
FAIL github.com/docker/docker/distribution [build failed]
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Also updated some existing ones to use `%v` instead of `%s` for consistency.
caught by go1.24
# github.com/docker/docker/libnetwork/drivers/windows/overlay
# github.com/docker/docker/libnetwork/drivers/windows/overlay/ov_network_windows.go:206:32: non-constant format string in call to github.com/docker/docker/libnetwork/types.ForbiddenErrorf
FAIL github.com/docker/docker/libnetwork/drivers/windows/overlay [build failed]
# github.com/docker/docker/libnetwork/drivers/windows
# github.com/docker/docker/libnetwork/drivers/windows/windows.go:449:33: non-constant format string in call to github.com/docker/docker/libnetwork/types.ForbiddenErrorf
FAIL github.com/docker/docker/libnetwork/drivers/windows [build failed]
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
| @@ -446,7 +446,7 @@ func (d *driver) DeleteNetwork(nid string) error { | |||
| if n.created { | |||
| _, err = hcsshim.HNSNetworkRequest("DELETE", config.HnsID, "") | |||
| if err != nil && err.Error() != errNotFound { | |||
There was a problem hiding this comment.
I just noticed this one, string-matching;
moby/libnetwork/drivers/windows/windows.go
Line 112 in 35cfb6f
For a second I was afraid I broke that one because I recalled I opened a PR in hcsshim to remove some stray whitespace in error messages;
But I think this one's not changed.
Let me have a look though if there's alternative ways to match the error (other than string matching 😬)
There was a problem hiding this comment.
The good news; I didn't break things.
The bad news; depending on which implementation we hit, we may be broken;
Looks like the "lowercase" one was changed in microsoft/hcsshim@7ec8848, which is in hcshim v0.12
Interestingly, it looks like we hit that problem 6 years; integration-cli uses strings.ToLower to work around that;
moby/integration-cli/docker_cli_run_test.go
Lines 3844 to 3848 in 35cfb6f
There was a problem hiding this comment.
OH! I spotted the wrong commit; it's not hcsshim v0.12, but the old one that touched that error; this was the commit microsoft/hcsshim@6d67a30
Not exactly sure why our linters didn't spot this, as it did for Linux; #48359 - perhaps we're missing some
GOOS=windowsin our linter?Ultimately we should also remove these libnetwork-specific errors, and just use errdefs probably.
distribution: fix non-constant format string
caught by go1.24
libnetwork/drivers/windows: fix non-constant format string
Also updated some existing ones to use
%vinstead of%sfor consistency.caught by go1.24
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)