mirror of https://github.com/docker/cli.git
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>
This commit is contained in:
parent
7db922cf9f
commit
0ba14fde41
|
@ -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)
|
||||||
|
|
|
@ -335,7 +335,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -76,7 +75,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 {
|
||||||
|
|
|
@ -458,7 +458,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,
|
||||||
|
|
|
@ -226,7 +226,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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {}
|
func (n notFound) NotFound() {}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package command_test
|
package command_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
|
@ -52,7 +51,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],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,9 +212,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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{
|
||||||
|
|
|
@ -58,7 +58,7 @@ func RunRemove(ctx context.Context, dockerCli command.Cli, opts options.Remove)
|
||||||
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)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -134,7 +134,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])
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -85,7 +84,7 @@ func dockerExporterOTLPEndpoint(cli Cli) (endpoint string, secure bool) {
|
||||||
// needs the scheme to use the correct resolver.
|
// 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.
|
// 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":
|
case "https":
|
||||||
secure = true
|
secure = true
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
|
@ -102,7 +102,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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -125,7 +124,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,10 +337,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,
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/e2e/internal/fixtures"
|
"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, versions.LessThan(environment.DaemonAPIVersion(t), "1.44"))
|
||||||
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("Installed plugin %s", pluginName),
|
Out: "Installed plugin " + pluginName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -59,15 +58,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) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -33,7 +32,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) {
|
||||||
|
@ -50,7 +49,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) {
|
||||||
|
@ -62,7 +61,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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -23,7 +23,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),
|
||||||
|
|
Loading…
Reference in New Issue