{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/78569629","id":78569629,"diff_hunk":"@@ -0,0 +1,300 @@\n+package formatter\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\tmounttypes \"github.com/docker/docker/api/types/mount\"\n+\t\"github.com/docker/docker/api/types/swarm\"\n+\t\"github.com/docker/docker/cli/command/inspect\"\n+\tunits \"github.com/docker/go-units\"\n+)\n+\n+const serviceInspectPrettyTemplate = `\n+ID:\t\t{{.ID}}\n+Name:\t\t{{.Name}}\n+{{- if .Labels }}\n+Labels:\n+{{- range $k, $v := .Labels }}\n+ {{ $k }}{{if $v }}={{ $v }}{{ end }}\n+{{- end }}{{ end }}\n+Mode:\n+{{- if .IsModeGlobal }}\t\tGlobal\n+{{- else }}\t\tReplicated\n+{{- if .ModeReplicatedReplicas }}\n+ Replicas:\t{{ .ModeReplicatedReplicas }}\n+{{- end }}{{ end }}\n+{{- if .HasUpdateStatus }}\n+UpdateStatus:\n+ State:\t\t{{ .UpdateStatusState }}\n+ Started:\t{{ .UpdateStatusStarted }}\n+{{- if .UpdateIsCompleted }}\n+ Completed:\t{{ .UpdateStatusCompleted }}\n+{{- end }}\n+ Message:\t{{ .UpdateStatusMessage }}\n+{{- end }}\n+Placement:\n+{{- if .TaskPlacementConstraints -}}\n+ Contraints:\t{{ .TaskPlacementConstraints }}\n+{{- end }}\n+{{- if .HasUpdateConfig }}\n+UpdateConfig:\n+ Parallelism:\t{{ .UpdateParallelism }}\n+{{- if .HasUpdateDelay -}}\n+ Delay:\t\t{{ .UpdateDelay }}\n+{{- end }}\n+ On failure:\t{{ .UpdateOnFailure }}\n+{{- end }}\n+ContainerSpec:\n+ Image:\t\t{{ .ContainerImage }}\n+{{- if .ContainerArgs }}\n+ Args:\t\t{{ range $arg := .ContainerArgs }}{{ $arg }} {{ end }}\n+{{- end -}}\n+{{- if .ContainerEnv }}\n+ Env:\t\t{{ range $env := .ContainerEnv }}{{ $env }} {{ end }}\n+{{- end -}}\n+{{- if .ContainerWorkDir }}\n+ Dir:\t\t{{ .ContainerWorkDir }}\n+{{- end -}}\n+{{- if .ContainerUser }}\n+ User: {{ .ContainerUser }}\n+{{- end }}\n+{{- if .ContainerMounts }}\n+Mounts:\n+{{- end }}\n+{{- range $mount := .ContainerMounts }}\n+  Target = {{ $mount.Target }}\n+   Source = {{ $mount.Source }}\n+   ReadOnly = {{ $mount.ReadOnly }}\n+   Type = {{ $mount.Type }}\n+{{- end -}}\n+{{- if .HasResources }}\n+Resources:\n+{{- if .HasResourceReservations }}\n+ Reservations:\n+{{- end }}\n+{{- if gt .ResourceReservationNanoCPUs 0.0 }}\n+  CPU:\t\t{{ .ResourceReservationNanoCPUs }}\n+{{- end }}\n+{{- if .ResourceReservationMemory }}\n+  Memory:\t{{ .ResourceReservationMemory }}\n+{{- end }}\n+{{- if .HasResourceLimits }}\n+ Limits:\n+{{- end }}\n+{{- if gt .ResourceLimitsNanoCPUs 0.0 }}\n+  CPU:\t\t{{ .ResourceLimitsNanoCPUs }}\n+{{- end }}\n+{{- if .ResourceLimitMemory }}\n+  Memory:\t{{ .ResourceLimitMemory }}\n+{{- end }}{{ end }}\n+{{- if .Networks }}\n+Networks:\n+{{- range $network := .Networks }} {{ $network }}{{ end }} {{ end }}\n+{{- if .Ports }}\n+Ports:\n+{{- range $port := .Ports }}\n+ PublishedPort {{ $port.PublishedPort }}\n+  Protocol = {{ $port.Protocol }}\n+  TargetPort = {{ $port.TargetPort }}\n+{{- end }} {{ end -}}\n+`\n+\n+// ServiceInspectContext contains service specific information required by the formater, encapsulate a Context struct.\n+type ServiceInspectContext struct {\n+\tContext\n+\tGetRef func(ref string) (interface{}, []byte, error)\n+\tRefs   []string\n+}\n+\n+// Write prepares and writes the inspect data to the context output\n+func (ctx ServiceInspectContext) Write() error {\n+\tswitch {\n+\tcase strings.HasPrefix(ctx.Format, prettyFormatKey):\n+\t\tctx.Format = serviceInspectPrettyTemplate\n+\tdefault:\n+\t\tctx.Format = strings.TrimPrefix(ctx.Format, rawFormatKey)\n+\t\treturn inspect.Inspect(ctx.Output, ctx.Refs, ctx.Format, ctx.GetRef)\n+\t}\n+\n+\tctx.buffer = bytes.NewBufferString(\"\")\n+\tctx.preformat()\n+\n+\ttmpl, err := ctx.parseFormat()\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tfor _, ref := range ctx.Refs {\n+\t\tserviceI, _, err := ctx.GetRef(ref)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}","path":"cli/command/formatter/service.go","position":134,"original_position":134,"commit_id":"a36be424caef9baf1e8c6a8a6ee3ed5e42d07b01","original_commit_id":"a36be424caef9baf1e8c6a8a6ee3ed5e42d07b01","user":{"login":"dnephin","id":442180,"avatar_url":"https://avatars.githubusercontent.com/u/442180?v=3","gravatar_id":"","url":"https://api.github.com/users/dnephin","html_url":"https://github.com/dnephin","followers_url":"https://api.github.com/users/dnephin/followers","following_url":"https://api.github.com/users/dnephin/following{/other_user}","gists_url":"https://api.github.com/users/dnephin/gists{/gist_id}","starred_url":"https://api.github.com/users/dnephin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnephin/subscriptions","organizations_url":"https://api.github.com/users/dnephin/orgs","repos_url":"https://api.github.com/users/dnephin/repos","events_url":"https://api.github.com/users/dnephin/events{/privacy}","received_events_url":"https://api.github.com/users/dnephin/received_events","type":"User","site_admin":false},"body":"container ps Context takes a slice of containers (https://github.com/docker/docker/blob/master/cli/command/formatter/container.go#L30-L36)\r\n\r\n","created_at":"2016-09-13T14:24:09Z","updated_at":"2016-09-13T14:24:10Z","html_url":"https://github.com/docker/docker/pull/25025#discussion_r78569629","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/25025","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/78569629"},"html":{"href":"https://github.com/docker/docker/pull/25025#discussion_r78569629"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/25025"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/25025","id":78746095,"html_url":"https://github.com/docker/docker/pull/25025","diff_url":"https://github.com/docker/docker/pull/25025.diff","patch_url":"https://github.com/docker/docker/pull/25025.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/25025","number":25025,"state":"open","locked":false,"title":"Add formatter for service inspect","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},"body":"Allows the user to use `pretty` as the format string.\r\nThis enables users to put custom format options into their CLI config\r\njust like is supported for `docker ps` and `docker images`\r\n\r\nExample config:\r\n\r\n```json\r\n{\r\n\t\"psFormat\": \"table {{.Names}}\\\\t{{.Image}}\\\\t{{.RunningFor}} ago\\\\t{{.Status}}\\\\t{{.Command}}\",\r\n\t\"imagesFormat\": \"table {{.Repository}}\\\\t{{.Tag}}\\\\t{{.ID}}\\\\t{{.Size}}\",\r\n\t\"serviceInspectFormat\": \"pretty\"\r\n}\r\n```","created_at":"2016-07-25T20:28:11Z","updated_at":"2016-09-13T14:24:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ec819f07663f50b24a0a84d9cc390398deca0390","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/25025/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/25025/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/25025/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/a36be424caef9baf1e8c6a8a6ee3ed5e42d07b01","head":{"label":"cpuguy83:service_inspect_formatter","ref":"service_inspect_formatter","sha":"a36be424caef9baf1e8c6a8a6ee3ed5e42d07b01","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},"repo":{"id":15300899,"name":"docker","full_name":"cpuguy83/docker","owner":{"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},"private":false,"html_url":"https://github.com/cpuguy83/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/cpuguy83/docker","forks_url":"https://api.github.com/repos/cpuguy83/docker/forks","keys_url":"https://api.github.com/repos/cpuguy83/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cpuguy83/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cpuguy83/docker/teams","hooks_url":"https://api.github.com/repos/cpuguy83/docker/hooks","issue_events_url":"https://api.github.com/repos/cpuguy83/docker/issues/events{/number}","events_url":"https://api.github.com/repos/cpuguy83/docker/events","assignees_url":"https://api.github.com/repos/cpuguy83/docker/assignees{/user}","branches_url":"https://api.github.com/repos/cpuguy83/docker/branches{/branch}","tags_url":"https://api.github.com/repos/cpuguy83/docker/tags","blobs_url":"https://api.github.com/repos/cpuguy83/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cpuguy83/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cpuguy83/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/cpuguy83/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cpuguy83/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/cpuguy83/docker/languages","stargazers_url":"https://api.github.com/repos/cpuguy83/docker/stargazers","contributors_url":"https://api.github.com/repos/cpuguy83/docker/contributors","subscribers_url":"https://api.github.com/repos/cpuguy83/docker/subscribers","subscription_url":"https://api.github.com/repos/cpuguy83/docker/subscription","commits_url":"https://api.github.com/repos/cpuguy83/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/cpuguy83/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/cpuguy83/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/cpuguy83/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/cpuguy83/docker/contents/{+path}","compare_url":"https://api.github.com/repos/cpuguy83/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cpuguy83/docker/merges","archive_url":"https://api.github.com/repos/cpuguy83/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cpuguy83/docker/downloads","issues_url":"https://api.github.com/repos/cpuguy83/docker/issues{/number}","pulls_url":"https://api.github.com/repos/cpuguy83/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/cpuguy83/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/cpuguy83/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cpuguy83/docker/labels{/name}","releases_url":"https://api.github.com/repos/cpuguy83/docker/releases{/id}","deployments_url":"https://api.github.com/repos/cpuguy83/docker/deployments","created_at":"2013-12-19T02:58:40Z","updated_at":"2015-04-27T13:11:12Z","pushed_at":"2016-09-13T13:55:47Z","git_url":"git://github.com/cpuguy83/docker.git","ssh_url":"git@github.com:cpuguy83/docker.git","clone_url":"https://github.com/cpuguy83/docker.git","svn_url":"https://github.com/cpuguy83/docker","homepage":"http://www.docker.io","size":101657,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"e345d67c4e2862d497ec92640fd00bf04e6b696e","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-09-13T13:41:10Z","pushed_at":"2016-09-13T13:55:50Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":209273,"stargazers_count":34904,"watchers_count":34904,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10263,"mirror_url":null,"open_issues_count":2227,"forks":10263,"open_issues":2227,"watchers":34904,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/25025"},"html":{"href":"https://github.com/docker/docker/pull/25025"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/25025"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/25025/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/25025/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/25025/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/a36be424caef9baf1e8c6a8a6ee3ed5e42d07b01"}}}}
{"actor":{"display_login":"dnephin"}}