mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Remove duplicate keys in labels of docker info
This fix tries to address the issue raised in 24392 where labels with duplicate keys exist in `docker info`, which contradicts with the specifications in the docs. The reason for duplicate keys is that labels are stored as slice of strings in the format of `A=B` (and the input/output). This fix tries to address this issue by checking conflict labels when daemon started, and remove duplicate labels (K-V). The existing `/info` API has not been changed. An additional integration test has been added to cover the changes in this fix. This fix fixes 24392. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -219,3 +219,15 @@ func (s *DockerDaemonSuite) TestRegistryMirrors(c *check.C) {
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" %s", registryMirror1))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" %s", registryMirror2))
|
||||
}
|
||||
|
||||
// Test case for #24392
|
||||
func (s *DockerDaemonSuite) TestInfoLabels(c *check.C) {
|
||||
testRequires(c, SameHostDaemon, DaemonIsLinux)
|
||||
|
||||
err := s.d.Start("--label", `test.empty=`, "--label", `test.empty=`, "--label", `test.label="1"`, "--label", `test.label="2"`)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, err := s.d.Cmd("info")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, "WARNING: labels with duplicate keys and conflicting values have been deprecated")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user