{"action":"created","comment":{"url":"https://api.github.com/repos/docker/libcontainer/pulls/comments/25113003","id":25113003,"diff_hunk":"@@ -26,9 +28,21 @@ type NetworkStrategy interface {\n // provided type.  If no strategy is registered for the type an\n // ErrNotValidStrategyType is returned.\n func GetStrategy(tpe string) (NetworkStrategy, error) {\n+\tstrategiesMtx.RLock()\n+\tdefer strategiesMtx.RUnlock()\n \ts, exists := strategies[tpe]\n \tif !exists {\n \t\treturn nil, ErrNotValidStrategyType\n \t}\n \treturn s, nil\n }\n+\n+// AddStrategy registers a network strategy to be used for the\n+// provided type. If there is a strategy already associated with\n+// that type, it will be overridden. Multiple goroutines can\n+// safely call AddStrategy.\n+func AddStrategy(tpe string, strategy NetworkStrategy) {\n+\tstrategiesMtx.Lock()\n+\tdefer strategiesMtx.Unlock()","path":"network/strategy.go","position":43,"original_position":43,"commit_id":"579161c10b5e32ae58e88fa6869d29fee61275c4","original_commit_id":"579161c10b5e32ae58e88fa6869d29fee61275c4","user":{"login":"fabiokung","id":5755,"avatar_url":"https://avatars.githubusercontent.com/u/5755?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiokung","html_url":"https://github.com/fabiokung","followers_url":"https://api.github.com/users/fabiokung/followers","following_url":"https://api.github.com/users/fabiokung/following{/other_user}","gists_url":"https://api.github.com/users/fabiokung/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiokung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiokung/subscriptions","organizations_url":"https://api.github.com/users/fabiokung/orgs","repos_url":"https://api.github.com/users/fabiokung/repos","events_url":"https://api.github.com/users/fabiokung/events{/privacy}","received_events_url":"https://api.github.com/users/fabiokung/received_events","type":"User","site_admin":false},"body":"but why not? This makes it slightly more robust on future changes.","created_at":"2015-02-20T23:39:49Z","updated_at":"2015-02-20T23:39:49Z","html_url":"https://github.com/docker/libcontainer/pull/365#discussion_r25113003","pull_request_url":"https://api.github.com/repos/docker/libcontainer/pulls/365","_links":{"self":{"href":"https://api.github.com/repos/docker/libcontainer/pulls/comments/25113003"},"html":{"href":"https://github.com/docker/libcontainer/pull/365#discussion_r25113003"},"pull_request":{"href":"https://api.github.com/repos/docker/libcontainer/pulls/365"}}},"pull_request":{"url":"https://api.github.com/repos/docker/libcontainer/pulls/365","id":28960334,"html_url":"https://github.com/docker/libcontainer/pull/365","diff_url":"https://github.com/docker/libcontainer/pull/365.diff","patch_url":"https://github.com/docker/libcontainer/pull/365.patch","issue_url":"https://api.github.com/repos/docker/libcontainer/issues/365","number":365,"state":"open","locked":false,"title":"Allow custom network strategies","user":{"login":"fabiokung","id":5755,"avatar_url":"https://avatars.githubusercontent.com/u/5755?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiokung","html_url":"https://github.com/fabiokung","followers_url":"https://api.github.com/users/fabiokung/followers","following_url":"https://api.github.com/users/fabiokung/following{/other_user}","gists_url":"https://api.github.com/users/fabiokung/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiokung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiokung/subscriptions","organizations_url":"https://api.github.com/users/fabiokung/orgs","repos_url":"https://api.github.com/users/fabiokung/repos","events_url":"https://api.github.com/users/fabiokung/events{/privacy}","received_events_url":"https://api.github.com/users/fabiokung/received_events","type":"User","site_admin":false},"body":"Open up the possibility for new network modes (and existing ones to be replaced).\r\n\r\nThe need for a \"no layer-2\" network mode (routing only, no bridges) motivated me to add this, instead of expecting that all possible network modes/strategies will be in libcontainer itself.\r\n\r\n`NetworkStrategies` can be safely registered and queried by multiple goroutines.\r\n\r\nSigned-off-by: Fabio Kung <fabio.kung@gmail.com>","created_at":"2015-02-09T21:57:18Z","updated_at":"2015-02-20T23:39:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d98fde9cf17a80cf8f8188a5ee3b222d277557c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/libcontainer/pulls/365/commits","review_comments_url":"https://api.github.com/repos/docker/libcontainer/pulls/365/comments","review_comment_url":"https://api.github.com/repos/docker/libcontainer/pulls/comments/{number}","comments_url":"https://api.github.com/repos/docker/libcontainer/issues/365/comments","statuses_url":"https://api.github.com/repos/docker/libcontainer/statuses/579161c10b5e32ae58e88fa6869d29fee61275c4","head":{"label":"fabiokung:custom-network-strategies","ref":"custom-network-strategies","sha":"579161c10b5e32ae58e88fa6869d29fee61275c4","user":{"login":"fabiokung","id":5755,"avatar_url":"https://avatars.githubusercontent.com/u/5755?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiokung","html_url":"https://github.com/fabiokung","followers_url":"https://api.github.com/users/fabiokung/followers","following_url":"https://api.github.com/users/fabiokung/following{/other_user}","gists_url":"https://api.github.com/users/fabiokung/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiokung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiokung/subscriptions","organizations_url":"https://api.github.com/users/fabiokung/orgs","repos_url":"https://api.github.com/users/fabiokung/repos","events_url":"https://api.github.com/users/fabiokung/events{/privacy}","received_events_url":"https://api.github.com/users/fabiokung/received_events","type":"User","site_admin":false},"repo":{"id":29701157,"name":"libcontainer","full_name":"fabiokung/libcontainer","owner":{"login":"fabiokung","id":5755,"avatar_url":"https://avatars.githubusercontent.com/u/5755?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiokung","html_url":"https://github.com/fabiokung","followers_url":"https://api.github.com/users/fabiokung/followers","following_url":"https://api.github.com/users/fabiokung/following{/other_user}","gists_url":"https://api.github.com/users/fabiokung/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiokung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiokung/subscriptions","organizations_url":"https://api.github.com/users/fabiokung/orgs","repos_url":"https://api.github.com/users/fabiokung/repos","events_url":"https://api.github.com/users/fabiokung/events{/privacy}","received_events_url":"https://api.github.com/users/fabiokung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabiokung/libcontainer","description":"Linux Containers","fork":true,"url":"https://api.github.com/repos/fabiokung/libcontainer","forks_url":"https://api.github.com/repos/fabiokung/libcontainer/forks","keys_url":"https://api.github.com/repos/fabiokung/libcontainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabiokung/libcontainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabiokung/libcontainer/teams","hooks_url":"https://api.github.com/repos/fabiokung/libcontainer/hooks","issue_events_url":"https://api.github.com/repos/fabiokung/libcontainer/issues/events{/number}","events_url":"https://api.github.com/repos/fabiokung/libcontainer/events","assignees_url":"https://api.github.com/repos/fabiokung/libcontainer/assignees{/user}","branches_url":"https://api.github.com/repos/fabiokung/libcontainer/branches{/branch}","tags_url":"https://api.github.com/repos/fabiokung/libcontainer/tags","blobs_url":"https://api.github.com/repos/fabiokung/libcontainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabiokung/libcontainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabiokung/libcontainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabiokung/libcontainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabiokung/libcontainer/statuses/{sha}","languages_url":"https://api.github.com/repos/fabiokung/libcontainer/languages","stargazers_url":"https://api.github.com/repos/fabiokung/libcontainer/stargazers","contributors_url":"https://api.github.com/repos/fabiokung/libcontainer/contributors","subscribers_url":"https://api.github.com/repos/fabiokung/libcontainer/subscribers","subscription_url":"https://api.github.com/repos/fabiokung/libcontainer/subscription","commits_url":"https://api.github.com/repos/fabiokung/libcontainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabiokung/libcontainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabiokung/libcontainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabiokung/libcontainer/issues/comments/{number}","contents_url":"https://api.github.com/repos/fabiokung/libcontainer/contents/{+path}","compare_url":"https://api.github.com/repos/fabiokung/libcontainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabiokung/libcontainer/merges","archive_url":"https://api.github.com/repos/fabiokung/libcontainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabiokung/libcontainer/downloads","issues_url":"https://api.github.com/repos/fabiokung/libcontainer/issues{/number}","pulls_url":"https://api.github.com/repos/fabiokung/libcontainer/pulls{/number}","milestones_url":"https://api.github.com/repos/fabiokung/libcontainer/milestones{/number}","notifications_url":"https://api.github.com/repos/fabiokung/libcontainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabiokung/libcontainer/labels{/name}","releases_url":"https://api.github.com/repos/fabiokung/libcontainer/releases{/id}","created_at":"2015-01-22T21:26:55Z","updated_at":"2015-02-09T21:53:48Z","pushed_at":"2015-02-09T21:53:48Z","git_url":"git://github.com/fabiokung/libcontainer.git","ssh_url":"git@github.com:fabiokung/libcontainer.git","clone_url":"https://github.com/fabiokung/libcontainer.git","svn_url":"https://github.com/fabiokung/libcontainer","homepage":"http://www.docker.com/","size":1197,"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":"docker:master","ref":"master","sha":"da32455210de558c829f089e8c3a3d1ed8c34a5b","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":15693680,"name":"libcontainer","full_name":"docker/libcontainer","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/libcontainer","description":"Linux Containers","fork":false,"url":"https://api.github.com/repos/docker/libcontainer","forks_url":"https://api.github.com/repos/docker/libcontainer/forks","keys_url":"https://api.github.com/repos/docker/libcontainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/libcontainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/libcontainer/teams","hooks_url":"https://api.github.com/repos/docker/libcontainer/hooks","issue_events_url":"https://api.github.com/repos/docker/libcontainer/issues/events{/number}","events_url":"https://api.github.com/repos/docker/libcontainer/events","assignees_url":"https://api.github.com/repos/docker/libcontainer/assignees{/user}","branches_url":"https://api.github.com/repos/docker/libcontainer/branches{/branch}","tags_url":"https://api.github.com/repos/docker/libcontainer/tags","blobs_url":"https://api.github.com/repos/docker/libcontainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/libcontainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/libcontainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/libcontainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/libcontainer/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/libcontainer/languages","stargazers_url":"https://api.github.com/repos/docker/libcontainer/stargazers","contributors_url":"https://api.github.com/repos/docker/libcontainer/contributors","subscribers_url":"https://api.github.com/repos/docker/libcontainer/subscribers","subscription_url":"https://api.github.com/repos/docker/libcontainer/subscription","commits_url":"https://api.github.com/repos/docker/libcontainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/libcontainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/libcontainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/libcontainer/issues/comments/{number}","contents_url":"https://api.github.com/repos/docker/libcontainer/contents/{+path}","compare_url":"https://api.github.com/repos/docker/libcontainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/libcontainer/merges","archive_url":"https://api.github.com/repos/docker/libcontainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/libcontainer/downloads","issues_url":"https://api.github.com/repos/docker/libcontainer/issues{/number}","pulls_url":"https://api.github.com/repos/docker/libcontainer/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/libcontainer/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/libcontainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/libcontainer/labels{/name}","releases_url":"https://api.github.com/repos/docker/libcontainer/releases{/id}","created_at":"2014-01-07T03:05:05Z","updated_at":"2015-02-20T15:38:31Z","pushed_at":"2015-02-20T00:30:06Z","git_url":"git://github.com/docker/libcontainer.git","ssh_url":"git@github.com:docker/libcontainer.git","clone_url":"https://github.com/docker/libcontainer.git","svn_url":"https://github.com/docker/libcontainer","homepage":"http://www.docker.com/","size":5022,"stargazers_count":684,"watchers_count":684,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":177,"mirror_url":null,"open_issues_count":38,"forks":177,"open_issues":38,"watchers":684,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/libcontainer/pulls/365"},"html":{"href":"https://github.com/docker/libcontainer/pull/365"},"issue":{"href":"https://api.github.com/repos/docker/libcontainer/issues/365"},"comments":{"href":"https://api.github.com/repos/docker/libcontainer/issues/365/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/libcontainer/pulls/365/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/libcontainer/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/docker/libcontainer/pulls/365/commits"},"statuses":{"href":"https://api.github.com/repos/docker/libcontainer/statuses/579161c10b5e32ae58e88fa6869d29fee61275c4"}}}}