{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/60047903","id":60047903,"diff_hunk":"@@ -57,47 +108,112 @@ func HaltOnError(fn AfterFunc) AfterFunc {\n \t}\n }\n \n-func encodeAndCreate(info *resource.Info, namespace string, obj runtime.Object) (runtime.Object, error) {\n+// Create is the default create operation for a generic resource.\n+func Create(info *resource.Info, namespace string, obj runtime.Object) (runtime.Object, error) {\n \treturn resource.NewHelper(info.Client, info.Mapping).Create(namespace, false, obj)\n }\n \n-// Create attempts to create each item generically, gathering all errors in the\n-// event a failure occurs. The contents of list will be updated to include the\n-// version from the server.\n-func (b *Bulk) Create(list *kapi.List, namespace string) []error {\n-\tresourceMapper := &resource.Mapper{ObjectTyper: b.Typer, RESTMapper: b.Mapper, ClientMapper: resource.ClientMapperFunc(b.RESTClientFactory)}\n-\tafter := b.After\n-\tif after == nil {\n-\t\tafter = func(*resource.Info, error) bool { return false }\n+func NoOp(info *resource.Info, namespace string, obj runtime.Object) (runtime.Object, error) {\n+\treturn info.Object, nil\n+}\n+\n+func labelSuffix(set map[string]string) string {\n+\tif len(set) == 0 {\n+\t\treturn \"\"\n+\t}\n+\treturn fmt.Sprintf(\" with label %s\", labels.SelectorFromSet(set).String())\n+}\n+\n+func CreateMessage(labels map[string]string) string {\n+\treturn fmt.Sprintf(\"Creating resources%s\", labelSuffix(labels))\n+}\n+\n+type BulkAction struct {\n+\t// required setup\n+\tBulk        Bulk\n+\tOut, ErrOut io.Writer\n+\n+\t// flags\n+\tOutput      string\n+\tDryRun      bool\n+\tStopOnError bool\n+\n+\t// output modifiers\n+\tAction string\n+}\n+\n+// BindForAction sets flags on this action for when setting -o should only change how the operation results are displayed.\n+// Passing -o is changing the default output format.\n+func (b *BulkAction) BindForAction(flags *pflag.FlagSet) {\n+\tflags.StringVarP(&b.Output, \"output\", \"o\", \"\", \"Output mode. Use \\\"-o name\\\" for shorter output (resource/name).\")\n+\tflags.BoolVar(&b.DryRun, \"dry-run\", false, \"If true, show the result of the operation without performing it.\")\n+}\n+\n+// BindForOutput sets flags on this action for when setting -o will not execute the action (the point of the action is\n+// primarily to generate the output). Passing -o is asking for output, not execution.\n+func (b *BulkAction) BindForOutput(flags *pflag.FlagSet) {\n+\tflags.StringVarP(&b.Output, \"output\", \"o\", \"\", \"Output results as yaml or json instead of executing, or use name for succint output (resource/name).\")\n+\tflags.BoolVar(&b.DryRun, \"dry-run\", false, \"If true, show the result of the operation without performing it.\")\n+}\n+\n+// Compact sets the output to a minimal set\n+func (b *BulkAction) Compact() {\n+\tb.Output = \"compact\"\n+}\n+\n+// ShouldPrint returns true if an external printer should handle this action instead of execution.\n+func (b *BulkAction) ShouldPrint() bool {\n+\treturn b.Output != \"\" && b.Output != \"name\" && b.Output != \"compact\"\n+}\n+\n+func (b *BulkAction) Verbose() bool {\n+\treturn b.Output == \"\"\n+}\n+\n+func (b *BulkAction) DefaultIndent() string {\n+\tif b.Verbose() {\n+\t\treturn \"    \"\n \t}\n+\treturn \"\"\n+}\n \n-\terrs := []error{}\n-\tfor i, item := range list.Items {\n-\t\tinfo, err := resourceMapper.InfoForObject(item, nil)\n-\t\tif err != nil {\n-\t\t\terrs = append(errs, err)\n-\t\t\tif after(info, err) {\n-\t\t\t\tbreak\n-\t\t\t}\n-\t\t\tcontinue\n+func (b BulkAction) WithMessage(action, individual string) Runner {\n+\tb.Action = action\n+\tswitch {\n+\t// TODO: this should be b printer\n+\tcase b.Output == \"\":\n+\t\tb.Bulk.After = NewPrintNameOrErrorAfterIndent(b.Bulk.Mapper.RESTMapper, false, individual, b.Out, b.ErrOut, b.DefaultIndent())","path":"pkg/config/cmd/cmd.go","position":176,"original_position":176,"commit_id":"e44ca5593b4d8049f941c4573a5a245248f6481a","original_commit_id":"e44ca5593b4d8049f941c4573a5a245248f6481a","user":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"body":"There will be no more jokes about my names!","created_at":"2016-04-18T12:21:20Z","updated_at":"2016-04-18T12:21:20Z","html_url":"https://github.com/openshift/origin/pull/8539#discussion_r60047903","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/8539","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/60047903"},"html":{"href":"https://github.com/openshift/origin/pull/8539#discussion_r60047903"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/8539"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/8539","id":66797000,"html_url":"https://github.com/openshift/origin/pull/8539","diff_url":"https://github.com/openshift/origin/pull/8539.diff","patch_url":"https://github.com/openshift/origin/pull/8539.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/8539","number":8539,"state":"open","locked":false,"title":"Make bulk output more centralized","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"Handle more conditions consistently across all \"config generator\"\ncommands.\n\nSimplify ipfailover to be more consistent with other flows.","created_at":"2016-04-18T04:16:32Z","updated_at":"2016-04-18T12:21:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6182b997bcdbc7e6d0029bbe4be62dac5bbd7822","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/8539/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/8539/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/8539/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/e44ca5593b4d8049f941c4573a5a245248f6481a","head":{"label":"smarterclayton:consistent_bulk_output","ref":"consistent_bulk_output","sha":"e44ca5593b4d8049f941c4573a5a245248f6481a","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"repo":{"id":22921364,"name":"origin","full_name":"smarterclayton/origin","owner":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smarterclayton/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/smarterclayton/origin","forks_url":"https://api.github.com/repos/smarterclayton/origin/forks","keys_url":"https://api.github.com/repos/smarterclayton/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarterclayton/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarterclayton/origin/teams","hooks_url":"https://api.github.com/repos/smarterclayton/origin/hooks","issue_events_url":"https://api.github.com/repos/smarterclayton/origin/issues/events{/number}","events_url":"https://api.github.com/repos/smarterclayton/origin/events","assignees_url":"https://api.github.com/repos/smarterclayton/origin/assignees{/user}","branches_url":"https://api.github.com/repos/smarterclayton/origin/branches{/branch}","tags_url":"https://api.github.com/repos/smarterclayton/origin/tags","blobs_url":"https://api.github.com/repos/smarterclayton/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarterclayton/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarterclayton/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarterclayton/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarterclayton/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/smarterclayton/origin/languages","stargazers_url":"https://api.github.com/repos/smarterclayton/origin/stargazers","contributors_url":"https://api.github.com/repos/smarterclayton/origin/contributors","subscribers_url":"https://api.github.com/repos/smarterclayton/origin/subscribers","subscription_url":"https://api.github.com/repos/smarterclayton/origin/subscription","commits_url":"https://api.github.com/repos/smarterclayton/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarterclayton/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarterclayton/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarterclayton/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/smarterclayton/origin/contents/{+path}","compare_url":"https://api.github.com/repos/smarterclayton/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarterclayton/origin/merges","archive_url":"https://api.github.com/repos/smarterclayton/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarterclayton/origin/downloads","issues_url":"https://api.github.com/repos/smarterclayton/origin/issues{/number}","pulls_url":"https://api.github.com/repos/smarterclayton/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/smarterclayton/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/smarterclayton/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarterclayton/origin/labels{/name}","releases_url":"https://api.github.com/repos/smarterclayton/origin/releases{/id}","deployments_url":"https://api.github.com/repos/smarterclayton/origin/deployments","created_at":"2014-08-13T15:49:23Z","updated_at":"2015-08-31T15:42:11Z","pushed_at":"2016-04-18T04:17:12Z","git_url":"git://github.com/smarterclayton/origin.git","ssh_url":"git@github.com:smarterclayton/origin.git","clone_url":"https://github.com/smarterclayton/origin.git","svn_url":"https://github.com/smarterclayton/origin","homepage":"https://openshift.github.io","size":245042,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"0a5b12b5c3257df25d96b0cfefa6f458bba172c4","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":22442668,"name":"origin","full_name":"openshift/origin","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/origin","description":"The Continuous Application Platform - build, deploy, and manage cloud-native and legacy applications on Kubernetes and Docker","fork":false,"url":"https://api.github.com/repos/openshift/origin","forks_url":"https://api.github.com/repos/openshift/origin/forks","keys_url":"https://api.github.com/repos/openshift/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/origin/teams","hooks_url":"https://api.github.com/repos/openshift/origin/hooks","issue_events_url":"https://api.github.com/repos/openshift/origin/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/origin/events","assignees_url":"https://api.github.com/repos/openshift/origin/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/origin/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/origin/tags","blobs_url":"https://api.github.com/repos/openshift/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/origin/languages","stargazers_url":"https://api.github.com/repos/openshift/origin/stargazers","contributors_url":"https://api.github.com/repos/openshift/origin/contributors","subscribers_url":"https://api.github.com/repos/openshift/origin/subscribers","subscription_url":"https://api.github.com/repos/openshift/origin/subscription","commits_url":"https://api.github.com/repos/openshift/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/origin/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/origin/merges","archive_url":"https://api.github.com/repos/openshift/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/origin/downloads","issues_url":"https://api.github.com/repos/openshift/origin/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/origin/labels{/name}","releases_url":"https://api.github.com/repos/openshift/origin/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/origin/deployments","created_at":"2014-07-30T20:04:05Z","updated_at":"2016-04-18T04:53:41Z","pushed_at":"2016-04-18T12:14:53Z","git_url":"git://github.com/openshift/origin.git","ssh_url":"git@github.com:openshift/origin.git","clone_url":"https://github.com/openshift/origin.git","svn_url":"https://github.com/openshift/origin","homepage":"http://www.openshift.org","size":318742,"stargazers_count":1228,"watchers_count":1228,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":744,"mirror_url":null,"open_issues_count":1019,"forks":744,"open_issues":1019,"watchers":1228,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/8539"},"html":{"href":"https://github.com/openshift/origin/pull/8539"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/8539"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/8539/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/8539/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/8539/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/e44ca5593b4d8049f941c4573a5a245248f6481a"}}}}