Browse code

Add security info to `docker info`

The security infomation has already been added to `GET /info` in #21172.
However, it is not part of the output of `docker info` yet.

This fix adds the security information to `docker info`.

Additional tests has been added to cover changes.

This fix fixes #23500. This fix is related to #20909, #21172.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
(cherry picked from commit eee20b564ffae0b8c8043115c959f0f9d1869fed)

Yong Tang authored on 2016/06/14 23:43:25
Showing 3 changed files
... ...
@@ -94,6 +94,10 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
94 94
 		fmt.Fprintf(cli.out, "Default Runtime: %s\n", info.DefaultRuntime)
95 95
 	}
96 96
 
97
+	fmt.Fprintf(cli.out, "Security Options:")
98
+	ioutils.FprintfIfNotEmpty(cli.out, " %s", strings.Join(info.SecurityOptions, " "))
99
+	fmt.Fprintf(cli.out, "\n")
100
+
97 101
 	ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
98 102
 	ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
99 103
 	ioutils.FprintfIfNotEmpty(cli.out, "OSType: %s\n", info.OSType)
... ...
@@ -32,6 +32,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
32 32
 		"Storage Driver:",
33 33
 		"Volume:",
34 34
 		"Network:",
35
+		"Security Options:",
35 36
 	}
36 37
 
37 38
 	if DaemonIsLinux.Condition() {
38 39
new file mode 100644
... ...
@@ -0,0 +1,15 @@
0
+// +build !windows
1
+
2
+package main
3
+
4
+import (
5
+	"github.com/docker/docker/pkg/integration/checker"
6
+	"github.com/go-check/check"
7
+)
8
+
9
+func (s *DockerSuite) TestInfoSecurityOptions(c *check.C) {
10
+	testRequires(c, SameHostDaemon, seccompEnabled, Apparmor, DaemonIsLinux)
11
+
12
+	out, _ := dockerCmd(c, "info")
13
+	c.Assert(out, checker.Contains, "Security Options: apparmor seccomp")
14
+}