From ac722bb368fad48c4882b86945624268b27b1abe Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 10 Jun 2024 21:07:37 +0200 Subject: [PATCH] linting: fmt.Sprintf can be replaced with string concatenation (perfsprint) cli/registry/client/endpoint.go:128:34: fmt.Sprintf can be replaced with string concatenation (perfsprint) req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token)) ^ cli/command/telemetry_docker.go:88:14: fmt.Sprintf can be replaced with string concatenation (perfsprint) endpoint = fmt.Sprintf("unix://%s", path.Join(u.Host, u.Path)) ^ cli/command/cli_test.go:195:47: fmt.Sprintf can be replaced with string concatenation (perfsprint) opts := &flags.ClientOptions{Hosts: []string{fmt.Sprintf("unix://%s", socket)}} ^ cli/command/registry_test.go:59:24: fmt.Sprintf can be replaced with string concatenation (perfsprint) inputServerAddress: fmt.Sprintf("https://%s", testAuthConfigs[1].ServerAddress), ^ cli/command/container/opts_test.go:338:35: fmt.Sprintf can be replaced with string concatenation (perfsprint) if config, _, _ := mustParse(t, fmt.Sprintf("--hostname=%s", hostname)); config.Hostname != expectedHostname { ^ cli/command/context/options.go:79:24: fmt.Sprintf can be replaced with string concatenation (perfsprint) errs = append(errs, fmt.Sprintf("%s: unrecognized config key", k)) ^ cli/command/image/build.go:461:68: fmt.Sprintf can be replaced with string concatenation (perfsprint) line = dockerfileFromLinePattern.ReplaceAllLiteralString(line, fmt.Sprintf("FROM %s", reference.FamiliarString(trustedRef))) ^ cli/command/image/remove_test.go:21:9: fmt.Sprintf can be replaced with string concatenation (perfsprint) return fmt.Sprintf("Error: No such image: %s", n.imageID) ^ cli/command/image/build/context.go:229:102: fmt.Sprintf can be replaced with string concatenation (perfsprint) progReader := progress.NewProgressReader(response.Body, progressOutput, response.ContentLength, "", fmt.Sprintf("Downloading build context from remote url: %s", remoteURL)) ^ cli/command/service/logs.go:215:16: fmt.Sprintf can be replaced with string concatenation (perfsprint) taskName += fmt.Sprintf(".%s", task.ID) ^ cli/command/service/logs.go:217:16: fmt.Sprintf can be replaced with string concatenation (perfsprint) taskName += fmt.Sprintf(".%s", stringid.TruncateID(task.ID)) ^ cli/command/service/progress/progress_test.go:877:18: fmt.Sprintf can be replaced with string concatenation (perfsprint) ID: fmt.Sprintf("task%s", nodeID), ^ cli/command/stack/swarm/remove.go:61:24: fmt.Sprintf can be replaced with string concatenation (perfsprint) errs = append(errs, fmt.Sprintf("Failed to remove some resources from stack: %s", namespace)) ^ cli/command/swarm/ipnet_slice_test.go:32:9: fmt.Sprintf can be replaced with string concatenation (perfsprint) arg := fmt.Sprintf("--cidrs=%s", strings.Join(vals, ",")) ^ cli/command/swarm/ipnet_slice_test.go:137:30: fmt.Sprintf can be replaced with string concatenation (perfsprint) if err := f.Parse([]string{fmt.Sprintf("--cidrs=%s", strings.Join(test.FlagArg, ","))}); err != nil { ^ cli/compose/schema/schema.go:105:11: fmt.Sprintf can be replaced with string concatenation (perfsprint) return fmt.Sprintf("must be a %s", humanReadableType(expectedType)) ^ cli/manifest/store/store.go:165:9: fmt.Sprintf can be replaced with string concatenation (perfsprint) return fmt.Sprintf("No such manifest: %s", n.object) ^ e2e/image/push_test.go:340:4: fmt.Sprintf can be replaced with string concatenation (perfsprint) fmt.Sprintf("NOTARY_ROOT_PASSPHRASE=%s", pwd), ^ e2e/image/push_test.go:341:4: fmt.Sprintf can be replaced with string concatenation (perfsprint) fmt.Sprintf("NOTARY_TARGETS_PASSPHRASE=%s", pwd), ^ e2e/image/push_test.go:342:4: fmt.Sprintf can be replaced with string concatenation (perfsprint) fmt.Sprintf("NOTARY_SNAPSHOT_PASSPHRASE=%s", pwd), ^ e2e/image/push_test.go:343:4: fmt.Sprintf can be replaced with string concatenation (perfsprint) fmt.Sprintf("NOTARY_DELEGATION_PASSPHRASE=%s", pwd), ^ e2e/plugin/trust_test.go:23:16: fmt.Sprintf can be replaced with string concatenation (perfsprint) pluginName := fmt.Sprintf("%s/plugin-content-trust", registryPrefix) ^ e2e/plugin/trust_test.go:53:8: fmt.Sprintf can be replaced with string concatenation (perfsprint) Out: fmt.Sprintf("Installed plugin %s", pluginName), ^ e2e/trust/revoke_test.go:62:57: fmt.Sprintf can be replaced with string concatenation (perfsprint) icmd.RunCommand("docker", "tag", fixtures.AlpineImage, fmt.Sprintf("%s:v1", revokeRepo)).Assert(t, icmd.Success) ^ e2e/trust/revoke_test.go:64:49: fmt.Sprintf can be replaced with string concatenation (perfsprint) icmd.Command("docker", "-D", "trust", "sign", fmt.Sprintf("%s:v1", revokeRepo)), ^ e2e/trust/revoke_test.go:68:58: fmt.Sprintf can be replaced with string concatenation (perfsprint) icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, fmt.Sprintf("%s:v2", revokeRepo)).Assert(t, icmd.Success) ^ e2e/trust/revoke_test.go:70:49: fmt.Sprintf can be replaced with string concatenation (perfsprint) icmd.Command("docker", "-D", "trust", "sign", fmt.Sprintf("%s:v2", revokeRepo)), ^ e2e/trust/sign_test.go:36:47: fmt.Sprintf can be replaced with string concatenation (perfsprint) assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.AlpineSha))) ^ e2e/trust/sign_test.go:53:47: fmt.Sprintf can be replaced with string concatenation (perfsprint) assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.BusyboxSha))) ^ e2e/trust/sign_test.go:65:47: fmt.Sprintf can be replaced with string concatenation (perfsprint) assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.AlpineSha))) ^ opts/file.go:21:9: fmt.Sprintf can be replaced with string concatenation (perfsprint) return fmt.Sprintf("poorly formatted environment: %s", e.msg) ^ opts/hosts_test.go:26:31: fmt.Sprintf can be replaced with string concatenation (perfsprint) "tcp://host:": fmt.Sprintf("tcp://host:%s", defaultHTTPPort), ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 0ba14fde41f4308f1d9fa73d03fb28bbb1650325) Signed-off-by: Cory Snider --- cli/command/cli_test.go | 2 +- cli/command/container/opts_test.go | 2 +- cli/command/context/options.go | 3 +-- cli/command/image/build.go | 2 +- cli/command/image/build/context.go | 5 +++-- cli/command/image/remove_test.go | 2 +- cli/command/registry_test.go | 3 +-- cli/command/service/logs.go | 4 ++-- cli/command/service/progress/progress_test.go | 2 +- cli/command/stack/swarm/remove.go | 2 +- cli/command/swarm/ipnet_slice_test.go | 4 ++-- cli/compose/schema/schema.go | 2 +- cli/manifest/store/store.go | 3 +-- cli/registry/client/endpoint.go | 3 +-- e2e/image/push_test.go | 8 ++++---- e2e/plugin/trust_test.go | 5 ++--- e2e/trust/revoke_test.go | 9 ++++----- e2e/trust/sign_test.go | 7 +++---- opts/file.go | 2 +- opts/hosts_test.go | 2 +- 20 files changed, 33 insertions(+), 39 deletions(-) diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index 7a0b4e727e..13fb5d7904 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -192,7 +192,7 @@ func TestInitializeFromClientHangs(t *testing.T) { ts.Start() defer ts.Close() - opts := &flags.ClientOptions{Hosts: []string{fmt.Sprintf("unix://%s", socket)}} + opts := &flags.ClientOptions{Hosts: []string{"unix://" + socket}} configFile := &configfile.ConfigFile{} apiClient, err := NewAPIClientFromFlags(opts, configFile) assert.NilError(t, err) diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index 6421f80a70..17fa075d29 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -329,7 +329,7 @@ func TestParseHostname(t *testing.T) { hostnameWithDomain := "--hostname=hostname.domainname" hostnameWithDomainTld := "--hostname=hostname.domainname.tld" for hostname, expectedHostname := range validHostnames { - if config, _ := mustParse(t, fmt.Sprintf("--hostname=%s", hostname)); config.Hostname != expectedHostname { + if config, _ := mustParse(t, "--hostname="+hostname); config.Hostname != expectedHostname { t.Fatalf("Expected the config to have 'hostname' as %q, got %q", expectedHostname, config.Hostname) } } diff --git a/cli/command/context/options.go b/cli/command/context/options.go index 39707fe3e9..80ddf3d6e9 100644 --- a/cli/command/context/options.go +++ b/cli/command/context/options.go @@ -1,7 +1,6 @@ package context import ( - "fmt" "strconv" "strings" @@ -77,7 +76,7 @@ func validateConfig(config map[string]string, allowedKeys map[string]struct{}) e var errs []string for k := range config { if _, ok := allowedKeys[k]; !ok { - errs = append(errs, fmt.Sprintf("%s: unrecognized config key", k)) + errs = append(errs, "unrecognized config key: "+k) } } if len(errs) == 0 { diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 771f61ec66..cad1195319 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -459,7 +459,7 @@ func rewriteDockerfileFromForContentTrust(ctx context.Context, dockerfile io.Rea return nil, nil, err } - line = dockerfileFromLinePattern.ReplaceAllLiteralString(line, fmt.Sprintf("FROM %s", reference.FamiliarString(trustedRef))) + line = dockerfileFromLinePattern.ReplaceAllLiteralString(line, "FROM "+reference.FamiliarString(trustedRef)) resolvedTags = append(resolvedTags, &resolvedTag{ digestRef: trustedRef, tagRef: ref, diff --git a/cli/command/image/build/context.go b/cli/command/image/build/context.go index 141344a407..7131372f5f 100644 --- a/cli/command/image/build/context.go +++ b/cli/command/image/build/context.go @@ -223,7 +223,7 @@ func GetContextFromURL(out io.Writer, remoteURL, dockerfileName string) (io.Read progressOutput := streamformatter.NewProgressOutput(out) // Pass the response body through a progress reader. - progReader := progress.NewProgressReader(response.Body, progressOutput, response.ContentLength, "", fmt.Sprintf("Downloading build context from remote url: %s", remoteURL)) + progReader := progress.NewProgressReader(response.Body, progressOutput, response.ContentLength, "", "Downloading build context from remote url: "+remoteURL) return GetContextFromReader(ioutils.NewReadCloserWrapper(progReader, func() error { return response.Body.Close() }), dockerfileName) } @@ -231,7 +231,8 @@ func GetContextFromURL(out io.Writer, remoteURL, dockerfileName string) (io.Read // getWithStatusError does an http.Get() and returns an error if the // status code is 4xx or 5xx. func getWithStatusError(url string) (resp *http.Response, err error) { - if resp, err = http.Get(url); err != nil { //nolint:gosec // Ignore G107: Potential HTTP request made with variable url + // #nosec G107 -- Ignore G107: Potential HTTP request made with variable url + if resp, err = http.Get(url); err != nil { return nil, err } if resp.StatusCode < http.StatusBadRequest { diff --git a/cli/command/image/remove_test.go b/cli/command/image/remove_test.go index 55de3eb6a6..7a45b614ef 100644 --- a/cli/command/image/remove_test.go +++ b/cli/command/image/remove_test.go @@ -18,7 +18,7 @@ type notFound struct { } func (n notFound) Error() string { - return fmt.Sprintf("Error: No such image: %s", n.imageID) + return "Error: No such image: " + n.imageID } func (n notFound) NotFound() bool { diff --git a/cli/command/registry_test.go b/cli/command/registry_test.go index 78117941c3..9ebe105f83 100644 --- a/cli/command/registry_test.go +++ b/cli/command/registry_test.go @@ -3,7 +3,6 @@ package command_test import ( "bytes" "context" - "fmt" "path/filepath" "testing" @@ -68,7 +67,7 @@ func TestGetDefaultAuthConfig(t *testing.T) { }, { checkCredStore: true, - inputServerAddress: fmt.Sprintf("https://%s", testAuthConfigs[1].ServerAddress), + inputServerAddress: "https://" + testAuthConfigs[1].ServerAddress, expectedAuthConfig: testAuthConfigs[1], }, } diff --git a/cli/command/service/logs.go b/cli/command/service/logs.go index 215bad74d9..90252bf0ed 100644 --- a/cli/command/service/logs.go +++ b/cli/command/service/logs.go @@ -214,9 +214,9 @@ func (f *taskFormatter) format(ctx context.Context, logCtx logContext) (string, taskName := fmt.Sprintf("%s.%d", serviceName, task.Slot) if !f.opts.noTaskIDs { if f.opts.noTrunc { - taskName += fmt.Sprintf(".%s", task.ID) + taskName += "." + task.ID } else { - taskName += fmt.Sprintf(".%s", stringid.TruncateID(task.ID)) + taskName += "." + stringid.TruncateID(task.ID) } } diff --git a/cli/command/service/progress/progress_test.go b/cli/command/service/progress/progress_test.go index 64cbde99cb..2edad317f4 100644 --- a/cli/command/service/progress/progress_test.go +++ b/cli/command/service/progress/progress_test.go @@ -874,7 +874,7 @@ func TestGlobalJobProgressUpdaterLarge(t *testing.T) { tasks := []swarm.Task{} for nodeID := range activeNodes { tasks = append(tasks, swarm.Task{ - ID: fmt.Sprintf("task%s", nodeID), + ID: "task" + nodeID, NodeID: nodeID, DesiredState: swarm.TaskStateComplete, Status: swarm.TaskStatus{ diff --git a/cli/command/stack/swarm/remove.go b/cli/command/stack/swarm/remove.go index 4dedef12f3..8fa1eaa272 100644 --- a/cli/command/stack/swarm/remove.go +++ b/cli/command/stack/swarm/remove.go @@ -58,7 +58,7 @@ func RunRemove(dockerCli command.Cli, opts options.Remove) error { hasError = removeNetworks(ctx, dockerCli, networks) || hasError if hasError { - errs = append(errs, fmt.Sprintf("Failed to remove some resources from stack: %s", namespace)) + errs = append(errs, "Failed to remove some resources from stack: "+namespace) } } diff --git a/cli/command/swarm/ipnet_slice_test.go b/cli/command/swarm/ipnet_slice_test.go index 3f28466ea1..ef12ebba65 100644 --- a/cli/command/swarm/ipnet_slice_test.go +++ b/cli/command/swarm/ipnet_slice_test.go @@ -29,7 +29,7 @@ func TestIPNets(t *testing.T) { f := setUpIPNetFlagSet(&ips) vals := []string{"192.168.1.1/24", "10.0.0.1/16", "fd00:0:0:0:0:0:0:2/64"} - arg := fmt.Sprintf("--cidrs=%s", strings.Join(vals, ",")) + arg := "--cidrs=" + strings.Join(vals, ",") err := f.Parse([]string{arg}) if err != nil { t.Fatal("expected no error; got", err) @@ -135,7 +135,7 @@ func TestIPNetBadQuoting(t *testing.T) { var cidrs []net.IPNet f := setUpIPNetFlagSet(&cidrs) - if err := f.Parse([]string{fmt.Sprintf("--cidrs=%s", strings.Join(test.FlagArg, ","))}); err != nil { + if err := f.Parse([]string{"--cidrs=" + strings.Join(test.FlagArg, ",")}); err != nil { t.Fatalf("flag parsing failed with error: %s\nparsing:\t%#v\nwant:\t\t%s", err, test.FlagArg, test.Want[i]) } diff --git a/cli/compose/schema/schema.go b/cli/compose/schema/schema.go index c7786f48fb..291b8ba0ff 100644 --- a/cli/compose/schema/schema.go +++ b/cli/compose/schema/schema.go @@ -99,7 +99,7 @@ func getDescription(err validationError) string { switch err.parent.Type() { case "invalid_type": if expectedType, ok := err.parent.Details()["expected"].(string); ok { - return fmt.Sprintf("must be a %s", humanReadableType(expectedType)) + return "must be a " + humanReadableType(expectedType) } case jsonschemaOneOf, jsonschemaAnyOf: if err.child == nil { diff --git a/cli/manifest/store/store.go b/cli/manifest/store/store.go index 39e576f6b2..7a69644927 100644 --- a/cli/manifest/store/store.go +++ b/cli/manifest/store/store.go @@ -2,7 +2,6 @@ package store import ( "encoding/json" - "fmt" "os" "path/filepath" "strings" @@ -162,7 +161,7 @@ func newNotFoundError(ref string) *notFoundError { } func (n *notFoundError) Error() string { - return fmt.Sprintf("No such manifest: %s", n.object) + return "No such manifest: " + n.object } // NotFound interface diff --git a/cli/registry/client/endpoint.go b/cli/registry/client/endpoint.go index ebb7192bd2..47dea00ed4 100644 --- a/cli/registry/client/endpoint.go +++ b/cli/registry/client/endpoint.go @@ -1,7 +1,6 @@ package client import ( - "fmt" "net" "net/http" "time" @@ -126,7 +125,7 @@ type existingTokenHandler struct { } func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, _ map[string]string) error { - req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token)) + req.Header.Set("Authorization", "Bearer "+th.token) return nil } diff --git a/e2e/image/push_test.go b/e2e/image/push_test.go index 9695c99aa8..79f9fde018 100644 --- a/e2e/image/push_test.go +++ b/e2e/image/push_test.go @@ -329,10 +329,10 @@ func createImage(t *testing.T, repo string, tags ...string) string { func withNotaryPassphrase(pwd string) func(*icmd.Cmd) { return func(c *icmd.Cmd) { c.Env = append(c.Env, []string{ - fmt.Sprintf("NOTARY_ROOT_PASSPHRASE=%s", pwd), - fmt.Sprintf("NOTARY_TARGETS_PASSPHRASE=%s", pwd), - fmt.Sprintf("NOTARY_SNAPSHOT_PASSPHRASE=%s", pwd), - fmt.Sprintf("NOTARY_DELEGATION_PASSPHRASE=%s", pwd), + "NOTARY_ROOT_PASSPHRASE=" + pwd, + "NOTARY_TARGETS_PASSPHRASE=" + pwd, + "NOTARY_SNAPSHOT_PASSPHRASE=" + pwd, + "NOTARY_DELEGATION_PASSPHRASE=" + pwd, }...) } } diff --git a/e2e/plugin/trust_test.go b/e2e/plugin/trust_test.go index b89bdfb99a..08c580a9aa 100644 --- a/e2e/plugin/trust_test.go +++ b/e2e/plugin/trust_test.go @@ -2,7 +2,6 @@ package plugin import ( "encoding/json" - "fmt" "os" "os/exec" "path/filepath" @@ -23,7 +22,7 @@ const registryPrefix = "registry:5000" func TestInstallWithContentTrust(t *testing.T) { skip.If(t, environment.SkipPluginTests()) - pluginName := fmt.Sprintf("%s/plugin-content-trust", registryPrefix) + const pluginName = registryPrefix + "/plugin-content-trust" dir := fixtures.SetupConfigFile(t) defer dir.Remove() @@ -50,7 +49,7 @@ func TestInstallWithContentTrust(t *testing.T) { fixtures.WithNotary, ) result.Assert(t, icmd.Expected{ - Out: fmt.Sprintf("Status: Downloaded newer image for %s@sha", pluginName), + Out: "Status: Downloaded newer image for " + pluginName + "@sha", }) } diff --git a/e2e/trust/revoke_test.go b/e2e/trust/revoke_test.go index fe0f44de04..e206329bc2 100644 --- a/e2e/trust/revoke_test.go +++ b/e2e/trust/revoke_test.go @@ -1,7 +1,6 @@ package trust import ( - "fmt" "testing" "github.com/docker/cli/e2e/internal/fixtures" @@ -57,15 +56,15 @@ func setupTrustedImagesForRevoke(t *testing.T, dir fs.Dir) { func setupTrustedImagesForRevokeRepo(t *testing.T, dir fs.Dir) { icmd.RunCmd(icmd.Command("docker", "pull", fixtures.AlpineImage)).Assert(t, icmd.Success) - icmd.RunCommand("docker", "tag", fixtures.AlpineImage, fmt.Sprintf("%s:v1", revokeRepo)).Assert(t, icmd.Success) + icmd.RunCommand("docker", "tag", fixtures.AlpineImage, revokeRepo+":v1").Assert(t, icmd.Success) icmd.RunCmd( - icmd.Command("docker", "-D", "trust", "sign", fmt.Sprintf("%s:v1", revokeRepo)), + icmd.Command("docker", "-D", "trust", "sign", revokeRepo+":v1"), fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithConfig(dir.Path()), fixtures.WithNotary).Assert(t, icmd.Success) icmd.RunCmd(icmd.Command("docker", "pull", fixtures.BusyboxImage)).Assert(t, icmd.Success) - icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, fmt.Sprintf("%s:v2", revokeRepo)).Assert(t, icmd.Success) + icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, revokeRepo+":v2").Assert(t, icmd.Success) icmd.RunCmd( - icmd.Command("docker", "-D", "trust", "sign", fmt.Sprintf("%s:v2", revokeRepo)), + icmd.Command("docker", "-D", "trust", "sign", revokeRepo+":v2"), fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithConfig(dir.Path()), fixtures.WithNotary).Assert(t, icmd.Success) } diff --git a/e2e/trust/sign_test.go b/e2e/trust/sign_test.go index 9f953b4adb..c75fa3baf2 100644 --- a/e2e/trust/sign_test.go +++ b/e2e/trust/sign_test.go @@ -1,7 +1,6 @@ package trust import ( - "fmt" "testing" "github.com/docker/cli/e2e/internal/fixtures" @@ -30,7 +29,7 @@ func TestSignLocalImage(t *testing.T) { fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithConfig(dir.Path()), fixtures.WithNotary) result.Assert(t, icmd.Success) - assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.AlpineSha))) + assert.Check(t, is.Contains(result.Stdout(), "v1: digest: sha256:"+fixtures.AlpineSha)) } func TestSignWithLocalFlag(t *testing.T) { @@ -44,7 +43,7 @@ func TestSignWithLocalFlag(t *testing.T) { fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithConfig(dir.Path()), fixtures.WithNotary) result.Assert(t, icmd.Success) - assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.BusyboxSha))) + assert.Check(t, is.Contains(result.Stdout(), "v1: digest: sha256:"+fixtures.BusyboxSha)) } func setupTrustedImageForOverwrite(t *testing.T, dir fs.Dir) { @@ -55,7 +54,7 @@ func setupTrustedImageForOverwrite(t *testing.T, dir fs.Dir) { fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithConfig(dir.Path()), fixtures.WithNotary) result.Assert(t, icmd.Success) - assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.AlpineSha))) + assert.Check(t, is.Contains(result.Stdout(), "v1: digest: sha256:"+fixtures.AlpineSha)) icmd.RunCmd(icmd.Command("docker", "pull", fixtures.BusyboxImage)).Assert(t, icmd.Success) icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, localImage).Assert(t, icmd.Success) } diff --git a/opts/file.go b/opts/file.go index 72b90e117f..5cdd8e1386 100644 --- a/opts/file.go +++ b/opts/file.go @@ -18,7 +18,7 @@ type ErrBadKey struct { } func (e ErrBadKey) Error() string { - return fmt.Sprintf("poorly formatted environment: %s", e.msg) + return "poorly formatted environment: " + e.msg } func parseKeyValueFile(filename string, emptyFn func(string) (string, bool)) ([]string, error) { diff --git a/opts/hosts_test.go b/opts/hosts_test.go index 9d38d164be..8030a2e699 100644 --- a/opts/hosts_test.go +++ b/opts/hosts_test.go @@ -21,7 +21,7 @@ func TestParseHost(t *testing.T) { " ": defaultHost, "fd://": "fd://", "fd://something": "fd://something", - "tcp://host:": fmt.Sprintf("tcp://host:%s", defaultHTTPPort), + "tcp://host:": "tcp://host:" + defaultHTTPPort, "tcp://": defaultTCPHost, "tcp://:2375": fmt.Sprintf("tcp://%s:%s", defaultHTTPHost, defaultHTTPPort), "tcp://:2376": fmt.Sprintf("tcp://%s:%s", defaultHTTPHost, defaultTLSHTTPPort),