From 2f7e84be654546ff3e01860c8140457b53afa578 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 27 Mar 2022 21:13:03 +0200 Subject: [PATCH] linting: fix incorrectly formatted errors (revive) cli/compose/interpolation/interpolation.go:102:4: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) "invalid interpolation format for %s: %#v. You may need to escape any $ with another $.", ^ cli/command/stack/loader/loader.go:30:30: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) return nil, errors.Errorf("Compose file contains unsupported options:\n\n%s\n", ^ cli/command/formatter/formatter.go:76:30: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) return tmpl, errors.Errorf("Template parsing error: %v\n", err) ^ cli/command/formatter/formatter.go:97:24: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) return errors.Errorf("Template parsing error: %v\n", err) ^ cli/command/image/build.go:257:25: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) return errors.Errorf("error checking context: '%s'.", err) ^ cli/command/volume/create.go:35:27: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) return errors.Errorf("Conflicting options: either specify --name or provide positional arg, not both\n") ^ cli/command/container/create.go:160:24: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) return errors.Errorf("failed to remove the CID file '%s': %s \n", cid.path, err) ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 4ab70bf61e87271ca56511172352296a202ced41) Signed-off-by: Sebastiaan van Stijn --- cli/command/config/formatter_test.go | 6 ++---- cli/command/config/inspect_test.go | 2 +- cli/command/container/create.go | 8 ++++---- cli/command/container/create_test.go | 2 +- cli/command/container/formatter_stats_test.go | 6 ++---- cli/command/formatter/container_test.go | 6 ++---- cli/command/formatter/disk_usage_test.go | 6 ++---- cli/command/formatter/formatter.go | 4 ++-- cli/command/formatter/image_test.go | 6 ++---- cli/command/formatter/volume_test.go | 6 ++---- cli/command/image/build.go | 2 +- cli/command/inspect/inspector.go | 6 +++--- cli/command/inspect/inspector_test.go | 4 ++-- cli/command/network/formatter_test.go | 6 ++---- cli/command/node/formatter_test.go | 10 ++++------ cli/command/plugin/formatter_test.go | 6 ++---- cli/command/plugin/inspect_test.go | 2 +- cli/command/plugin/list_test.go | 2 +- cli/command/registry/formatter_search_test.go | 6 ++---- cli/command/secret/formatter_test.go | 6 ++---- cli/command/secret/inspect_test.go | 2 +- cli/command/service/formatter_test.go | 6 ++---- cli/command/stack/formatter/formatter_test.go | 6 ++---- cli/command/stack/list_test.go | 2 +- cli/command/stack/loader/loader.go | 1 + cli/command/stack/services_test.go | 2 +- cli/command/system/info.go | 2 +- cli/command/system/info_test.go | 2 +- cli/command/system/version.go | 2 +- cli/command/task/formatter_test.go | 6 ++---- cli/command/trust/formatter_test.go | 12 ++++-------- cli/command/volume/create.go | 2 +- cli/command/volume/create_test.go | 2 +- cli/command/volume/inspect_test.go | 2 +- cli/compose/interpolation/interpolation.go | 2 +- cli/compose/interpolation/interpolation_test.go | 2 +- 36 files changed, 62 insertions(+), 93 deletions(-) diff --git a/cli/command/config/formatter_test.go b/cli/command/config/formatter_test.go index 143aaa1686..c6ebcb4f25 100644 --- a/cli/command/config/formatter_test.go +++ b/cli/command/config/formatter_test.go @@ -19,13 +19,11 @@ func TestConfigContextFormatWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format {formatter.Context{Format: NewFormat("table", false)}, diff --git a/cli/command/config/inspect_test.go b/cli/command/config/inspect_test.go index 6ac3a442ec..eeb6391f38 100644 --- a/cli/command/config/inspect_test.go +++ b/cli/command/config/inspect_test.go @@ -36,7 +36,7 @@ func TestConfigInspectErrors(t *testing.T) { flags: map[string]string{ "format": "{{invalid format}}", }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, { args: []string{"foo", "bar"}, diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 743878be18..036c03d464 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -155,7 +155,7 @@ func (cid *cidFile) Close() error { return nil } if err := os.Remove(cid.path); err != nil { - return errors.Errorf("failed to remove the CID file '%s': %s \n", cid.path, err) + return errors.Wrapf(err, "failed to remove the CID file '%s'", cid.path) } return nil @@ -166,7 +166,7 @@ func (cid *cidFile) Write(id string) error { return nil } if _, err := cid.file.Write([]byte(id)); err != nil { - return errors.Errorf("Failed to write the container ID to the file: %s", err) + return errors.Wrap(err, "failed to write the container ID to the file") } cid.written = true return nil @@ -177,12 +177,12 @@ func newCIDFile(path string) (*cidFile, error) { return &cidFile{}, nil } if _, err := os.Stat(path); err == nil { - return nil, errors.Errorf("Container ID file found, make sure the other container isn't running or delete %s", path) + return nil, errors.Errorf("container ID file found, make sure the other container isn't running or delete %s", path) } f, err := os.Create(path) if err != nil { - return nil, errors.Errorf("Failed to create the container ID file: %s", err) + return nil, errors.Wrap(err, "failed to create the container ID file") } return &cidFile{path: path, file: f}, nil diff --git a/cli/command/container/create_test.go b/cli/command/container/create_test.go index 54a83ce75d..19c3de366a 100644 --- a/cli/command/container/create_test.go +++ b/cli/command/container/create_test.go @@ -39,7 +39,7 @@ func TestNewCIDFileWhenFileAlreadyExists(t *testing.T) { defer tempfile.Remove() _, err := newCIDFile(tempfile.Path()) - assert.ErrorContains(t, err, "Container ID file found") + assert.ErrorContains(t, err, "container ID file found") } func TestCIDFileCloseWithNoWrite(t *testing.T) { diff --git a/cli/command/container/formatter_stats_test.go b/cli/command/container/formatter_stats_test.go index d0be1606ca..844679654b 100644 --- a/cli/command/container/formatter_stats_test.go +++ b/cli/command/container/formatter_stats_test.go @@ -54,13 +54,11 @@ func TestContainerStatsContextWrite(t *testing.T) { }{ { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, { formatter.Context{Format: "table {{.MemUsage}}"}, diff --git a/cli/command/formatter/container_test.go b/cli/command/formatter/container_test.go index 051c71589d..42dc0a3cda 100644 --- a/cli/command/formatter/container_test.go +++ b/cli/command/formatter/container_test.go @@ -130,13 +130,11 @@ func TestContainerContextWrite(t *testing.T) { // Errors { Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table Format { diff --git a/cli/command/formatter/disk_usage_test.go b/cli/command/formatter/disk_usage_test.go index 40ca19ec8d..7fff4b2147 100644 --- a/cli/command/formatter/disk_usage_test.go +++ b/cli/command/formatter/disk_usage_test.go @@ -61,8 +61,7 @@ CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED Format: "{{InvalidFunction}}", }, }, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { DiskUsageContext{ @@ -70,8 +69,7 @@ CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED Format: "{{nil}}", }, }, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table Format { diff --git a/cli/command/formatter/formatter.go b/cli/command/formatter/formatter.go index 10ada78f93..a100d828b6 100644 --- a/cli/command/formatter/formatter.go +++ b/cli/command/formatter/formatter.go @@ -64,7 +64,7 @@ func (c *Context) preFormat() { func (c *Context) parseFormat() (*template.Template, error) { tmpl, err := templates.Parse(c.finalFormat) if err != nil { - return tmpl, errors.Errorf("Template parsing error: %v\n", err) + return tmpl, errors.Wrap(err, "template parsing error") } return tmpl, err } @@ -85,7 +85,7 @@ func (c *Context) postFormat(tmpl *template.Template, subContext SubContext) { func (c *Context) contextFormat(tmpl *template.Template, subContext SubContext) error { if err := tmpl.Execute(c.buffer, subContext); err != nil { - return errors.Errorf("Template parsing error: %v\n", err) + return errors.Wrap(err, "template parsing error") } if c.Format.IsTable() && c.header != nil { c.header = subContext.FullHeader() diff --git a/cli/command/formatter/image_test.go b/cli/command/formatter/image_test.go index b4b039d2da..ab336b4a39 100644 --- a/cli/command/formatter/image_test.go +++ b/cli/command/formatter/image_test.go @@ -119,8 +119,7 @@ func TestImageContextWrite(t *testing.T) { Format: "{{InvalidFunction}}", }, }, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { ImageContext{ @@ -128,8 +127,7 @@ func TestImageContextWrite(t *testing.T) { Format: "{{nil}}", }, }, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table Format { diff --git a/cli/command/formatter/volume_test.go b/cli/command/formatter/volume_test.go index 75a8f10d39..b34dc74676 100644 --- a/cli/command/formatter/volume_test.go +++ b/cli/command/formatter/volume_test.go @@ -62,13 +62,11 @@ func TestVolumeContextWrite(t *testing.T) { // Errors { Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format { diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 64b51113c0..2d6144442e 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -297,7 +297,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error { } if err := build.ValidateContextDirectory(contextDir, excludes); err != nil { - return errors.Errorf("error checking context: '%s'.", err) + return errors.Wrap(err, "error checking context") } // And canonicalize dockerfile name to a platform-independent one diff --git a/cli/command/inspect/inspector.go b/cli/command/inspect/inspector.go index aef31e62df..63d285f2d7 100644 --- a/cli/command/inspect/inspector.go +++ b/cli/command/inspect/inspector.go @@ -44,7 +44,7 @@ func NewTemplateInspectorFromString(out io.Writer, tmplStr string) (Inspector, e tmpl, err := templates.Parse(tmplStr) if err != nil { - return nil, errors.Errorf("Template parsing error: %s", err) + return nil, errors.Errorf("template parsing error: %s", err) } return NewTemplateInspector(out, tmpl), nil } @@ -94,7 +94,7 @@ func (i *TemplateInspector) Inspect(typedElement interface{}, rawElement []byte) buffer := new(bytes.Buffer) if err := i.tmpl.Execute(buffer, typedElement); err != nil { if rawElement == nil { - return errors.Errorf("Template parsing error: %v", err) + return errors.Errorf("template parsing error: %v", err) } return i.tryRawInspectFallback(rawElement) } @@ -118,7 +118,7 @@ func (i *TemplateInspector) tryRawInspectFallback(rawElement []byte) error { tmplMissingKey := i.tmpl.Option("missingkey=error") if rawErr := tmplMissingKey.Execute(buffer, raw); rawErr != nil { - return errors.Errorf("Template parsing error: %v", rawErr) + return errors.Errorf("template parsing error: %v", rawErr) } i.buffer.Write(buffer.Bytes()) diff --git a/cli/command/inspect/inspector_test.go b/cli/command/inspect/inspector_test.go index 702df3d8cc..52537dba3a 100644 --- a/cli/command/inspect/inspector_test.go +++ b/cli/command/inspect/inspector_test.go @@ -62,7 +62,7 @@ func TestTemplateInspectorTemplateError(t *testing.T) { t.Fatal("Expected error got nil") } - if !strings.HasPrefix(err.Error(), "Template parsing error") { + if !strings.HasPrefix(err.Error(), "template parsing error") { t.Fatalf("Expected template error, got %v", err) } } @@ -98,7 +98,7 @@ func TestTemplateInspectorRawFallbackError(t *testing.T) { t.Fatal("Expected error got nil") } - if !strings.HasPrefix(err.Error(), "Template parsing error") { + if !strings.HasPrefix(err.Error(), "template parsing error") { t.Fatalf("Expected template error, got %v", err) } } diff --git a/cli/command/network/formatter_test.go b/cli/command/network/formatter_test.go index 02ae981670..3cadbecbcf 100644 --- a/cli/command/network/formatter_test.go +++ b/cli/command/network/formatter_test.go @@ -79,13 +79,11 @@ func TestNetworkContextWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format { diff --git a/cli/command/node/formatter_test.go b/cli/command/node/formatter_test.go index 87b65a14f2..442359f671 100644 --- a/cli/command/node/formatter_test.go +++ b/cli/command/node/formatter_test.go @@ -62,15 +62,13 @@ func TestNodeContextWrite(t *testing.T) { // Errors { - context: formatter.Context{Format: "{{InvalidFunction}}"}, - expected: `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + context: formatter.Context{Format: "{{InvalidFunction}}"}, + expected: `template parsing error: template: :1: function "InvalidFunction" not defined`, clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}}, }, { - context: formatter.Context{Format: "{{nil}}"}, - expected: `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + context: formatter.Context{Format: "{{nil}}"}, + expected: `template parsing error: template: :1:2: executing "" at : nil is not a command`, clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}}, }, // Table format diff --git a/cli/command/plugin/formatter_test.go b/cli/command/plugin/formatter_test.go index 26eeca7be9..b2e991287d 100644 --- a/cli/command/plugin/formatter_test.go +++ b/cli/command/plugin/formatter_test.go @@ -59,13 +59,11 @@ func TestPluginContextWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format { diff --git a/cli/command/plugin/inspect_test.go b/cli/command/plugin/inspect_test.go index a112cd42a6..66454b462f 100644 --- a/cli/command/plugin/inspect_test.go +++ b/cli/command/plugin/inspect_test.go @@ -61,7 +61,7 @@ func TestInspectErrors(t *testing.T) { flags: map[string]string{ "format": "{{invalid format}}", }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, } diff --git a/cli/command/plugin/list_test.go b/cli/command/plugin/list_test.go index fe9bd9762a..b51565969b 100644 --- a/cli/command/plugin/list_test.go +++ b/cli/command/plugin/list_test.go @@ -41,7 +41,7 @@ func TestListErrors(t *testing.T) { flags: map[string]string{ "format": "{{invalid format}}", }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, } diff --git a/cli/command/registry/formatter_search_test.go b/cli/command/registry/formatter_search_test.go index 0255321118..8c72408cf3 100644 --- a/cli/command/registry/formatter_search_test.go +++ b/cli/command/registry/formatter_search_test.go @@ -112,13 +112,11 @@ func TestSearchContextWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format { diff --git a/cli/command/secret/formatter_test.go b/cli/command/secret/formatter_test.go index a5e3aac874..e87d013e1b 100644 --- a/cli/command/secret/formatter_test.go +++ b/cli/command/secret/formatter_test.go @@ -19,13 +19,11 @@ func TestSecretContextFormatWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format {formatter.Context{Format: NewFormat("table", false)}, diff --git a/cli/command/secret/inspect_test.go b/cli/command/secret/inspect_test.go index d4eda421df..170adf4c86 100644 --- a/cli/command/secret/inspect_test.go +++ b/cli/command/secret/inspect_test.go @@ -36,7 +36,7 @@ func TestSecretInspectErrors(t *testing.T) { flags: map[string]string{ "format": "{{invalid format}}", }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, { args: []string{"foo", "bar"}, diff --git a/cli/command/service/formatter_test.go b/cli/command/service/formatter_test.go index 74e1a3677b..c15c9e4d96 100644 --- a/cli/command/service/formatter_test.go +++ b/cli/command/service/formatter_test.go @@ -29,13 +29,11 @@ func TestServiceContextWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format { diff --git a/cli/command/stack/formatter/formatter_test.go b/cli/command/stack/formatter/formatter_test.go index dd25bca7d2..a2711dece9 100644 --- a/cli/command/stack/formatter/formatter_test.go +++ b/cli/command/stack/formatter/formatter_test.go @@ -16,13 +16,11 @@ func TestStackContextWrite(t *testing.T) { // Errors { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table format { diff --git a/cli/command/stack/list_test.go b/cli/command/stack/list_test.go index a6983cc3a6..e9c653329a 100644 --- a/cli/command/stack/list_test.go +++ b/cli/command/stack/list_test.go @@ -33,7 +33,7 @@ func TestListErrors(t *testing.T) { flags: map[string]string{ "format": "{{invalid format}}", }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, { serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { diff --git a/cli/command/stack/loader/loader.go b/cli/command/stack/loader/loader.go index c4333965fa..0874d6bf6b 100644 --- a/cli/command/stack/loader/loader.go +++ b/cli/command/stack/loader/loader.go @@ -28,6 +28,7 @@ func LoadComposefile(dockerCli command.Cli, opts options.Deploy) (*composetypes. config, err := loader.Load(configDetails) if err != nil { if fpe, ok := err.(*loader.ForbiddenPropertiesError); ok { + //nolint:revive // ignore capitalization error; this error is intentionally formatted multi-line return nil, errors.Errorf("Compose file contains unsupported options:\n\n%s\n", propertyWarnings(fpe.Properties)) } diff --git a/cli/command/stack/services_test.go b/cli/command/stack/services_test.go index ef190d2290..1962dd245f 100644 --- a/cli/command/stack/services_test.go +++ b/cli/command/stack/services_test.go @@ -62,7 +62,7 @@ func TestStackServicesErrors(t *testing.T) { serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { return []swarm.Service{*Service()}, nil }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, } diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 6c4dc01d9c..1095462a1d 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -506,7 +506,7 @@ func formatInfo(dockerCli command.Cli, info info, format string) error { tmpl, err := templates.Parse(format) if err != nil { return cli.StatusError{StatusCode: 64, - Status: "Template parsing error: " + err.Error()} + Status: "template parsing error: " + err.Error()} } err = tmpl.Execute(dockerCli.Out(), info) dockerCli.Out().Write([]byte{'\n'}) diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index d3762ea783..7c683f4449 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -394,7 +394,7 @@ func TestFormatInfo(t *testing.T) { { doc: "syntax", template: "{{}", - expectedError: `Status: Template parsing error: template: :1: unexpected "}" in command, Code: 64`, + expectedError: `Status: template parsing error: template: :1: unexpected "}" in command, Code: 64`, }, { doc: "syntax", diff --git a/cli/command/system/version.go b/cli/command/system/version.go index 418ce651c0..6e3cee271f 100644 --- a/cli/command/system/version.go +++ b/cli/command/system/version.go @@ -235,7 +235,7 @@ func newVersionTemplate(templateFormat string) (*template.Template, error) { tmpl := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder}) tmpl, err := tmpl.Parse(templateFormat) - return tmpl, errors.Wrap(err, "Template parsing error") + return tmpl, errors.Wrap(err, "template parsing error") } func getDetailsOrder(v types.ComponentVersion) []string { diff --git a/cli/command/task/formatter_test.go b/cli/command/task/formatter_test.go index 2dfdb98587..4a7ed7fb2f 100644 --- a/cli/command/task/formatter_test.go +++ b/cli/command/task/formatter_test.go @@ -20,13 +20,11 @@ func TestTaskContextWrite(t *testing.T) { }{ { formatter.Context{Format: "{{InvalidFunction}}"}, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{Format: "{{nil}}"}, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, { formatter.Context{Format: NewTaskFormat("table", true)}, diff --git a/cli/command/trust/formatter_test.go b/cli/command/trust/formatter_test.go index d3863b034d..c8a507cf9f 100644 --- a/cli/command/trust/formatter_test.go +++ b/cli/command/trust/formatter_test.go @@ -95,15 +95,13 @@ func TestTrustTagContextWrite(t *testing.T) { formatter.Context{ Format: "{{InvalidFunction}}", }, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{ Format: "{{nil}}", }, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table Format { @@ -191,15 +189,13 @@ func TestSignerInfoContextWrite(t *testing.T) { formatter.Context{ Format: "{{InvalidFunction}}", }, - `Template parsing error: template: :1: function "InvalidFunction" not defined -`, + `template parsing error: template: :1: function "InvalidFunction" not defined`, }, { formatter.Context{ Format: "{{nil}}", }, - `Template parsing error: template: :1:2: executing "" at : nil is not a command -`, + `template parsing error: template: :1:2: executing "" at : nil is not a command`, }, // Table Format { diff --git a/cli/command/volume/create.go b/cli/command/volume/create.go index 125da44332..180cea6928 100644 --- a/cli/command/volume/create.go +++ b/cli/command/volume/create.go @@ -32,7 +32,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 1 { if options.name != "" { - return errors.Errorf("Conflicting options: either specify --name or provide positional arg, not both\n") + return errors.Errorf("conflicting options: either specify --name or provide positional arg, not both") } options.name = args[0] } diff --git a/cli/command/volume/create_test.go b/cli/command/volume/create_test.go index 0b1562a75f..e9eaa58179 100644 --- a/cli/command/volume/create_test.go +++ b/cli/command/volume/create_test.go @@ -26,7 +26,7 @@ func TestVolumeCreateErrors(t *testing.T) { flags: map[string]string{ "name": "volumeName", }, - expectedError: "Conflicting options: either specify --name or provide positional arg, not both", + expectedError: "conflicting options: either specify --name or provide positional arg, not both", }, { args: []string{"too", "many"}, diff --git a/cli/command/volume/inspect_test.go b/cli/command/volume/inspect_test.go index 563e92202e..49907202bc 100644 --- a/cli/command/volume/inspect_test.go +++ b/cli/command/volume/inspect_test.go @@ -35,7 +35,7 @@ func TestVolumeInspectErrors(t *testing.T) { flags: map[string]string{ "format": "{{invalid format}}", }, - expectedError: "Template parsing error", + expectedError: "template parsing error", }, { args: []string{"foo", "bar"}, diff --git a/cli/compose/interpolation/interpolation.go b/cli/compose/interpolation/interpolation.go index fd34ca82ea..e84756dba6 100644 --- a/cli/compose/interpolation/interpolation.go +++ b/cli/compose/interpolation/interpolation.go @@ -99,7 +99,7 @@ func newPathError(path Path, err error) error { return nil case *template.InvalidTemplateError: return errors.Errorf( - "invalid interpolation format for %s: %#v. You may need to escape any $ with another $.", + "invalid interpolation format for %s: %#v; you may need to escape any $ with another $", path, err.Template) default: return errors.Wrapf(err, "error while interpolating %s", path) diff --git a/cli/compose/interpolation/interpolation_test.go b/cli/compose/interpolation/interpolation_test.go index 55800b1b26..536da0013b 100644 --- a/cli/compose/interpolation/interpolation_test.go +++ b/cli/compose/interpolation/interpolation_test.go @@ -58,7 +58,7 @@ func TestInvalidInterpolation(t *testing.T) { }, } _, err := Interpolate(services, Options{LookupValue: defaultMapping}) - assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $.`) + assert.Error(t, err, `invalid interpolation format for servicea.image: "${"; you may need to escape any $ with another $`) } func TestInterpolateWithDefaults(t *testing.T) {