From 0ba14fde41f4308f1d9fa73d03fb28bbb1650325 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 --- 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 | 4 ++-- 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/command/telemetry_docker.go | 3 +-- 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 +- 21 files changed, 33 insertions(+), 41 deletions(-) diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index d0456cddc5..2f9cb89c4a 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 28c109e6fb..e03c26530e 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -335,7 +335,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 ce79d57a4f..7b39f7d768 100644 --- a/cli/command/context/options.go +++ b/cli/command/context/options.go @@ -1,7 +1,6 @@ package context import ( - "fmt" "strconv" "strings" @@ -76,7 +75,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 61a5ed4dbb..f19ac389bd 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -458,7 +458,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 6a5a50a1b4..a1082e0d52 100644 --- a/cli/command/image/build/context.go +++ b/cli/command/image/build/context.go @@ -226,7 +226,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) } @@ -234,7 +234,7 @@ 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) { - //#nosec G107 -- 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 } diff --git a/cli/command/image/remove_test.go b/cli/command/image/remove_test.go index 9220a5a16b..b1035da924 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() {} diff --git a/cli/command/registry_test.go b/cli/command/registry_test.go index 6f3efa4b28..65acd069e2 100644 --- a/cli/command/registry_test.go +++ b/cli/command/registry_test.go @@ -1,7 +1,6 @@ package command_test import ( - "fmt" "testing" "github.com/docker/cli/cli/command" @@ -52,7 +51,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 e31f992fb4..b9f964aec9 100644 --- a/cli/command/service/logs.go +++ b/cli/command/service/logs.go @@ -212,9 +212,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 19ba07a9e8..7e5ed2643b 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 6ccd0b1ad2..cde317fe0a 100644 --- a/cli/command/stack/swarm/remove.go +++ b/cli/command/stack/swarm/remove.go @@ -58,7 +58,7 @@ func RunRemove(ctx context.Context, dockerCli command.Cli, opts options.Remove) 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) continue } diff --git a/cli/command/swarm/ipnet_slice_test.go b/cli/command/swarm/ipnet_slice_test.go index 04f07430fd..675881f91e 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) @@ -134,7 +134,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/command/telemetry_docker.go b/cli/command/telemetry_docker.go index 5dc72e2bb5..281ca9131b 100644 --- a/cli/command/telemetry_docker.go +++ b/cli/command/telemetry_docker.go @@ -5,7 +5,6 @@ package command import ( "context" - "fmt" "net/url" "os" "path" @@ -85,7 +84,7 @@ func dockerExporterOTLPEndpoint(cli Cli) (endpoint string, secure bool) { // needs the scheme to use the correct resolver. // // We'll just handle this in a special way and add the unix:// back to the endpoint. - endpoint = fmt.Sprintf("unix://%s", path.Join(u.Host, u.Path)) + endpoint = "unix://" + path.Join(u.Host, u.Path) case "https": secure = true fallthrough diff --git a/cli/compose/schema/schema.go b/cli/compose/schema/schema.go index 6d11f5d817..aa8dd19bd9 100644 --- a/cli/compose/schema/schema.go +++ b/cli/compose/schema/schema.go @@ -102,7 +102,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 dbf7730632..c4f8219cec 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 1bf0b78eae..e06bfea50b 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" @@ -125,7 +124,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 4069692197..3ee86c5351 100644 --- a/e2e/image/push_test.go +++ b/e2e/image/push_test.go @@ -337,10 +337,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 b32bfaf5b0..1abf5f8c4c 100644 --- a/e2e/plugin/trust_test.go +++ b/e2e/plugin/trust_test.go @@ -2,7 +2,6 @@ package plugin import ( "context" - "fmt" "testing" "github.com/docker/cli/e2e/internal/fixtures" @@ -20,7 +19,7 @@ func TestInstallWithContentTrust(t *testing.T) { skip.If(t, versions.LessThan(environment.DaemonAPIVersion(t), "1.44")) 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("Installed plugin %s", pluginName), + Out: "Installed plugin " + pluginName, }) } diff --git a/e2e/trust/revoke_test.go b/e2e/trust/revoke_test.go index b903ece562..8ee5dc4ad9 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" @@ -59,15 +58,15 @@ func setupTrustedImagesForRevoke(t *testing.T, dir fs.Dir) { func setupTrustedImagesForRevokeRepo(t *testing.T, dir fs.Dir) { t.Helper() 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 81a09f78df..44bb007826 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" @@ -33,7 +32,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) { @@ -50,7 +49,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) { @@ -62,7 +61,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 326d975564..f33c915f03 100644 --- a/opts/hosts_test.go +++ b/opts/hosts_test.go @@ -23,7 +23,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),