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 <github@gone.nl>
(cherry picked from commit 4ab70bf61e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-03-27 21:13:03 +02:00
parent e628209d9b
commit 2f7e84be65
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
36 changed files with 62 additions and 93 deletions

View File

@ -19,13 +19,11 @@ func TestConfigContextFormatWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{formatter.Context{Format: NewFormat("table", false)}, {formatter.Context{Format: NewFormat("table", false)},

View File

@ -36,7 +36,7 @@ func TestConfigInspectErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"format": "{{invalid format}}", "format": "{{invalid format}}",
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},

View File

@ -155,7 +155,7 @@ func (cid *cidFile) Close() error {
return nil return nil
} }
if err := os.Remove(cid.path); err != 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 return nil
@ -166,7 +166,7 @@ func (cid *cidFile) Write(id string) error {
return nil return nil
} }
if _, err := cid.file.Write([]byte(id)); err != 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 cid.written = true
return nil return nil
@ -177,12 +177,12 @@ func newCIDFile(path string) (*cidFile, error) {
return &cidFile{}, nil return &cidFile{}, nil
} }
if _, err := os.Stat(path); err == 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) f, err := os.Create(path)
if err != nil { 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 return &cidFile{path: path, file: f}, nil

View File

@ -39,7 +39,7 @@ func TestNewCIDFileWhenFileAlreadyExists(t *testing.T) {
defer tempfile.Remove() defer tempfile.Remove()
_, err := newCIDFile(tempfile.Path()) _, 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) { func TestCIDFileCloseWithNoWrite(t *testing.T) {

View File

@ -54,13 +54,11 @@ func TestContainerStatsContextWrite(t *testing.T) {
}{ }{
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
{ {
formatter.Context{Format: "table {{.MemUsage}}"}, formatter.Context{Format: "table {{.MemUsage}}"},

View File

@ -130,13 +130,11 @@ func TestContainerContextWrite(t *testing.T) {
// Errors // Errors
{ {
Context{Format: "{{InvalidFunction}}"}, Context{Format: "{{InvalidFunction}}"},
`Template parsing error: template: :1: function "InvalidFunction" not defined `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
}, },
{ {
Context{Format: "{{nil}}"}, Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table Format // Table Format
{ {

View File

@ -61,8 +61,7 @@ CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED
Format: "{{InvalidFunction}}", Format: "{{InvalidFunction}}",
}, },
}, },
`Template parsing error: template: :1: function "InvalidFunction" not defined `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
}, },
{ {
DiskUsageContext{ DiskUsageContext{
@ -70,8 +69,7 @@ CACHE ID CACHE TYPE SIZE CREATED LAST USED USAGE SHARED
Format: "{{nil}}", Format: "{{nil}}",
}, },
}, },
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table Format // Table Format
{ {

View File

@ -64,7 +64,7 @@ func (c *Context) preFormat() {
func (c *Context) parseFormat() (*template.Template, error) { func (c *Context) parseFormat() (*template.Template, error) {
tmpl, err := templates.Parse(c.finalFormat) tmpl, err := templates.Parse(c.finalFormat)
if err != nil { if err != nil {
return tmpl, errors.Errorf("Template parsing error: %v\n", err) return tmpl, errors.Wrap(err, "template parsing error")
} }
return tmpl, err 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 { func (c *Context) contextFormat(tmpl *template.Template, subContext SubContext) error {
if err := tmpl.Execute(c.buffer, subContext); err != nil { 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 { if c.Format.IsTable() && c.header != nil {
c.header = subContext.FullHeader() c.header = subContext.FullHeader()

View File

@ -119,8 +119,7 @@ func TestImageContextWrite(t *testing.T) {
Format: "{{InvalidFunction}}", Format: "{{InvalidFunction}}",
}, },
}, },
`Template parsing error: template: :1: function "InvalidFunction" not defined `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
}, },
{ {
ImageContext{ ImageContext{
@ -128,8 +127,7 @@ func TestImageContextWrite(t *testing.T) {
Format: "{{nil}}", Format: "{{nil}}",
}, },
}, },
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table Format // Table Format
{ {

View File

@ -62,13 +62,11 @@ func TestVolumeContextWrite(t *testing.T) {
// Errors // Errors
{ {
Context{Format: "{{InvalidFunction}}"}, Context{Format: "{{InvalidFunction}}"},
`Template parsing error: template: :1: function "InvalidFunction" not defined `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
}, },
{ {
Context{Format: "{{nil}}"}, Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{ {

View File

@ -297,7 +297,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
} }
if err := build.ValidateContextDirectory(contextDir, excludes); err != nil { 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 // And canonicalize dockerfile name to a platform-independent one

View File

@ -44,7 +44,7 @@ func NewTemplateInspectorFromString(out io.Writer, tmplStr string) (Inspector, e
tmpl, err := templates.Parse(tmplStr) tmpl, err := templates.Parse(tmplStr)
if err != nil { 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 return NewTemplateInspector(out, tmpl), nil
} }
@ -94,7 +94,7 @@ func (i *TemplateInspector) Inspect(typedElement interface{}, rawElement []byte)
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)
if err := i.tmpl.Execute(buffer, typedElement); err != nil { if err := i.tmpl.Execute(buffer, typedElement); err != nil {
if rawElement == nil { if rawElement == nil {
return errors.Errorf("Template parsing error: %v", err) return errors.Errorf("template parsing error: %v", err)
} }
return i.tryRawInspectFallback(rawElement) return i.tryRawInspectFallback(rawElement)
} }
@ -118,7 +118,7 @@ func (i *TemplateInspector) tryRawInspectFallback(rawElement []byte) error {
tmplMissingKey := i.tmpl.Option("missingkey=error") tmplMissingKey := i.tmpl.Option("missingkey=error")
if rawErr := tmplMissingKey.Execute(buffer, raw); rawErr != nil { 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()) i.buffer.Write(buffer.Bytes())

View File

@ -62,7 +62,7 @@ func TestTemplateInspectorTemplateError(t *testing.T) {
t.Fatal("Expected error got nil") 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) t.Fatalf("Expected template error, got %v", err)
} }
} }
@ -98,7 +98,7 @@ func TestTemplateInspectorRawFallbackError(t *testing.T) {
t.Fatal("Expected error got nil") 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) t.Fatalf("Expected template error, got %v", err)
} }
} }

View File

@ -79,13 +79,11 @@ func TestNetworkContextWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{ {

View File

@ -62,15 +62,13 @@ func TestNodeContextWrite(t *testing.T) {
// Errors // Errors
{ {
context: formatter.Context{Format: "{{InvalidFunction}}"}, context: formatter.Context{Format: "{{InvalidFunction}}"},
expected: `Template parsing error: template: :1: function "InvalidFunction" not defined expected: `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}}, clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}},
}, },
{ {
context: formatter.Context{Format: "{{nil}}"}, context: formatter.Context{Format: "{{nil}}"},
expected: `Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command expected: `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}}, clusterInfo: swarm.ClusterInfo{TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}},
}, },
// Table format // Table format

View File

@ -59,13 +59,11 @@ func TestPluginContextWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{ {

View File

@ -61,7 +61,7 @@ func TestInspectErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"format": "{{invalid format}}", "format": "{{invalid format}}",
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
} }

View File

@ -41,7 +41,7 @@ func TestListErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"format": "{{invalid format}}", "format": "{{invalid format}}",
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
} }

View File

@ -112,13 +112,11 @@ func TestSearchContextWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{ {

View File

@ -19,13 +19,11 @@ func TestSecretContextFormatWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{formatter.Context{Format: NewFormat("table", false)}, {formatter.Context{Format: NewFormat("table", false)},

View File

@ -36,7 +36,7 @@ func TestSecretInspectErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"format": "{{invalid format}}", "format": "{{invalid format}}",
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},

View File

@ -29,13 +29,11 @@ func TestServiceContextWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{ {

View File

@ -16,13 +16,11 @@ func TestStackContextWrite(t *testing.T) {
// Errors // Errors
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table format // Table format
{ {

View File

@ -33,7 +33,7 @@ func TestListErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"format": "{{invalid format}}", "format": "{{invalid format}}",
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
{ {
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {

View File

@ -28,6 +28,7 @@ func LoadComposefile(dockerCli command.Cli, opts options.Deploy) (*composetypes.
config, err := loader.Load(configDetails) config, err := loader.Load(configDetails)
if err != nil { if err != nil {
if fpe, ok := err.(*loader.ForbiddenPropertiesError); ok { 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", return nil, errors.Errorf("Compose file contains unsupported options:\n\n%s\n",
propertyWarnings(fpe.Properties)) propertyWarnings(fpe.Properties))
} }

View File

@ -62,7 +62,7 @@ func TestStackServicesErrors(t *testing.T) {
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*Service()}, nil return []swarm.Service{*Service()}, nil
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
} }

View File

@ -506,7 +506,7 @@ func formatInfo(dockerCli command.Cli, info info, format string) error {
tmpl, err := templates.Parse(format) tmpl, err := templates.Parse(format)
if err != nil { if err != nil {
return cli.StatusError{StatusCode: 64, return cli.StatusError{StatusCode: 64,
Status: "Template parsing error: " + err.Error()} Status: "template parsing error: " + err.Error()}
} }
err = tmpl.Execute(dockerCli.Out(), info) err = tmpl.Execute(dockerCli.Out(), info)
dockerCli.Out().Write([]byte{'\n'}) dockerCli.Out().Write([]byte{'\n'})

View File

@ -394,7 +394,7 @@ func TestFormatInfo(t *testing.T) {
{ {
doc: "syntax", doc: "syntax",
template: "{{}", 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", doc: "syntax",

View File

@ -235,7 +235,7 @@ func newVersionTemplate(templateFormat string) (*template.Template, error) {
tmpl := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder}) tmpl := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder})
tmpl, err := tmpl.Parse(templateFormat) 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 { func getDetailsOrder(v types.ComponentVersion) []string {

View File

@ -20,13 +20,11 @@ func TestTaskContextWrite(t *testing.T) {
}{ }{
{ {
formatter.Context{Format: "{{InvalidFunction}}"}, 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}}"}, formatter.Context{Format: "{{nil}}"},
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
{ {
formatter.Context{Format: NewTaskFormat("table", true)}, formatter.Context{Format: NewTaskFormat("table", true)},

View File

@ -95,15 +95,13 @@ func TestTrustTagContextWrite(t *testing.T) {
formatter.Context{ formatter.Context{
Format: "{{InvalidFunction}}", Format: "{{InvalidFunction}}",
}, },
`Template parsing error: template: :1: function "InvalidFunction" not defined `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
}, },
{ {
formatter.Context{ formatter.Context{
Format: "{{nil}}", Format: "{{nil}}",
}, },
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table Format // Table Format
{ {
@ -191,15 +189,13 @@ func TestSignerInfoContextWrite(t *testing.T) {
formatter.Context{ formatter.Context{
Format: "{{InvalidFunction}}", Format: "{{InvalidFunction}}",
}, },
`Template parsing error: template: :1: function "InvalidFunction" not defined `template parsing error: template: :1: function "InvalidFunction" not defined`,
`,
}, },
{ {
formatter.Context{ formatter.Context{
Format: "{{nil}}", Format: "{{nil}}",
}, },
`Template parsing error: template: :1:2: executing "" at <nil>: nil is not a command `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
`,
}, },
// Table Format // Table Format
{ {

View File

@ -32,7 +32,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 1 { if len(args) == 1 {
if options.name != "" { 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] options.name = args[0]
} }

View File

@ -26,7 +26,7 @@ func TestVolumeCreateErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"name": "volumeName", "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"}, args: []string{"too", "many"},

View File

@ -35,7 +35,7 @@ func TestVolumeInspectErrors(t *testing.T) {
flags: map[string]string{ flags: map[string]string{
"format": "{{invalid format}}", "format": "{{invalid format}}",
}, },
expectedError: "Template parsing error", expectedError: "template parsing error",
}, },
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},

View File

@ -99,7 +99,7 @@ func newPathError(path Path, err error) error {
return nil return nil
case *template.InvalidTemplateError: case *template.InvalidTemplateError:
return errors.Errorf( 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) path, err.Template)
default: default:
return errors.Wrapf(err, "error while interpolating %s", path) return errors.Wrapf(err, "error while interpolating %s", path)

View File

@ -58,7 +58,7 @@ func TestInvalidInterpolation(t *testing.T) {
}, },
} }
_, err := Interpolate(services, Options{LookupValue: defaultMapping}) _, 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) { func TestInterpolateWithDefaults(t *testing.T) {