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 <github@gone.nl>
(cherry picked from commit 0ba14fde41)
Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Sebastiaan van Stijn 2024-06-10 21:07:37 +02:00 committed by Cory Snider
parent abf372a871
commit ac722bb368
20 changed files with 33 additions and 39 deletions

View File

@ -192,7 +192,7 @@ func TestInitializeFromClientHangs(t *testing.T) {
ts.Start() ts.Start()
defer ts.Close() defer ts.Close()
opts := &flags.ClientOptions{Hosts: []string{fmt.Sprintf("unix://%s", socket)}} opts := &flags.ClientOptions{Hosts: []string{"unix://" + socket}}
configFile := &configfile.ConfigFile{} configFile := &configfile.ConfigFile{}
apiClient, err := NewAPIClientFromFlags(opts, configFile) apiClient, err := NewAPIClientFromFlags(opts, configFile)
assert.NilError(t, err) assert.NilError(t, err)

View File

@ -329,7 +329,7 @@ func TestParseHostname(t *testing.T) {
hostnameWithDomain := "--hostname=hostname.domainname" hostnameWithDomain := "--hostname=hostname.domainname"
hostnameWithDomainTld := "--hostname=hostname.domainname.tld" hostnameWithDomainTld := "--hostname=hostname.domainname.tld"
for hostname, expectedHostname := range validHostnames { 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) t.Fatalf("Expected the config to have 'hostname' as %q, got %q", expectedHostname, config.Hostname)
} }
} }

View File

@ -1,7 +1,6 @@
package context package context
import ( import (
"fmt"
"strconv" "strconv"
"strings" "strings"
@ -77,7 +76,7 @@ func validateConfig(config map[string]string, allowedKeys map[string]struct{}) e
var errs []string var errs []string
for k := range config { for k := range config {
if _, ok := allowedKeys[k]; !ok { 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 { if len(errs) == 0 {

View File

@ -459,7 +459,7 @@ func rewriteDockerfileFromForContentTrust(ctx context.Context, dockerfile io.Rea
return nil, nil, err 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{ resolvedTags = append(resolvedTags, &resolvedTag{
digestRef: trustedRef, digestRef: trustedRef,
tagRef: ref, tagRef: ref,

View File

@ -223,7 +223,7 @@ func GetContextFromURL(out io.Writer, remoteURL, dockerfileName string) (io.Read
progressOutput := streamformatter.NewProgressOutput(out) progressOutput := streamformatter.NewProgressOutput(out)
// Pass the response body through a progress reader. // 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) 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 // getWithStatusError does an http.Get() and returns an error if the
// status code is 4xx or 5xx. // status code is 4xx or 5xx.
func getWithStatusError(url string) (resp *http.Response, err error) { 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 return nil, err
} }
if resp.StatusCode < http.StatusBadRequest { if resp.StatusCode < http.StatusBadRequest {

View File

@ -18,7 +18,7 @@ type notFound struct {
} }
func (n notFound) Error() string { 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 { func (n notFound) NotFound() bool {

View File

@ -3,7 +3,6 @@ package command_test
import ( import (
"bytes" "bytes"
"context" "context"
"fmt"
"path/filepath" "path/filepath"
"testing" "testing"
@ -68,7 +67,7 @@ func TestGetDefaultAuthConfig(t *testing.T) {
}, },
{ {
checkCredStore: true, checkCredStore: true,
inputServerAddress: fmt.Sprintf("https://%s", testAuthConfigs[1].ServerAddress), inputServerAddress: "https://" + testAuthConfigs[1].ServerAddress,
expectedAuthConfig: testAuthConfigs[1], expectedAuthConfig: testAuthConfigs[1],
}, },
} }

View File

@ -214,9 +214,9 @@ func (f *taskFormatter) format(ctx context.Context, logCtx logContext) (string,
taskName := fmt.Sprintf("%s.%d", serviceName, task.Slot) taskName := fmt.Sprintf("%s.%d", serviceName, task.Slot)
if !f.opts.noTaskIDs { if !f.opts.noTaskIDs {
if f.opts.noTrunc { if f.opts.noTrunc {
taskName += fmt.Sprintf(".%s", task.ID) taskName += "." + task.ID
} else { } else {
taskName += fmt.Sprintf(".%s", stringid.TruncateID(task.ID)) taskName += "." + stringid.TruncateID(task.ID)
} }
} }

View File

@ -874,7 +874,7 @@ func TestGlobalJobProgressUpdaterLarge(t *testing.T) {
tasks := []swarm.Task{} tasks := []swarm.Task{}
for nodeID := range activeNodes { for nodeID := range activeNodes {
tasks = append(tasks, swarm.Task{ tasks = append(tasks, swarm.Task{
ID: fmt.Sprintf("task%s", nodeID), ID: "task" + nodeID,
NodeID: nodeID, NodeID: nodeID,
DesiredState: swarm.TaskStateComplete, DesiredState: swarm.TaskStateComplete,
Status: swarm.TaskStatus{ Status: swarm.TaskStatus{

View File

@ -58,7 +58,7 @@ func RunRemove(dockerCli command.Cli, opts options.Remove) error {
hasError = removeNetworks(ctx, dockerCli, networks) || hasError hasError = removeNetworks(ctx, dockerCli, networks) || hasError
if 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)
} }
} }

View File

@ -29,7 +29,7 @@ func TestIPNets(t *testing.T) {
f := setUpIPNetFlagSet(&ips) f := setUpIPNetFlagSet(&ips)
vals := []string{"192.168.1.1/24", "10.0.0.1/16", "fd00:0:0:0:0:0:0:2/64"} 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}) err := f.Parse([]string{arg})
if err != nil { if err != nil {
t.Fatal("expected no error; got", err) t.Fatal("expected no error; got", err)
@ -135,7 +135,7 @@ func TestIPNetBadQuoting(t *testing.T) {
var cidrs []net.IPNet var cidrs []net.IPNet
f := setUpIPNetFlagSet(&cidrs) 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", t.Fatalf("flag parsing failed with error: %s\nparsing:\t%#v\nwant:\t\t%s",
err, test.FlagArg, test.Want[i]) err, test.FlagArg, test.Want[i])
} }

View File

@ -99,7 +99,7 @@ func getDescription(err validationError) string {
switch err.parent.Type() { switch err.parent.Type() {
case "invalid_type": case "invalid_type":
if expectedType, ok := err.parent.Details()["expected"].(string); ok { 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: case jsonschemaOneOf, jsonschemaAnyOf:
if err.child == nil { if err.child == nil {

View File

@ -2,7 +2,6 @@ package store
import ( import (
"encoding/json" "encoding/json"
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -162,7 +161,7 @@ func newNotFoundError(ref string) *notFoundError {
} }
func (n *notFoundError) Error() string { func (n *notFoundError) Error() string {
return fmt.Sprintf("No such manifest: %s", n.object) return "No such manifest: " + n.object
} }
// NotFound interface // NotFound interface

View File

@ -1,7 +1,6 @@
package client package client
import ( import (
"fmt"
"net" "net"
"net/http" "net/http"
"time" "time"
@ -126,7 +125,7 @@ type existingTokenHandler struct {
} }
func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, _ map[string]string) error { 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 return nil
} }

View File

@ -329,10 +329,10 @@ func createImage(t *testing.T, repo string, tags ...string) string {
func withNotaryPassphrase(pwd string) func(*icmd.Cmd) { func withNotaryPassphrase(pwd string) func(*icmd.Cmd) {
return func(c *icmd.Cmd) { return func(c *icmd.Cmd) {
c.Env = append(c.Env, []string{ c.Env = append(c.Env, []string{
fmt.Sprintf("NOTARY_ROOT_PASSPHRASE=%s", pwd), "NOTARY_ROOT_PASSPHRASE=" + pwd,
fmt.Sprintf("NOTARY_TARGETS_PASSPHRASE=%s", pwd), "NOTARY_TARGETS_PASSPHRASE=" + pwd,
fmt.Sprintf("NOTARY_SNAPSHOT_PASSPHRASE=%s", pwd), "NOTARY_SNAPSHOT_PASSPHRASE=" + pwd,
fmt.Sprintf("NOTARY_DELEGATION_PASSPHRASE=%s", pwd), "NOTARY_DELEGATION_PASSPHRASE=" + pwd,
}...) }...)
} }
} }

View File

@ -2,7 +2,6 @@ package plugin
import ( import (
"encoding/json" "encoding/json"
"fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -23,7 +22,7 @@ const registryPrefix = "registry:5000"
func TestInstallWithContentTrust(t *testing.T) { func TestInstallWithContentTrust(t *testing.T) {
skip.If(t, environment.SkipPluginTests()) skip.If(t, environment.SkipPluginTests())
pluginName := fmt.Sprintf("%s/plugin-content-trust", registryPrefix) const pluginName = registryPrefix + "/plugin-content-trust"
dir := fixtures.SetupConfigFile(t) dir := fixtures.SetupConfigFile(t)
defer dir.Remove() defer dir.Remove()
@ -50,7 +49,7 @@ func TestInstallWithContentTrust(t *testing.T) {
fixtures.WithNotary, fixtures.WithNotary,
) )
result.Assert(t, icmd.Expected{ result.Assert(t, icmd.Expected{
Out: fmt.Sprintf("Status: Downloaded newer image for %s@sha", pluginName), Out: "Status: Downloaded newer image for " + pluginName + "@sha",
}) })
} }

View File

@ -1,7 +1,6 @@
package trust package trust
import ( import (
"fmt"
"testing" "testing"
"github.com/docker/cli/e2e/internal/fixtures" "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) { func setupTrustedImagesForRevokeRepo(t *testing.T, dir fs.Dir) {
icmd.RunCmd(icmd.Command("docker", "pull", fixtures.AlpineImage)).Assert(t, icmd.Success) 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.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.WithPassphrase("root_password", "repo_password"),
fixtures.WithConfig(dir.Path()), fixtures.WithNotary).Assert(t, icmd.Success) fixtures.WithConfig(dir.Path()), fixtures.WithNotary).Assert(t, icmd.Success)
icmd.RunCmd(icmd.Command("docker", "pull", fixtures.BusyboxImage)).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.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.WithPassphrase("root_password", "repo_password"),
fixtures.WithConfig(dir.Path()), fixtures.WithNotary).Assert(t, icmd.Success) fixtures.WithConfig(dir.Path()), fixtures.WithNotary).Assert(t, icmd.Success)
} }

View File

@ -1,7 +1,6 @@
package trust package trust
import ( import (
"fmt"
"testing" "testing"
"github.com/docker/cli/e2e/internal/fixtures" "github.com/docker/cli/e2e/internal/fixtures"
@ -30,7 +29,7 @@ func TestSignLocalImage(t *testing.T) {
fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithPassphrase("root_password", "repo_password"),
fixtures.WithConfig(dir.Path()), fixtures.WithNotary) fixtures.WithConfig(dir.Path()), fixtures.WithNotary)
result.Assert(t, icmd.Success) 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) { func TestSignWithLocalFlag(t *testing.T) {
@ -44,7 +43,7 @@ func TestSignWithLocalFlag(t *testing.T) {
fixtures.WithPassphrase("root_password", "repo_password"), fixtures.WithPassphrase("root_password", "repo_password"),
fixtures.WithConfig(dir.Path()), fixtures.WithNotary) fixtures.WithConfig(dir.Path()), fixtures.WithNotary)
result.Assert(t, icmd.Success) 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) { 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.WithPassphrase("root_password", "repo_password"),
fixtures.WithConfig(dir.Path()), fixtures.WithNotary) fixtures.WithConfig(dir.Path()), fixtures.WithNotary)
result.Assert(t, icmd.Success) 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.RunCmd(icmd.Command("docker", "pull", fixtures.BusyboxImage)).Assert(t, icmd.Success)
icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, localImage).Assert(t, icmd.Success) icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, localImage).Assert(t, icmd.Success)
} }

View File

@ -18,7 +18,7 @@ type ErrBadKey struct {
} }
func (e ErrBadKey) Error() string { 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) { func parseKeyValueFile(filename string, emptyFn func(string) (string, bool)) ([]string, error) {

View File

@ -21,7 +21,7 @@ func TestParseHost(t *testing.T) {
" ": defaultHost, " ": defaultHost,
"fd://": "fd://", "fd://": "fd://",
"fd://something": "fd://something", "fd://something": "fd://something",
"tcp://host:": fmt.Sprintf("tcp://host:%s", defaultHTTPPort), "tcp://host:": "tcp://host:" + defaultHTTPPort,
"tcp://": defaultTCPHost, "tcp://": defaultTCPHost,
"tcp://:2375": fmt.Sprintf("tcp://%s:%s", defaultHTTPHost, defaultHTTPPort), "tcp://:2375": fmt.Sprintf("tcp://%s:%s", defaultHTTPHost, defaultHTTPPort),
"tcp://:2376": fmt.Sprintf("tcp://%s:%s", defaultHTTPHost, defaultTLSHTTPPort), "tcp://:2376": fmt.Sprintf("tcp://%s:%s", defaultHTTPHost, defaultTLSHTTPPort),