{"action":"created","comment":{"url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/comments/123616819","pull_request_review_id":45839969,"id":123616819,"diff_hunk":"@@ -0,0 +1,153 @@\n+// Copyright (c) 2017 Tigera, Inc. All rights reserved.\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+package resources\n+\n+import (\n+\t\"reflect\"\n+\t\"strings\"\n+\n+\t\"github.com/projectcalico/libcalico-go/lib/api\"\n+\t\"github.com/projectcalico/libcalico-go/lib/backend/k8s/thirdparty\"\n+\t\"github.com/projectcalico/libcalico-go/lib/backend/model\"\n+\t\"github.com/projectcalico/libcalico-go/lib/converter\"\n+\t\"github.com/projectcalico/libcalico-go/lib/net\"\n+\t\"github.com/projectcalico/libcalico-go/lib/scope\"\n+\n+\tlog \"github.com/Sirupsen/logrus\"\n+\n+\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n+\t\"k8s.io/client-go/kubernetes\"\n+\t\"k8s.io/client-go/rest\"\n+)\n+\n+const (\n+\tGlobalBGPPeerResourceName = \"globalbgppeers\"\n+\tGlobalBGPPeerTPRName      = \"global-bgp-peer.projectcalico.org\"\n+)\n+\n+func NewGlobalBGPPeerHandler(c *kubernetes.Clientset, r *rest.RESTClient) ResourceHandler {\n+\treturn newTPRHandler(\n+\t\tc, r,\n+\t\tGlobalBGPPeerTPRName,\n+\t\tGlobalBGPPeerResourceName,\n+\t\t\"Calico Global BGP Peers\",\n+\t\treflect.TypeOf(thirdparty.GlobalBGPPeer{}),\n+\t\treflect.TypeOf(thirdparty.GlobalBGPPeerList{}),\n+\t\tGlobalBGPPeerConverter{},\n+\t)\n+}\n+\n+// GlobalBGPPeerConvert implements the ResourceConverter interface.\n+type GlobalBGPPeerConverter struct {\n+\tconverter.BGPPeerConverter\n+}\n+\n+func (_ GlobalBGPPeerConverter) ListInterfaceToKey(l model.ListInterface) model.Key {\n+\tpl := l.(model.GlobalBGPPeerListOptions)\n+\tif pl.PeerIP.IP != nil {\n+\t\treturn model.GlobalBGPPeerKey{PeerIP: pl.PeerIP}\n+\t}\n+\treturn nil\n+}\n+\n+func (_ GlobalBGPPeerConverter) KeyToResourceName(k model.Key) (string, error) {\n+\t// The name should be policed before we get here.","path":"lib/backend/k8s/resources/globalbgppeer.go","position":66,"original_position":66,"commit_id":"58e111c1000a533ed401e956837490a3e5c73cfc","original_commit_id":"58e111c1000a533ed401e956837490a3e5c73cfc","user":{"login":"bcreane","id":12074410,"avatar_url":"https://avatars0.githubusercontent.com/u/12074410?v=3","gravatar_id":"","url":"https://api.github.com/users/bcreane","html_url":"https://github.com/bcreane","followers_url":"https://api.github.com/users/bcreane/followers","following_url":"https://api.github.com/users/bcreane/following{/other_user}","gists_url":"https://api.github.com/users/bcreane/gists{/gist_id}","starred_url":"https://api.github.com/users/bcreane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcreane/subscriptions","organizations_url":"https://api.github.com/users/bcreane/orgs","repos_url":"https://api.github.com/users/bcreane/repos","events_url":"https://api.github.com/users/bcreane/events{/privacy}","received_events_url":"https://api.github.com/users/bcreane/received_events","type":"User","site_admin":false},"body":"policed->validated?","created_at":"2017-06-22T20:42:17Z","updated_at":"2017-06-22T20:42:17Z","html_url":"https://github.com/projectcalico/libcalico-go/pull/455#discussion_r123616819","pull_request_url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455","_links":{"self":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/comments/123616819"},"html":{"href":"https://github.com/projectcalico/libcalico-go/pull/455#discussion_r123616819"},"pull_request":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455"}}},"pull_request":{"url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455","id":125863722,"html_url":"https://github.com/projectcalico/libcalico-go/pull/455","diff_url":"https://github.com/projectcalico/libcalico-go/pull/455.diff","patch_url":"https://github.com/projectcalico/libcalico-go/pull/455.patch","issue_url":"https://api.github.com/repos/projectcalico/libcalico-go/issues/455","number":455,"state":"open","locked":false,"title":"Add common infrastructure for TPR resources and add BGP Peering config","user":{"login":"robbrockbank","id":3227729,"avatar_url":"https://avatars3.githubusercontent.com/u/3227729?v=3","gravatar_id":"","url":"https://api.github.com/users/robbrockbank","html_url":"https://github.com/robbrockbank","followers_url":"https://api.github.com/users/robbrockbank/followers","following_url":"https://api.github.com/users/robbrockbank/following{/other_user}","gists_url":"https://api.github.com/users/robbrockbank/gists{/gist_id}","starred_url":"https://api.github.com/users/robbrockbank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbrockbank/subscriptions","organizations_url":"https://api.github.com/users/robbrockbank/orgs","repos_url":"https://api.github.com/users/robbrockbank/repos","events_url":"https://api.github.com/users/robbrockbank/events{/privacy}","received_events_url":"https://api.github.com/users/robbrockbank/received_events","type":"User","site_admin":false},"body":"This PR adds:\r\n-  Generic TPR resource handling (when there is a 1:1 mapping between a Calico Resource and a TPR.\r\n-  Global BGP Peers\r\n-  It migrates the IPPools and System Network Policies to the generic TPR code\r\n-  Add client and k8s tests\r\n\r\n\r\nThere are a bunch of changes resulting from moving the MustParseIP/IPNet/CIDR methods out of testutils and into net.  This makes the review look a bit bigger than it actually is.\r\n\r\nThis should be a standalone PR - and the Per-Node BGP Peers can be added as a separate PR, so removing the [WIP] label from this PR.\r\n\r\nOther possible change (not intending to make at this stage):\r\n-  Move syncer code into the TPR handler and the ResourceHandler interface (so that it takes care of converting to the KVPairs automatically).\r\n-  Register each of the TPRs or ResourceHandlers so that the CRUD operations can automatically fan out to the appropriate helper without having to have separate branches for each (basically have each ResourceHelper register as a CRUD helper).\r\n-  Migrate Global config over to the TPR helper","created_at":"2017-06-15T16:36:21Z","updated_at":"2017-06-22T20:42:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24475e6c12932a9d85a24d07ee74e2dc0c85ce19","assignee":{"login":"caseydavenport","id":1944093,"avatar_url":"https://avatars0.githubusercontent.com/u/1944093?v=3","gravatar_id":"","url":"https://api.github.com/users/caseydavenport","html_url":"https://github.com/caseydavenport","followers_url":"https://api.github.com/users/caseydavenport/followers","following_url":"https://api.github.com/users/caseydavenport/following{/other_user}","gists_url":"https://api.github.com/users/caseydavenport/gists{/gist_id}","starred_url":"https://api.github.com/users/caseydavenport/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseydavenport/subscriptions","organizations_url":"https://api.github.com/users/caseydavenport/orgs","repos_url":"https://api.github.com/users/caseydavenport/repos","events_url":"https://api.github.com/users/caseydavenport/events{/privacy}","received_events_url":"https://api.github.com/users/caseydavenport/received_events","type":"User","site_admin":false},"assignees":[{"login":"caseydavenport","id":1944093,"avatar_url":"https://avatars0.githubusercontent.com/u/1944093?v=3","gravatar_id":"","url":"https://api.github.com/users/caseydavenport","html_url":"https://github.com/caseydavenport","followers_url":"https://api.github.com/users/caseydavenport/followers","following_url":"https://api.github.com/users/caseydavenport/following{/other_user}","gists_url":"https://api.github.com/users/caseydavenport/gists{/gist_id}","starred_url":"https://api.github.com/users/caseydavenport/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseydavenport/subscriptions","organizations_url":"https://api.github.com/users/caseydavenport/orgs","repos_url":"https://api.github.com/users/caseydavenport/repos","events_url":"https://api.github.com/users/caseydavenport/events{/privacy}","received_events_url":"https://api.github.com/users/caseydavenport/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455/commits","review_comments_url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455/comments","review_comment_url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projectcalico/libcalico-go/issues/455/comments","statuses_url":"https://api.github.com/repos/projectcalico/libcalico-go/statuses/58e111c1000a533ed401e956837490a3e5c73cfc","head":{"label":"robbrockbank:tpr-infra","ref":"tpr-infra","sha":"58e111c1000a533ed401e956837490a3e5c73cfc","user":{"login":"robbrockbank","id":3227729,"avatar_url":"https://avatars3.githubusercontent.com/u/3227729?v=3","gravatar_id":"","url":"https://api.github.com/users/robbrockbank","html_url":"https://github.com/robbrockbank","followers_url":"https://api.github.com/users/robbrockbank/followers","following_url":"https://api.github.com/users/robbrockbank/following{/other_user}","gists_url":"https://api.github.com/users/robbrockbank/gists{/gist_id}","starred_url":"https://api.github.com/users/robbrockbank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbrockbank/subscriptions","organizations_url":"https://api.github.com/users/robbrockbank/orgs","repos_url":"https://api.github.com/users/robbrockbank/repos","events_url":"https://api.github.com/users/robbrockbank/events{/privacy}","received_events_url":"https://api.github.com/users/robbrockbank/received_events","type":"User","site_admin":false},"repo":{"id":63622166,"name":"libcalico-go","full_name":"robbrockbank/libcalico-go","owner":{"login":"robbrockbank","id":3227729,"avatar_url":"https://avatars3.githubusercontent.com/u/3227729?v=3","gravatar_id":"","url":"https://api.github.com/users/robbrockbank","html_url":"https://github.com/robbrockbank","followers_url":"https://api.github.com/users/robbrockbank/followers","following_url":"https://api.github.com/users/robbrockbank/following{/other_user}","gists_url":"https://api.github.com/users/robbrockbank/gists{/gist_id}","starred_url":"https://api.github.com/users/robbrockbank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbrockbank/subscriptions","organizations_url":"https://api.github.com/users/robbrockbank/orgs","repos_url":"https://api.github.com/users/robbrockbank/repos","events_url":"https://api.github.com/users/robbrockbank/events{/privacy}","received_events_url":"https://api.github.com/users/robbrockbank/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robbrockbank/libcalico-go","description":"Golang Calico library functions:  https://www.projectcalico.org","fork":true,"url":"https://api.github.com/repos/robbrockbank/libcalico-go","forks_url":"https://api.github.com/repos/robbrockbank/libcalico-go/forks","keys_url":"https://api.github.com/repos/robbrockbank/libcalico-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robbrockbank/libcalico-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robbrockbank/libcalico-go/teams","hooks_url":"https://api.github.com/repos/robbrockbank/libcalico-go/hooks","issue_events_url":"https://api.github.com/repos/robbrockbank/libcalico-go/issues/events{/number}","events_url":"https://api.github.com/repos/robbrockbank/libcalico-go/events","assignees_url":"https://api.github.com/repos/robbrockbank/libcalico-go/assignees{/user}","branches_url":"https://api.github.com/repos/robbrockbank/libcalico-go/branches{/branch}","tags_url":"https://api.github.com/repos/robbrockbank/libcalico-go/tags","blobs_url":"https://api.github.com/repos/robbrockbank/libcalico-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robbrockbank/libcalico-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robbrockbank/libcalico-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/robbrockbank/libcalico-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robbrockbank/libcalico-go/statuses/{sha}","languages_url":"https://api.github.com/repos/robbrockbank/libcalico-go/languages","stargazers_url":"https://api.github.com/repos/robbrockbank/libcalico-go/stargazers","contributors_url":"https://api.github.com/repos/robbrockbank/libcalico-go/contributors","subscribers_url":"https://api.github.com/repos/robbrockbank/libcalico-go/subscribers","subscription_url":"https://api.github.com/repos/robbrockbank/libcalico-go/subscription","commits_url":"https://api.github.com/repos/robbrockbank/libcalico-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/robbrockbank/libcalico-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/robbrockbank/libcalico-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/robbrockbank/libcalico-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/robbrockbank/libcalico-go/contents/{+path}","compare_url":"https://api.github.com/repos/robbrockbank/libcalico-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robbrockbank/libcalico-go/merges","archive_url":"https://api.github.com/repos/robbrockbank/libcalico-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robbrockbank/libcalico-go/downloads","issues_url":"https://api.github.com/repos/robbrockbank/libcalico-go/issues{/number}","pulls_url":"https://api.github.com/repos/robbrockbank/libcalico-go/pulls{/number}","milestones_url":"https://api.github.com/repos/robbrockbank/libcalico-go/milestones{/number}","notifications_url":"https://api.github.com/repos/robbrockbank/libcalico-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robbrockbank/libcalico-go/labels{/name}","releases_url":"https://api.github.com/repos/robbrockbank/libcalico-go/releases{/id}","deployments_url":"https://api.github.com/repos/robbrockbank/libcalico-go/deployments","created_at":"2016-07-18T17:12:42Z","updated_at":"2016-07-18T17:12:43Z","pushed_at":"2017-06-22T20:38:52Z","git_url":"git://github.com/robbrockbank/libcalico-go.git","ssh_url":"git@github.com:robbrockbank/libcalico-go.git","clone_url":"https://github.com/robbrockbank/libcalico-go.git","svn_url":"https://github.com/robbrockbank/libcalico-go","homepage":null,"size":1452,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"projectcalico:master","ref":"master","sha":"0900b7d2a8b8e4aa212f3b808f62657e88132461","user":{"login":"projectcalico","id":12304728,"avatar_url":"https://avatars0.githubusercontent.com/u/12304728?v=3","gravatar_id":"","url":"https://api.github.com/users/projectcalico","html_url":"https://github.com/projectcalico","followers_url":"https://api.github.com/users/projectcalico/followers","following_url":"https://api.github.com/users/projectcalico/following{/other_user}","gists_url":"https://api.github.com/users/projectcalico/gists{/gist_id}","starred_url":"https://api.github.com/users/projectcalico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectcalico/subscriptions","organizations_url":"https://api.github.com/users/projectcalico/orgs","repos_url":"https://api.github.com/users/projectcalico/repos","events_url":"https://api.github.com/users/projectcalico/events{/privacy}","received_events_url":"https://api.github.com/users/projectcalico/received_events","type":"Organization","site_admin":false},"repo":{"id":63438319,"name":"libcalico-go","full_name":"projectcalico/libcalico-go","owner":{"login":"projectcalico","id":12304728,"avatar_url":"https://avatars0.githubusercontent.com/u/12304728?v=3","gravatar_id":"","url":"https://api.github.com/users/projectcalico","html_url":"https://github.com/projectcalico","followers_url":"https://api.github.com/users/projectcalico/followers","following_url":"https://api.github.com/users/projectcalico/following{/other_user}","gists_url":"https://api.github.com/users/projectcalico/gists{/gist_id}","starred_url":"https://api.github.com/users/projectcalico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectcalico/subscriptions","organizations_url":"https://api.github.com/users/projectcalico/orgs","repos_url":"https://api.github.com/users/projectcalico/repos","events_url":"https://api.github.com/users/projectcalico/events{/privacy}","received_events_url":"https://api.github.com/users/projectcalico/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projectcalico/libcalico-go","description":"Golang Calico library functions:  https://www.projectcalico.org","fork":false,"url":"https://api.github.com/repos/projectcalico/libcalico-go","forks_url":"https://api.github.com/repos/projectcalico/libcalico-go/forks","keys_url":"https://api.github.com/repos/projectcalico/libcalico-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projectcalico/libcalico-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projectcalico/libcalico-go/teams","hooks_url":"https://api.github.com/repos/projectcalico/libcalico-go/hooks","issue_events_url":"https://api.github.com/repos/projectcalico/libcalico-go/issues/events{/number}","events_url":"https://api.github.com/repos/projectcalico/libcalico-go/events","assignees_url":"https://api.github.com/repos/projectcalico/libcalico-go/assignees{/user}","branches_url":"https://api.github.com/repos/projectcalico/libcalico-go/branches{/branch}","tags_url":"https://api.github.com/repos/projectcalico/libcalico-go/tags","blobs_url":"https://api.github.com/repos/projectcalico/libcalico-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projectcalico/libcalico-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projectcalico/libcalico-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/projectcalico/libcalico-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projectcalico/libcalico-go/statuses/{sha}","languages_url":"https://api.github.com/repos/projectcalico/libcalico-go/languages","stargazers_url":"https://api.github.com/repos/projectcalico/libcalico-go/stargazers","contributors_url":"https://api.github.com/repos/projectcalico/libcalico-go/contributors","subscribers_url":"https://api.github.com/repos/projectcalico/libcalico-go/subscribers","subscription_url":"https://api.github.com/repos/projectcalico/libcalico-go/subscription","commits_url":"https://api.github.com/repos/projectcalico/libcalico-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/projectcalico/libcalico-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/projectcalico/libcalico-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/projectcalico/libcalico-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/projectcalico/libcalico-go/contents/{+path}","compare_url":"https://api.github.com/repos/projectcalico/libcalico-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projectcalico/libcalico-go/merges","archive_url":"https://api.github.com/repos/projectcalico/libcalico-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projectcalico/libcalico-go/downloads","issues_url":"https://api.github.com/repos/projectcalico/libcalico-go/issues{/number}","pulls_url":"https://api.github.com/repos/projectcalico/libcalico-go/pulls{/number}","milestones_url":"https://api.github.com/repos/projectcalico/libcalico-go/milestones{/number}","notifications_url":"https://api.github.com/repos/projectcalico/libcalico-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projectcalico/libcalico-go/labels{/name}","releases_url":"https://api.github.com/repos/projectcalico/libcalico-go/releases{/id}","deployments_url":"https://api.github.com/repos/projectcalico/libcalico-go/deployments","created_at":"2016-07-15T17:09:40Z","updated_at":"2017-06-07T17:43:49Z","pushed_at":"2017-06-22T20:38:53Z","git_url":"git://github.com/projectcalico/libcalico-go.git","ssh_url":"git@github.com:projectcalico/libcalico-go.git","clone_url":"https://github.com/projectcalico/libcalico-go.git","svn_url":"https://github.com/projectcalico/libcalico-go","homepage":null,"size":1235,"stargazers_count":31,"watchers_count":31,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":35,"forks":39,"open_issues":35,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455"},"html":{"href":"https://github.com/projectcalico/libcalico-go/pull/455"},"issue":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/issues/455"},"comments":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/issues/455/comments"},"review_comments":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455/comments"},"review_comment":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/pulls/455/commits"},"statuses":{"href":"https://api.github.com/repos/projectcalico/libcalico-go/statuses/58e111c1000a533ed401e956837490a3e5c73cfc"}}}}
{"actor":{"display_login":"bcreane"}}