{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/test-infra/pulls/comments/123543634","pull_request_review_id":45754542,"id":123543634,"diff_hunk":"@@ -0,0 +1,135 @@\n+/*\n+Copyright 2017 The Kubernetes Authors.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package update_config\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/Sirupsen/logrus\"\n+\n+\t\"k8s.io/test-infra/prow/github\"\n+\t\"k8s.io/test-infra/prow/kube\"\n+\t\"k8s.io/test-infra/prow/plugins\"\n+)\n+\n+const (\n+\tpluginName = \"updater\"\n+\tconfigFile = \"prow/config.yaml\"\n+\tpluginFile = \"prow/plugins.yaml\"\n+)\n+\n+func init() {\n+\tplugins.RegisterPullRequestHandler(pluginName, handlePullRequest)\n+}\n+\n+type githubClient interface {\n+\tCreateComment(owner, repo string, number int, comment string) error\n+\tGetPullRequestChanges(pr github.PullRequest) ([]github.PullRequestChange, error)\n+\tGetFile(org, repo, filepath string) (string, error)\n+}\n+\n+type kubeClient interface {\n+\tReplaceConfigMap(name string, config kube.ConfigMap) (kube.ConfigMap, error)\n+}\n+\n+func handlePullRequest(pc plugins.PluginClient, pre github.PullRequestEvent) error {\n+\treturn handle(pc.GitHubClient, pc.KubeClient, pc.Logger, pre)\n+}\n+\n+func getRemoteFile(gc githubClient, org, repo, filepath string) (string, error) {\n+\treturn gc.GetFile(org, repo, filepath)\n+}\n+\n+func handleConfig(gc githubClient, kc kubeClient, org, repo string) error {\n+\tif content, err := getRemoteFile(gc, org, repo, configFile); err != nil {\n+\t\treturn err\n+\t} else {\n+\t\tc := kube.ConfigMap{\n+\t\t\tData: map[string]string{\n+\t\t\t\t\"config\": content,\n+\t\t\t},\n+\t\t}\n+\t\tif _, err = kc.ReplaceConfigMap(\"config\", c); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t}\n+\n+\treturn nil\n+}\n+\n+func handlePlugin(gc githubClient, kc kubeClient, org, repo string) error {\n+\tif content, err := getRemoteFile(gc, org, repo, pluginFile); err != nil {\n+\t\treturn err\n+\t} else {\n+\t\tc := kube.ConfigMap{\n+\t\t\tData: map[string]string{\n+\t\t\t\t\"plugins\": content,\n+\t\t\t},\n+\t\t}\n+\t\tif _, err = kc.ReplaceConfigMap(\"plugins\", c); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t}\n+\n+\treturn nil\n+}\n+\n+func handle(gc githubClient, kc kubeClient, log *logrus.Entry, pre github.PullRequestEvent) error {\n+\t// Only consider newly merged PRs\n+\tif pre.Action != \"closed\" {\n+\t\treturn nil\n+\t}\n+\n+\tpr := pre.PullRequest\n+\tif !pr.Merged {\n+\t\treturn nil\n+\t}\n+\n+\t// process change to prow/config.yaml and prow/plugin.yaml","path":"prow/plugins/update_config/update_config.go","position":102,"original_position":102,"commit_id":"e103d2eeac7322ccfbb1a12d72a60a8aa9e3fb42","original_commit_id":"e103d2eeac7322ccfbb1a12d72a60a8aa9e3fb42","user":{"login":"spxtr","id":7368979,"avatar_url":"https://avatars1.githubusercontent.com/u/7368979?v=3","gravatar_id":"","url":"https://api.github.com/users/spxtr","html_url":"https://github.com/spxtr","followers_url":"https://api.github.com/users/spxtr/followers","following_url":"https://api.github.com/users/spxtr/following{/other_user}","gists_url":"https://api.github.com/users/spxtr/gists{/gist_id}","starred_url":"https://api.github.com/users/spxtr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spxtr/subscriptions","organizations_url":"https://api.github.com/users/spxtr/orgs","repos_url":"https://api.github.com/users/spxtr/repos","events_url":"https://api.github.com/users/spxtr/events{/privacy}","received_events_url":"https://api.github.com/users/spxtr/received_events","type":"User","site_admin":false},"body":"Start comments with caps.","created_at":"2017-06-22T15:30:05Z","updated_at":"2017-06-22T15:34:14Z","html_url":"https://github.com/kubernetes/test-infra/pull/3147#discussion_r123543634","pull_request_url":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/test-infra/pulls/comments/123543634"},"html":{"href":"https://github.com/kubernetes/test-infra/pull/3147#discussion_r123543634"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147","id":126880105,"html_url":"https://github.com/kubernetes/test-infra/pull/3147","diff_url":"https://github.com/kubernetes/test-infra/pull/3147.diff","patch_url":"https://github.com/kubernetes/test-infra/pull/3147.patch","issue_url":"https://api.github.com/repos/kubernetes/test-infra/issues/3147","number":3147,"state":"open","locked":false,"title":"Plugin for auto update prow config","user":{"login":"krzyzacy","id":1108148,"avatar_url":"https://avatars0.githubusercontent.com/u/1108148?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyzacy","html_url":"https://github.com/krzyzacy","followers_url":"https://api.github.com/users/krzyzacy/followers","following_url":"https://api.github.com/users/krzyzacy/following{/other_user}","gists_url":"https://api.github.com/users/krzyzacy/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyzacy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyzacy/subscriptions","organizations_url":"https://api.github.com/users/krzyzacy/orgs","repos_url":"https://api.github.com/users/krzyzacy/repos","events_url":"https://api.github.com/users/krzyzacy/events{/privacy}","received_events_url":"https://api.github.com/users/krzyzacy/received_events","type":"User","site_admin":false},"body":"and also someone please give it a somewhat better name.. my creativity is gone in summer\r\n\r\n/assign @spxtr \r\n\r\nI'm not sure if I can replace a configmap like this, or I need to actually create -> replace, but we can start iterate on the PR.","created_at":"2017-06-21T23:13:14Z","updated_at":"2017-06-22T15:34:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"613d8eba3fcbc833fab3ddf9a5a50d7eb937316e","assignee":{"login":"spxtr","id":7368979,"avatar_url":"https://avatars1.githubusercontent.com/u/7368979?v=3","gravatar_id":"","url":"https://api.github.com/users/spxtr","html_url":"https://github.com/spxtr","followers_url":"https://api.github.com/users/spxtr/followers","following_url":"https://api.github.com/users/spxtr/following{/other_user}","gists_url":"https://api.github.com/users/spxtr/gists{/gist_id}","starred_url":"https://api.github.com/users/spxtr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spxtr/subscriptions","organizations_url":"https://api.github.com/users/spxtr/orgs","repos_url":"https://api.github.com/users/spxtr/repos","events_url":"https://api.github.com/users/spxtr/events{/privacy}","received_events_url":"https://api.github.com/users/spxtr/received_events","type":"User","site_admin":false},"assignees":[{"login":"spxtr","id":7368979,"avatar_url":"https://avatars1.githubusercontent.com/u/7368979?v=3","gravatar_id":"","url":"https://api.github.com/users/spxtr","html_url":"https://github.com/spxtr","followers_url":"https://api.github.com/users/spxtr/followers","following_url":"https://api.github.com/users/spxtr/following{/other_user}","gists_url":"https://api.github.com/users/spxtr/gists{/gist_id}","starred_url":"https://api.github.com/users/spxtr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spxtr/subscriptions","organizations_url":"https://api.github.com/users/spxtr/orgs","repos_url":"https://api.github.com/users/spxtr/repos","events_url":"https://api.github.com/users/spxtr/events{/privacy}","received_events_url":"https://api.github.com/users/spxtr/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147/commits","review_comments_url":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147/comments","review_comment_url":"https://api.github.com/repos/kubernetes/test-infra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/test-infra/issues/3147/comments","statuses_url":"https://api.github.com/repos/kubernetes/test-infra/statuses/e103d2eeac7322ccfbb1a12d72a60a8aa9e3fb42","head":{"label":"krzyzacy:auto-prow-config","ref":"auto-prow-config","sha":"e103d2eeac7322ccfbb1a12d72a60a8aa9e3fb42","user":{"login":"krzyzacy","id":1108148,"avatar_url":"https://avatars0.githubusercontent.com/u/1108148?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyzacy","html_url":"https://github.com/krzyzacy","followers_url":"https://api.github.com/users/krzyzacy/followers","following_url":"https://api.github.com/users/krzyzacy/following{/other_user}","gists_url":"https://api.github.com/users/krzyzacy/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyzacy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyzacy/subscriptions","organizations_url":"https://api.github.com/users/krzyzacy/orgs","repos_url":"https://api.github.com/users/krzyzacy/repos","events_url":"https://api.github.com/users/krzyzacy/events{/privacy}","received_events_url":"https://api.github.com/users/krzyzacy/received_events","type":"User","site_admin":false},"repo":{"id":65492161,"name":"test-infra","full_name":"krzyzacy/test-infra","owner":{"login":"krzyzacy","id":1108148,"avatar_url":"https://avatars0.githubusercontent.com/u/1108148?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyzacy","html_url":"https://github.com/krzyzacy","followers_url":"https://api.github.com/users/krzyzacy/followers","following_url":"https://api.github.com/users/krzyzacy/following{/other_user}","gists_url":"https://api.github.com/users/krzyzacy/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyzacy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyzacy/subscriptions","organizations_url":"https://api.github.com/users/krzyzacy/orgs","repos_url":"https://api.github.com/users/krzyzacy/repos","events_url":"https://api.github.com/users/krzyzacy/events{/privacy}","received_events_url":"https://api.github.com/users/krzyzacy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krzyzacy/test-infra","description":"Test infrastructure for the Kubernetes project.","fork":true,"url":"https://api.github.com/repos/krzyzacy/test-infra","forks_url":"https://api.github.com/repos/krzyzacy/test-infra/forks","keys_url":"https://api.github.com/repos/krzyzacy/test-infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krzyzacy/test-infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krzyzacy/test-infra/teams","hooks_url":"https://api.github.com/repos/krzyzacy/test-infra/hooks","issue_events_url":"https://api.github.com/repos/krzyzacy/test-infra/issues/events{/number}","events_url":"https://api.github.com/repos/krzyzacy/test-infra/events","assignees_url":"https://api.github.com/repos/krzyzacy/test-infra/assignees{/user}","branches_url":"https://api.github.com/repos/krzyzacy/test-infra/branches{/branch}","tags_url":"https://api.github.com/repos/krzyzacy/test-infra/tags","blobs_url":"https://api.github.com/repos/krzyzacy/test-infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krzyzacy/test-infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krzyzacy/test-infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/krzyzacy/test-infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krzyzacy/test-infra/statuses/{sha}","languages_url":"https://api.github.com/repos/krzyzacy/test-infra/languages","stargazers_url":"https://api.github.com/repos/krzyzacy/test-infra/stargazers","contributors_url":"https://api.github.com/repos/krzyzacy/test-infra/contributors","subscribers_url":"https://api.github.com/repos/krzyzacy/test-infra/subscribers","subscription_url":"https://api.github.com/repos/krzyzacy/test-infra/subscription","commits_url":"https://api.github.com/repos/krzyzacy/test-infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/krzyzacy/test-infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/krzyzacy/test-infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/krzyzacy/test-infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/krzyzacy/test-infra/contents/{+path}","compare_url":"https://api.github.com/repos/krzyzacy/test-infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krzyzacy/test-infra/merges","archive_url":"https://api.github.com/repos/krzyzacy/test-infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krzyzacy/test-infra/downloads","issues_url":"https://api.github.com/repos/krzyzacy/test-infra/issues{/number}","pulls_url":"https://api.github.com/repos/krzyzacy/test-infra/pulls{/number}","milestones_url":"https://api.github.com/repos/krzyzacy/test-infra/milestones{/number}","notifications_url":"https://api.github.com/repos/krzyzacy/test-infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krzyzacy/test-infra/labels{/name}","releases_url":"https://api.github.com/repos/krzyzacy/test-infra/releases{/id}","deployments_url":"https://api.github.com/repos/krzyzacy/test-infra/deployments","created_at":"2016-08-11T18:25:52Z","updated_at":"2017-01-21T03:34:56Z","pushed_at":"2017-06-22T01:16:34Z","git_url":"git://github.com/krzyzacy/test-infra.git","ssh_url":"git@github.com:krzyzacy/test-infra.git","clone_url":"https://github.com/krzyzacy/test-infra.git","svn_url":"https://github.com/krzyzacy/test-infra","homepage":null,"size":20238,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"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":0,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"11be2d3c8718c936a3791a9986316acacb741100","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars1.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":57333709,"name":"test-infra","full_name":"kubernetes/test-infra","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars1.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/test-infra","description":"Test infrastructure for the Kubernetes project.","fork":false,"url":"https://api.github.com/repos/kubernetes/test-infra","forks_url":"https://api.github.com/repos/kubernetes/test-infra/forks","keys_url":"https://api.github.com/repos/kubernetes/test-infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/test-infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/test-infra/teams","hooks_url":"https://api.github.com/repos/kubernetes/test-infra/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/test-infra/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/test-infra/events","assignees_url":"https://api.github.com/repos/kubernetes/test-infra/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/test-infra/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/test-infra/tags","blobs_url":"https://api.github.com/repos/kubernetes/test-infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/test-infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/test-infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/test-infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/test-infra/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/test-infra/languages","stargazers_url":"https://api.github.com/repos/kubernetes/test-infra/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/test-infra/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/test-infra/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/test-infra/subscription","commits_url":"https://api.github.com/repos/kubernetes/test-infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/test-infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/test-infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/test-infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/test-infra/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/test-infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/test-infra/merges","archive_url":"https://api.github.com/repos/kubernetes/test-infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/test-infra/downloads","issues_url":"https://api.github.com/repos/kubernetes/test-infra/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/test-infra/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/test-infra/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/test-infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/test-infra/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/test-infra/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/test-infra/deployments","created_at":"2016-04-28T21:05:35Z","updated_at":"2017-06-22T11:29:15Z","pushed_at":"2017-06-22T11:52:45Z","git_url":"git://github.com/kubernetes/test-infra.git","ssh_url":"git@github.com:kubernetes/test-infra.git","clone_url":"https://github.com/kubernetes/test-infra.git","svn_url":"https://github.com/kubernetes/test-infra","homepage":null,"size":20607,"stargazers_count":99,"watchers_count":99,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":154,"mirror_url":null,"open_issues_count":214,"forks":154,"open_issues":214,"watchers":99,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147"},"html":{"href":"https://github.com/kubernetes/test-infra/pull/3147"},"issue":{"href":"https://api.github.com/repos/kubernetes/test-infra/issues/3147"},"comments":{"href":"https://api.github.com/repos/kubernetes/test-infra/issues/3147/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/test-infra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/test-infra/pulls/3147/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/test-infra/statuses/e103d2eeac7322ccfbb1a12d72a60a8aa9e3fb42"}}}}
{"actor":{"display_login":"spxtr"}}