{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/flannel/pulls/comments/30434194","id":30434194,"diff_hunk":"@@ -0,0 +1,190 @@\n+// Copyright 2015 CoreOS, Inc.\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 remote\n+\n+import (\n+\t\"bytes\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"path\"\n+\n+\t//log \"github.com/coreos/flannel/Godeps/_workspace/src/github.com/golang/glog\"\n+\t\"github.com/coreos/flannel/Godeps/_workspace/src/golang.org/x/net/context\"\n+\t\"github.com/coreos/flannel/subnet\"\n+)\n+\n+type httpRespErr struct {\n+\tresp *http.Response\n+\terr  error\n+}\n+\n+func httpDo(ctx context.Context, req *http.Request) (*http.Response, error) {\n+\t// Run the HTTP request in a goroutine and pass the response to f.\n+\ttr := &http.Transport{}\n+\tclient := &http.Client{Transport: tr}\n+\tc := make(chan httpRespErr, 1)\n+\tgo func() {\n+\t\tresp, err := client.Do(req)\n+\t\tc <- httpRespErr{resp, err}\n+\t}()\n+\n+\tselect {\n+\tcase <-ctx.Done():\n+\t\ttr.CancelRequest(req)\n+\t\t<-c // Wait for f to return.\n+\t\treturn nil, ctx.Err()\n+\tcase r := <-c:\n+\t\treturn r.resp, r.err\n+\t}\n+}\n+\n+// implements subnet.Manager by sending requests to the server\n+type RemoteManager struct {\n+\tclient http.Client\n+\thost   string // includes scheme, host, and port\n+}\n+\n+func NewRemoteManager(listenAddr string) subnet.Manager {\n+\treturn &RemoteManager{host: \"http://\" + listenAddr}\n+}\n+\n+func (m *RemoteManager) mkurl(network string, parts ...string) string {\n+\tif network == \"\" {\n+\t\tnetwork = \"/_\"\n+\t}\n+\tif network[0] != '/' {\n+\t\tnetwork = \"/\" + network\n+\t}\n+\treturn m.host + path.Join(append([]string{network}, parts...)...)\n+}\n+\n+func (m *RemoteManager) GetNetworkConfig(ctx context.Context, network string) (*subnet.Config, error) {","path":"remote/client.go","position":75,"original_position":75,"commit_id":"56f192c5f392ece84d84f26b65bad586dc5a51a6","original_commit_id":"56f192c5f392ece84d84f26b65bad586dc5a51a6","user":{"login":"eyakubovich","id":3586053,"avatar_url":"https://avatars.githubusercontent.com/u/3586053?v=3","gravatar_id":"","url":"https://api.github.com/users/eyakubovich","html_url":"https://github.com/eyakubovich","followers_url":"https://api.github.com/users/eyakubovich/followers","following_url":"https://api.github.com/users/eyakubovich/following{/other_user}","gists_url":"https://api.github.com/users/eyakubovich/gists{/gist_id}","starred_url":"https://api.github.com/users/eyakubovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyakubovich/subscriptions","organizations_url":"https://api.github.com/users/eyakubovich/orgs","repos_url":"https://api.github.com/users/eyakubovich/repos","events_url":"https://api.github.com/users/eyakubovich/events{/privacy}","received_events_url":"https://api.github.com/users/eyakubovich/received_events","type":"User","site_admin":false},"body":"RemoteManager implements subnet.Manager interface which has `ctx` as the first arg for consistency. Not all methods/implementations (there're two now) do anything with it yet. New etcd client is ctx based so once we move over to it, it'll be used more.","created_at":"2015-05-15T18:38:59Z","updated_at":"2015-05-15T18:38:59Z","html_url":"https://github.com/coreos/flannel/pull/177#discussion_r30434194","pull_request_url":"https://api.github.com/repos/coreos/flannel/pulls/177","_links":{"self":{"href":"https://api.github.com/repos/coreos/flannel/pulls/comments/30434194"},"html":{"href":"https://github.com/coreos/flannel/pull/177#discussion_r30434194"},"pull_request":{"href":"https://api.github.com/repos/coreos/flannel/pulls/177"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/flannel/pulls/177","id":35532886,"html_url":"https://github.com/coreos/flannel/pull/177","diff_url":"https://github.com/coreos/flannel/pull/177.diff","patch_url":"https://github.com/coreos/flannel/pull/177.patch","issue_url":"https://api.github.com/repos/coreos/flannel/issues/177","number":177,"state":"open","locked":false,"title":"Client server","user":{"login":"eyakubovich","id":3586053,"avatar_url":"https://avatars.githubusercontent.com/u/3586053?v=3","gravatar_id":"","url":"https://api.github.com/users/eyakubovich","html_url":"https://github.com/eyakubovich","followers_url":"https://api.github.com/users/eyakubovich/followers","following_url":"https://api.github.com/users/eyakubovich/following{/other_user}","gists_url":"https://api.github.com/users/eyakubovich/gists{/gist_id}","starred_url":"https://api.github.com/users/eyakubovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyakubovich/subscriptions","organizations_url":"https://api.github.com/users/eyakubovich/orgs","repos_url":"https://api.github.com/users/eyakubovich/repos","events_url":"https://api.github.com/users/eyakubovich/events{/privacy}","received_events_url":"https://api.github.com/users/eyakubovich/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-15T17:22:47Z","updated_at":"2015-05-15T18:38:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8c30680611c179607bdb286a220cc4d56ff5a0a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coreos/flannel/pulls/177/commits","review_comments_url":"https://api.github.com/repos/coreos/flannel/pulls/177/comments","review_comment_url":"https://api.github.com/repos/coreos/flannel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/flannel/issues/177/comments","statuses_url":"https://api.github.com/repos/coreos/flannel/statuses/56f192c5f392ece84d84f26b65bad586dc5a51a6","head":{"label":"eyakubovich:client-server","ref":"client-server","sha":"56f192c5f392ece84d84f26b65bad586dc5a51a6","user":{"login":"eyakubovich","id":3586053,"avatar_url":"https://avatars.githubusercontent.com/u/3586053?v=3","gravatar_id":"","url":"https://api.github.com/users/eyakubovich","html_url":"https://github.com/eyakubovich","followers_url":"https://api.github.com/users/eyakubovich/followers","following_url":"https://api.github.com/users/eyakubovich/following{/other_user}","gists_url":"https://api.github.com/users/eyakubovich/gists{/gist_id}","starred_url":"https://api.github.com/users/eyakubovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyakubovich/subscriptions","organizations_url":"https://api.github.com/users/eyakubovich/orgs","repos_url":"https://api.github.com/users/eyakubovich/repos","events_url":"https://api.github.com/users/eyakubovich/events{/privacy}","received_events_url":"https://api.github.com/users/eyakubovich/received_events","type":"User","site_admin":false},"repo":{"id":23436332,"name":"flannel","full_name":"eyakubovich/flannel","owner":{"login":"eyakubovich","id":3586053,"avatar_url":"https://avatars.githubusercontent.com/u/3586053?v=3","gravatar_id":"","url":"https://api.github.com/users/eyakubovich","html_url":"https://github.com/eyakubovich","followers_url":"https://api.github.com/users/eyakubovich/followers","following_url":"https://api.github.com/users/eyakubovich/following{/other_user}","gists_url":"https://api.github.com/users/eyakubovich/gists{/gist_id}","starred_url":"https://api.github.com/users/eyakubovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyakubovich/subscriptions","organizations_url":"https://api.github.com/users/eyakubovich/orgs","repos_url":"https://api.github.com/users/eyakubovich/repos","events_url":"https://api.github.com/users/eyakubovich/events{/privacy}","received_events_url":"https://api.github.com/users/eyakubovich/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eyakubovich/flannel","description":"flannel is an etcd backed overlay network for containers","fork":true,"url":"https://api.github.com/repos/eyakubovich/flannel","forks_url":"https://api.github.com/repos/eyakubovich/flannel/forks","keys_url":"https://api.github.com/repos/eyakubovich/flannel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eyakubovich/flannel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eyakubovich/flannel/teams","hooks_url":"https://api.github.com/repos/eyakubovich/flannel/hooks","issue_events_url":"https://api.github.com/repos/eyakubovich/flannel/issues/events{/number}","events_url":"https://api.github.com/repos/eyakubovich/flannel/events","assignees_url":"https://api.github.com/repos/eyakubovich/flannel/assignees{/user}","branches_url":"https://api.github.com/repos/eyakubovich/flannel/branches{/branch}","tags_url":"https://api.github.com/repos/eyakubovich/flannel/tags","blobs_url":"https://api.github.com/repos/eyakubovich/flannel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eyakubovich/flannel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eyakubovich/flannel/git/refs{/sha}","trees_url":"https://api.github.com/repos/eyakubovich/flannel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eyakubovich/flannel/statuses/{sha}","languages_url":"https://api.github.com/repos/eyakubovich/flannel/languages","stargazers_url":"https://api.github.com/repos/eyakubovich/flannel/stargazers","contributors_url":"https://api.github.com/repos/eyakubovich/flannel/contributors","subscribers_url":"https://api.github.com/repos/eyakubovich/flannel/subscribers","subscription_url":"https://api.github.com/repos/eyakubovich/flannel/subscription","commits_url":"https://api.github.com/repos/eyakubovich/flannel/commits{/sha}","git_commits_url":"https://api.github.com/repos/eyakubovich/flannel/git/commits{/sha}","comments_url":"https://api.github.com/repos/eyakubovich/flannel/comments{/number}","issue_comment_url":"https://api.github.com/repos/eyakubovich/flannel/issues/comments{/number}","contents_url":"https://api.github.com/repos/eyakubovich/flannel/contents/{+path}","compare_url":"https://api.github.com/repos/eyakubovich/flannel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eyakubovich/flannel/merges","archive_url":"https://api.github.com/repos/eyakubovich/flannel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eyakubovich/flannel/downloads","issues_url":"https://api.github.com/repos/eyakubovich/flannel/issues{/number}","pulls_url":"https://api.github.com/repos/eyakubovich/flannel/pulls{/number}","milestones_url":"https://api.github.com/repos/eyakubovich/flannel/milestones{/number}","notifications_url":"https://api.github.com/repos/eyakubovich/flannel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eyakubovich/flannel/labels{/name}","releases_url":"https://api.github.com/repos/eyakubovich/flannel/releases{/id}","created_at":"2014-08-28T17:11:27Z","updated_at":"2015-04-24T20:54:32Z","pushed_at":"2015-05-15T17:22:28Z","git_url":"git://github.com/eyakubovich/flannel.git","ssh_url":"git@github.com:eyakubovich/flannel.git","clone_url":"https://github.com/eyakubovich/flannel.git","svn_url":"https://github.com/eyakubovich/flannel","homepage":"","size":14137,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"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":"coreos:master","ref":"master","sha":"4ab27ddd3e87eb2daf152513c0b1dc22879393a8","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":21704134,"name":"flannel","full_name":"coreos/flannel","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/flannel","description":"flannel is an etcd backed network fabric for containers","fork":false,"url":"https://api.github.com/repos/coreos/flannel","forks_url":"https://api.github.com/repos/coreos/flannel/forks","keys_url":"https://api.github.com/repos/coreos/flannel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/flannel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/flannel/teams","hooks_url":"https://api.github.com/repos/coreos/flannel/hooks","issue_events_url":"https://api.github.com/repos/coreos/flannel/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/flannel/events","assignees_url":"https://api.github.com/repos/coreos/flannel/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/flannel/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/flannel/tags","blobs_url":"https://api.github.com/repos/coreos/flannel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/flannel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/flannel/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/flannel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/flannel/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/flannel/languages","stargazers_url":"https://api.github.com/repos/coreos/flannel/stargazers","contributors_url":"https://api.github.com/repos/coreos/flannel/contributors","subscribers_url":"https://api.github.com/repos/coreos/flannel/subscribers","subscription_url":"https://api.github.com/repos/coreos/flannel/subscription","commits_url":"https://api.github.com/repos/coreos/flannel/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/flannel/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/flannel/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/flannel/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/flannel/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/flannel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/flannel/merges","archive_url":"https://api.github.com/repos/coreos/flannel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/flannel/downloads","issues_url":"https://api.github.com/repos/coreos/flannel/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/flannel/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/flannel/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/flannel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/flannel/labels{/name}","releases_url":"https://api.github.com/repos/coreos/flannel/releases{/id}","created_at":"2014-07-10T17:45:29Z","updated_at":"2015-05-14T16:18:50Z","pushed_at":"2015-05-15T17:22:48Z","git_url":"git://github.com/coreos/flannel.git","ssh_url":"git@github.com:coreos/flannel.git","clone_url":"https://github.com/coreos/flannel.git","svn_url":"https://github.com/coreos/flannel","homepage":"","size":3829,"stargazers_count":714,"watchers_count":714,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":79,"mirror_url":null,"open_issues_count":27,"forks":79,"open_issues":27,"watchers":714,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/flannel/pulls/177"},"html":{"href":"https://github.com/coreos/flannel/pull/177"},"issue":{"href":"https://api.github.com/repos/coreos/flannel/issues/177"},"comments":{"href":"https://api.github.com/repos/coreos/flannel/issues/177/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/flannel/pulls/177/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/flannel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/flannel/pulls/177/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/flannel/statuses/56f192c5f392ece84d84f26b65bad586dc5a51a6"}}}}