mirror of https://github.com/docker/cli.git
Merge pull request #1006 from essamhassan/908_show_secrets_configs_srv_inspect
908 - Adding configs/secrets to service inspect pretty
This commit is contained in:
commit
e9731e9d0f
|
@ -97,6 +97,18 @@ Mounts:
|
|||
ReadOnly = {{ $mount.ReadOnly }}
|
||||
Type = {{ $mount.Type }}
|
||||
{{- end -}}
|
||||
{{- if .Configs}}
|
||||
Configs:
|
||||
{{- range $config := .Configs }}
|
||||
Target: {{$config.File.Name}}
|
||||
Source: {{$config.ConfigName}}
|
||||
{{- end }}{{ end }}
|
||||
{{- if .Secrets }}
|
||||
Secrets:
|
||||
{{- range $secret := .Secrets }}
|
||||
Target: {{$secret.File.Name}}
|
||||
Source: {{$secret.SecretName}}
|
||||
{{- end }}{{ end }}
|
||||
{{- if .HasResources }}
|
||||
Resources:
|
||||
{{- if .HasResourceReservations }}
|
||||
|
@ -200,6 +212,14 @@ func (ctx *serviceInspectContext) Labels() map[string]string {
|
|||
return ctx.Service.Spec.Labels
|
||||
}
|
||||
|
||||
func (ctx *serviceInspectContext) Configs() []*swarm.ConfigReference {
|
||||
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Configs
|
||||
}
|
||||
|
||||
func (ctx *serviceInspectContext) Secrets() []*swarm.SecretReference {
|
||||
return ctx.Service.Spec.TaskTemplate.ContainerSpec.Secrets
|
||||
}
|
||||
|
||||
func (ctx *serviceInspectContext) IsModeGlobal() bool {
|
||||
return ctx.Service.Spec.Mode.Global != nil
|
||||
}
|
||||
|
|
|
@ -44,6 +44,24 @@ func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time)
|
|||
TaskTemplate: swarm.TaskSpec{
|
||||
ContainerSpec: &swarm.ContainerSpec{
|
||||
Image: "foo/bar@sha256:this_is_a_test",
|
||||
Configs: []*swarm.ConfigReference{
|
||||
{
|
||||
ConfigID: "mtc3i44r1awdoziy2iceg73z8",
|
||||
ConfigName: "configtest.conf",
|
||||
File: &swarm.ConfigReferenceFileTarget{
|
||||
Name: "/configtest.conf",
|
||||
},
|
||||
},
|
||||
},
|
||||
Secrets: []*swarm.SecretReference{
|
||||
{
|
||||
SecretID: "3hv39ehbbb4hdozo7spod9ftn",
|
||||
SecretName: "secrettest.conf",
|
||||
File: &swarm.SecretReferenceFileTarget{
|
||||
Name: "/secrettest.conf",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Networks: []swarm.NetworkAttachmentConfig{
|
||||
{
|
||||
|
@ -133,3 +151,10 @@ func TestJSONFormatWithNoUpdateConfig(t *testing.T) {
|
|||
}
|
||||
assert.Check(t, is.DeepEqual(m1, m2))
|
||||
}
|
||||
|
||||
func TestPrettyPrintWithConfigsAndSecrets(t *testing.T) {
|
||||
s := formatServiceInspect(t, formatter.NewServiceFormat("pretty"), time.Now())
|
||||
|
||||
assert.Check(t, is.Contains(s, "Configs:"), "Pretty print missing configs")
|
||||
assert.Check(t, is.Contains(s, "Secrets:"), "Pretty print missing secrets")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue