diff --git a/cli/command/service/formatter.go b/cli/command/service/formatter.go index 311355618d..08a8360f64 100644 --- a/cli/command/service/formatter.go +++ b/cli/command/service/formatter.go @@ -123,6 +123,17 @@ Secrets: Target: {{$secret.File.Name}} Source: {{$secret.SecretName}} {{- 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 }} Resources: {{- if .HasResourceReservations }} @@ -238,6 +249,21 @@ func (ctx *serviceInspectContext) Labels() map[string]string { 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 { return ctx.Service.Spec.TaskTemplate.ContainerSpec.Configs } diff --git a/cli/command/service/inspect_test.go b/cli/command/service/inspect_test.go index fe662ba397..327b79bf6f 100644 --- a/cli/command/service/inspect_test.go +++ b/cli/command/service/inspect_test.go @@ -43,6 +43,12 @@ func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time) Labels: map[string]string{"com.label": "foo"}, }, TaskTemplate: swarm.TaskSpec{ + LogDriver: &swarm.Driver{ + Name: "driver", + Options: map[string]string{ + "max-file": "5", + }, + }, ContainerSpec: &swarm.ContainerSpec{ Image: "foo/bar@sha256:this_is_a_test", Configs: []*swarm.ConfigReference{ @@ -163,7 +169,7 @@ func TestJSONFormatWithNoUpdateConfig(t *testing.T) { func TestPrettyPrintWithConfigsAndSecrets(t *testing.T) { 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, "Secrets:"), "Pretty print missing secrets") assert.Check(t, is.Contains(s, "Healthcheck:"), "Pretty print missing healthcheck")