diff --git a/cli/inspect/inspector.go b/cli/inspect/inspector.go index 0d275c416..b2112ce78 100644 --- a/cli/inspect/inspector.go +++ b/cli/inspect/inspector.go @@ -41,6 +41,9 @@ func NewTemplateInspectorFromString(out io.Writer, tmplStr string) (Inspector, e if tmplStr == "" { return NewIndentedInspector(out), nil } + if strings.Contains(tmplStr, ".Id") { + tmplStr = strings.Replace(tmplStr, ".Id", ".ID", -1) + } tmpl, err := templates.Parse(tmplStr) if err != nil { diff --git a/cli/inspect/inspector_test.go b/cli/inspect/inspector_test.go index 550f21de5..e8d602fa8 100644 --- a/cli/inspect/inspector_test.go +++ b/cli/inspect/inspector_test.go @@ -193,11 +193,20 @@ func TestInspect(t *testing.T) { }, wantOut: "\n", wantErr: false, + }, { + name: "testInspectTemplate{{.Id}}", + args: args{ + references: []string{"reference"}, + tmplStr: "{{.Id}}", + getRef: getRefFunc, + }, + wantOut: "id", + wantErr: false, }, { name: "testInspectTemplateError", args: args{ references: []string{"single reference"}, - tmplStr: "{{.Id}}", + tmplStr: "{{.id}}", getRef: getRefFunc, }, wantOut: "", diff --git a/test/cli_inspect_test.go b/test/cli_inspect_test.go index 7f2feecfd..c7499f8a1 100644 --- a/test/cli_inspect_test.go +++ b/test/cli_inspect_test.go @@ -58,6 +58,10 @@ func (suite *PouchInspectSuite) TestInspectCreateAndStartedFormat(c *check.C) { output = command.PouchRun("inspect", "-f", "{{.ID}}", name).Stdout() c.Assert(output, check.Equals, fmt.Sprintf("%s\n", containerID)) + // inspect Container Id + output = command.PouchRun("inspect", "-f", "{{.Id}}", name).Stdout() + c.Assert(output, check.Equals, fmt.Sprintf("%s\n", containerID)) + // inspect Memory output = command.PouchRun("inspect", "-f", "{{.HostConfig.Memory}}", name).Stdout() c.Assert(output, check.Equals, fmt.Sprintf("%d\n", result[0].HostConfig.Memory))