mirror of https://github.com/docker/cli.git
Merge pull request #1732 from sjeandeaux/fix/issue-117
[pretty print] pretty print and healthcheck
This commit is contained in:
commit
fc9ef7087e
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command/inspect"
|
"github.com/docker/cli/cli/command/inspect"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
mounttypes "github.com/docker/docker/api/types/mount"
|
mounttypes "github.com/docker/docker/api/types/mount"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
@ -146,6 +147,18 @@ Ports:
|
||||||
TargetPort = {{ $port.TargetPort }}
|
TargetPort = {{ $port.TargetPort }}
|
||||||
PublishMode = {{ $port.PublishMode }}
|
PublishMode = {{ $port.PublishMode }}
|
||||||
{{- end }} {{ end -}}
|
{{- end }} {{ end -}}
|
||||||
|
{{- if .Healthcheck }}
|
||||||
|
Healthcheck:
|
||||||
|
Interval = {{ .Healthcheck.Interval }}
|
||||||
|
Retries = {{ .Healthcheck.Retries }}
|
||||||
|
StartPeriod = {{ .Healthcheck.StartPeriod }}
|
||||||
|
Timeout = {{ .Healthcheck.Timeout }}
|
||||||
|
{{- if .Healthcheck.Test }}
|
||||||
|
Tests:
|
||||||
|
{{- range $test := .Healthcheck.Test }}
|
||||||
|
Test = {{ $test }}
|
||||||
|
{{- end }} {{ end -}}
|
||||||
|
{{- end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
// NewFormat returns a Format for rendering using a Context
|
// NewFormat returns a Format for rendering using a Context
|
||||||
|
@ -227,6 +240,10 @@ func (ctx *serviceInspectContext) Secrets() []*swarm.SecretReference {
|
||||||
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Secrets
|
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Secrets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *serviceInspectContext) Healthcheck() *container.HealthConfig {
|
||||||
|
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Healthcheck
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) IsModeGlobal() bool {
|
func (ctx *serviceInspectContext) IsModeGlobal() bool {
|
||||||
return ctx.Service.Spec.Mode.Global != nil
|
return ctx.Service.Spec.Mode.Global != nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
is "gotest.tools/assert/cmp"
|
is "gotest.tools/assert/cmp"
|
||||||
|
@ -62,6 +63,14 @@ func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Healthcheck: &container.HealthConfig{
|
||||||
|
Test: []string{"CMD-SHELL", "curl"},
|
||||||
|
Interval: 4,
|
||||||
|
Retries: 3,
|
||||||
|
StartPeriod: 2,
|
||||||
|
Timeout: 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Networks: []swarm.NetworkAttachmentConfig{
|
Networks: []swarm.NetworkAttachmentConfig{
|
||||||
{
|
{
|
||||||
|
@ -157,4 +166,5 @@ func TestPrettyPrintWithConfigsAndSecrets(t *testing.T) {
|
||||||
|
|
||||||
assert.Check(t, is.Contains(s, "Configs:"), "Pretty print missing configs")
|
assert.Check(t, is.Contains(s, "Configs:"), "Pretty print missing configs")
|
||||||
assert.Check(t, is.Contains(s, "Secrets:"), "Pretty print missing secrets")
|
assert.Check(t, is.Contains(s, "Secrets:"), "Pretty print missing secrets")
|
||||||
|
assert.Check(t, is.Contains(s, "Healthcheck:"), "Pretty print missing healthcheck")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue