metadata: avoid printing large chunks of configuration json to the console

If the configuration .json has contents like:

{
  "etc": {
    "ssl": {
      "certs": {
        "ca-certificates.crt": {
          "perm": "0644",
          "content": "large amount of certificate text"
        }
      }
    }
  },
...
}

then we print a warning because the node "ssl" has no "perm".
Previously the warning would include the contents of "ssl", which
would be large (and in theory could include secret information).

This patch modifies the warning print to only print the key and
not the value.

Without this patch, I see on the console:

2017/07/20 10:03:04 CDROM: Probe succeeded
2017/07/20 10:03:04 No permission provided ssl:map[certs:map[ca-certificates.crt:map[perm:0644 content:large amount of certificate text]]]
 - 000-metadata

With this patch, I see on the console:

2017/07/20 09:54:18 CDROM: Probe succeeded
2017/07/20 09:54:18 No permission provided ssl
 - 000-metadata

Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
David Scott 2017-07-20 10:54:43 +01:00
parent de11ea12ac
commit 5bf6526380

View File

@ -173,11 +173,11 @@ func processUserData(data []byte) error {
switch fi := i.(type) {
case map[string]interface{}:
if _, ok := fi["perm"]; !ok {
log.Printf("No permission provided %s:%s", f, fi)
log.Printf("No permission provided %s", f)
continue
}
if _, ok := fi["content"]; !ok {
log.Printf("No content provided %s:%s", f, fi)
log.Printf("No content provided %s", f)
continue
}
c = fi["content"].(string)