{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/22033","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/22033/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/22033/comments","events_url":"https://api.github.com/repos/docker/docker/issues/22033/events","html_url":"https://github.com/docker/docker/pull/22033","id":148345041,"number":22033,"title":"Add a check for size field in custom format string","user":{"login":"paigr","id":18450564,"avatar_url":"https://avatars.githubusercontent.com/u/18450564?v=3","gravatar_id":"","url":"https://api.github.com/users/paigr","html_url":"https://github.com/paigr","followers_url":"https://api.github.com/users/paigr/followers","following_url":"https://api.github.com/users/paigr/following{/other_user}","gists_url":"https://api.github.com/users/paigr/gists{/gist_id}","starred_url":"https://api.github.com/users/paigr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paigr/subscriptions","organizations_url":"https://api.github.com/users/paigr/orgs","repos_url":"https://api.github.com/users/paigr/repos","events_url":"https://api.github.com/users/paigr/events{/privacy}","received_events_url":"https://api.github.com/users/paigr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/status/2-code-review","name":"status/2-code-review","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2016-04-14T12:26:14Z","updated_at":"2016-05-23T20:00:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/22033","html_url":"https://github.com/docker/docker/pull/22033","diff_url":"https://github.com/docker/docker/pull/22033.diff","patch_url":"https://github.com/docker/docker/pull/22033.patch"},"body":"<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/docker/docker/blob/master/CONTRIBUTING.md\r\n\r\n** Make sure all your commits include a signature generated with `git commit -s` **\r\n\r\nFor additional information on our contributing process, read our contributing\r\nguide https://docs.docker.com/opensource/code/\r\n\r\nIf this is a bug fix, make sure your description includes \"fixes #xxxx\", or\r\n\"closes #xxxx\"\r\n\r\nPlease provide the following information:\r\n-->\r\n\r\n**- What I did**\r\nThis fix addresses an issue where including the `{{.Size}}` format\r\nfield in conjunction with `docker ps --format`, without the `--size`\r\nflag, would not correctly display the size of containers.\r\n\r\n**- How I did it**\r\nThis is done by doing a check on the custom format string, and setting\r\nthe size flag on the options struct if the field is found. This struct\r\ngets passed to the engine API which then generates the correct query.\r\n\r\n**- How to verify it**\r\nAn integration test is included which runs `docker ps --format table`\r\n`{{.Size}}` without `--size`, and checks that the returned output is\r\nnot `0 B`.\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n![Baby penguin](https://s-media-cache-ak0.pinimg.com/236x/ce/eb/92/ceeb92ff02869506c45878d00f8f651a.jpg)\r\n\r\nFixes #21991\r\n\r\nAs suggested by @cpuguy83, a parser is implemented to process the format\r\nstring as a template, and then traverses the template tree to determine\r\nif `.Size` was called.\r\n\r\nThis was then reworked by making use of template execution with a\r\npre-processor struct that will set the `--size` option if the template\r\ncalls for the field.\r\n\r\nThe pre-processor now also sets a boolean in the context passed to the\r\nwriter. There is an integration test for this that calls `docker ps`\r\n`--size --format \"{{.Size}}\"` and then checks that `size: {{.Size}}` is\r\nnot appended, as it would with previous behavior.\r\n\r\nSigned-off-by: Paulo Ribeiro <paigr.io@gmail.com>"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/221078988","html_url":"https://github.com/docker/docker/pull/22033#issuecomment-221078988","issue_url":"https://api.github.com/repos/docker/docker/issues/22033","id":221078988,"user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"created_at":"2016-05-23T20:00:47Z","updated_at":"2016-05-23T20:00:47Z","body":"@paigr Ok, I think you're right, we should not append `.Size` to a populated format.\r\nAfter changing that back, I think this will be good, nice job!"}}
{"actor":{"display_login":"cpuguy83"}}