mirror of https://github.com/docker/cli.git
Add log-driver and options to service inspect "pretty" format
Signed-off-by: Rahul Zoldyck <rahulzoldyck@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c6d10b6da0
commit
139af1f6d6
|
@ -123,6 +123,17 @@ Secrets:
|
||||||
Target: {{$secret.File.Name}}
|
Target: {{$secret.File.Name}}
|
||||||
Source: {{$secret.SecretName}}
|
Source: {{$secret.SecretName}}
|
||||||
{{- end }}{{ end }}
|
{{- end }}{{ end }}
|
||||||
|
{{- if .HasLogDriver }}
|
||||||
|
Log Driver:
|
||||||
|
{{- if .HasLogDriverName }}
|
||||||
|
Name: {{ .LogDriverName }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .LogOpts }}
|
||||||
|
LogOpts:
|
||||||
|
{{- range $k, $v := .LogOpts }}
|
||||||
|
{{ $k }}{{if $v }}: {{ $v }}{{ end }}
|
||||||
|
{{- end }}{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{- if .HasResources }}
|
{{- if .HasResources }}
|
||||||
Resources:
|
Resources:
|
||||||
{{- if .HasResourceReservations }}
|
{{- if .HasResourceReservations }}
|
||||||
|
@ -238,6 +249,21 @@ func (ctx *serviceInspectContext) Labels() map[string]string {
|
||||||
return ctx.Service.Spec.Labels
|
return ctx.Service.Spec.Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *serviceInspectContext) HasLogDriver() bool {
|
||||||
|
return ctx.Service.Spec.TaskTemplate.LogDriver != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *serviceInspectContext) HasLogDriverName() bool {
|
||||||
|
return ctx.Service.Spec.TaskTemplate.LogDriver.Name != ""
|
||||||
|
}
|
||||||
|
func (ctx *serviceInspectContext) LogDriverName() string {
|
||||||
|
return ctx.Service.Spec.TaskTemplate.LogDriver.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *serviceInspectContext) LogOpts() map[string]string {
|
||||||
|
return ctx.Service.Spec.TaskTemplate.LogDriver.Options
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) Configs() []*swarm.ConfigReference {
|
func (ctx *serviceInspectContext) Configs() []*swarm.ConfigReference {
|
||||||
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Configs
|
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Configs
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,12 @@ func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time)
|
||||||
Labels: map[string]string{"com.label": "foo"},
|
Labels: map[string]string{"com.label": "foo"},
|
||||||
},
|
},
|
||||||
TaskTemplate: swarm.TaskSpec{
|
TaskTemplate: swarm.TaskSpec{
|
||||||
|
LogDriver: &swarm.Driver{
|
||||||
|
Name: "driver",
|
||||||
|
Options: map[string]string{
|
||||||
|
"max-file": "5",
|
||||||
|
},
|
||||||
|
},
|
||||||
ContainerSpec: &swarm.ContainerSpec{
|
ContainerSpec: &swarm.ContainerSpec{
|
||||||
Image: "foo/bar@sha256:this_is_a_test",
|
Image: "foo/bar@sha256:this_is_a_test",
|
||||||
Configs: []*swarm.ConfigReference{
|
Configs: []*swarm.ConfigReference{
|
||||||
|
@ -163,7 +169,7 @@ func TestJSONFormatWithNoUpdateConfig(t *testing.T) {
|
||||||
|
|
||||||
func TestPrettyPrintWithConfigsAndSecrets(t *testing.T) {
|
func TestPrettyPrintWithConfigsAndSecrets(t *testing.T) {
|
||||||
s := formatServiceInspect(t, NewFormat("pretty"), time.Now())
|
s := formatServiceInspect(t, NewFormat("pretty"), time.Now())
|
||||||
|
assert.Check(t, is.Contains(s, "Log Driver:"), "Pretty print missing Log Driver")
|
||||||
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")
|
assert.Check(t, is.Contains(s, "Healthcheck:"), "Pretty print missing healthcheck")
|
||||||
|
|
Loading…
Reference in New Issue