{"action":"created","comment":{"url":"https://api.github.com/repos/romana/core/pulls/comments/62283478","id":62283478,"diff_hunk":"@@ -129,21 +149,30 @@ func (ipam *IPAM) legacyAllocateIpByName(input interface{}, ctx common.RestConte\n \t\treturn nil, err\n \t}\n \tfound = false\n-\tvar i int\n-\tfor i = range tenants {\n-\t\tif tenants[i].Name == tenantName {\n-\t\t\tfound = true\n-\t\t\tEndpoint.TenantId = fmt.Sprintf(\"%d\", tenants[i].ID)\n-\t\t\tlog.Printf(\"IPAM: Tenant name %s has ID %s, original %d\\n\", tenantName, Endpoint.TenantId, tenants[i].ID)\n+\tfor _, t := range tenants {\n+\t\tswitch tenantLookupField {\n+\t\tcase \"Name\":\n+\t\t\tif t.Name == tenantParam {","path":"ipam/ipam.go","position":97,"original_position":97,"commit_id":"fbd8eb6edc4d75db863fedca1267d77ceb030970","original_commit_id":"fbd8eb6edc4d75db863fedca1267d77ceb030970","user":{"login":"jbrendel","id":233741,"avatar_url":"https://avatars.githubusercontent.com/u/233741?v=3","gravatar_id":"","url":"https://api.github.com/users/jbrendel","html_url":"https://github.com/jbrendel","followers_url":"https://api.github.com/users/jbrendel/followers","following_url":"https://api.github.com/users/jbrendel/following{/other_user}","gists_url":"https://api.github.com/users/jbrendel/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrendel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrendel/subscriptions","organizations_url":"https://api.github.com/users/jbrendel/orgs","repos_url":"https://api.github.com/users/jbrendel/repos","events_url":"https://api.github.com/users/jbrendel/events{/privacy}","received_events_url":"https://api.github.com/users/jbrendel/received_events","type":"User","site_admin":false},"body":"Is there a Go equivalent to Pythons 'getattr()'? This would allow to replace the entire switch block with one line:\r\n\r\n    if getattr(t, tenantLookupField) == tenantParam:\r\n        found = True\r\n\r\n\r\n","created_at":"2016-05-06T02:46:32Z","updated_at":"2016-05-06T02:46:32Z","html_url":"https://github.com/romana/core/pull/85#discussion_r62283478","pull_request_url":"https://api.github.com/repos/romana/core/pulls/85","_links":{"self":{"href":"https://api.github.com/repos/romana/core/pulls/comments/62283478"},"html":{"href":"https://github.com/romana/core/pull/85#discussion_r62283478"},"pull_request":{"href":"https://api.github.com/repos/romana/core/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/romana/core/pulls/85","id":68959280,"html_url":"https://github.com/romana/core/pull/85","diff_url":"https://github.com/romana/core/pull/85.diff","patch_url":"https://github.com/romana/core/pull/85.patch","issue_url":"https://api.github.com/repos/romana/core/issues/85","number":85,"state":"open","locked":false,"title":"Ipam allocate endpoints","user":{"login":"cgilmour","id":892558,"avatar_url":"https://avatars.githubusercontent.com/u/892558?v=3","gravatar_id":"","url":"https://api.github.com/users/cgilmour","html_url":"https://github.com/cgilmour","followers_url":"https://api.github.com/users/cgilmour/followers","following_url":"https://api.github.com/users/cgilmour/following{/other_user}","gists_url":"https://api.github.com/users/cgilmour/gists{/gist_id}","starred_url":"https://api.github.com/users/cgilmour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgilmour/subscriptions","organizations_url":"https://api.github.com/users/cgilmour/orgs","repos_url":"https://api.github.com/users/cgilmour/repos","events_url":"https://api.github.com/users/cgilmour/events{/privacy}","received_events_url":"https://api.github.com/users/cgilmour/received_events","type":"User","site_admin":false},"body":"This PR changes the behaviour of the \"legacy allocate IP\" path in the IPAM service.\r\nNow, it takes a \"clusterType\" parameter with values either 'kubernetes' or 'openstack'.\r\n\r\nFor kubernetes, it will expect a tenantName parameter, and compare it to the Name field in the tenant data.\r\nFor openstack/devstack, it will expect a tenantID parameter, and compare it to the ExternalID field in the tenant data.","created_at":"2016-05-05T02:20:52Z","updated_at":"2016-05-06T02:46:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c504cc1125993ed981d62961a8bdc8c7889cb7e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/romana/core/pulls/85/commits","review_comments_url":"https://api.github.com/repos/romana/core/pulls/85/comments","review_comment_url":"https://api.github.com/repos/romana/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/romana/core/issues/85/comments","statuses_url":"https://api.github.com/repos/romana/core/statuses/fbd8eb6edc4d75db863fedca1267d77ceb030970","head":{"label":"romana:ipam-allocate-endpoints","ref":"ipam-allocate-endpoints","sha":"fbd8eb6edc4d75db863fedca1267d77ceb030970","user":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"repo":{"id":43855674,"name":"core","full_name":"romana/core","owner":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/romana/core","description":"Romana core components - Micro services written in Go.","fork":false,"url":"https://api.github.com/repos/romana/core","forks_url":"https://api.github.com/repos/romana/core/forks","keys_url":"https://api.github.com/repos/romana/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romana/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romana/core/teams","hooks_url":"https://api.github.com/repos/romana/core/hooks","issue_events_url":"https://api.github.com/repos/romana/core/issues/events{/number}","events_url":"https://api.github.com/repos/romana/core/events","assignees_url":"https://api.github.com/repos/romana/core/assignees{/user}","branches_url":"https://api.github.com/repos/romana/core/branches{/branch}","tags_url":"https://api.github.com/repos/romana/core/tags","blobs_url":"https://api.github.com/repos/romana/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romana/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romana/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/romana/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romana/core/statuses/{sha}","languages_url":"https://api.github.com/repos/romana/core/languages","stargazers_url":"https://api.github.com/repos/romana/core/stargazers","contributors_url":"https://api.github.com/repos/romana/core/contributors","subscribers_url":"https://api.github.com/repos/romana/core/subscribers","subscription_url":"https://api.github.com/repos/romana/core/subscription","commits_url":"https://api.github.com/repos/romana/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/romana/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/romana/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/romana/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/romana/core/contents/{+path}","compare_url":"https://api.github.com/repos/romana/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romana/core/merges","archive_url":"https://api.github.com/repos/romana/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romana/core/downloads","issues_url":"https://api.github.com/repos/romana/core/issues{/number}","pulls_url":"https://api.github.com/repos/romana/core/pulls{/number}","milestones_url":"https://api.github.com/repos/romana/core/milestones{/number}","notifications_url":"https://api.github.com/repos/romana/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romana/core/labels{/name}","releases_url":"https://api.github.com/repos/romana/core/releases{/id}","deployments_url":"https://api.github.com/repos/romana/core/deployments","created_at":"2015-10-08T01:45:35Z","updated_at":"2016-04-13T22:10:15Z","pushed_at":"2016-05-06T00:29:50Z","git_url":"git://github.com/romana/core.git","ssh_url":"git@github.com:romana/core.git","clone_url":"https://github.com/romana/core.git","svn_url":"https://github.com/romana/core","homepage":"","size":646,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":10,"default_branch":"master"}},"base":{"label":"romana:release-v0.8","ref":"release-v0.8","sha":"e46b5a20e103f0c563443104c4fb2ffbd1848a44","user":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"repo":{"id":43855674,"name":"core","full_name":"romana/core","owner":{"login":"romana","id":9849297,"avatar_url":"https://avatars.githubusercontent.com/u/9849297?v=3","gravatar_id":"","url":"https://api.github.com/users/romana","html_url":"https://github.com/romana","followers_url":"https://api.github.com/users/romana/followers","following_url":"https://api.github.com/users/romana/following{/other_user}","gists_url":"https://api.github.com/users/romana/gists{/gist_id}","starred_url":"https://api.github.com/users/romana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romana/subscriptions","organizations_url":"https://api.github.com/users/romana/orgs","repos_url":"https://api.github.com/users/romana/repos","events_url":"https://api.github.com/users/romana/events{/privacy}","received_events_url":"https://api.github.com/users/romana/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/romana/core","description":"Romana core components - Micro services written in Go.","fork":false,"url":"https://api.github.com/repos/romana/core","forks_url":"https://api.github.com/repos/romana/core/forks","keys_url":"https://api.github.com/repos/romana/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romana/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romana/core/teams","hooks_url":"https://api.github.com/repos/romana/core/hooks","issue_events_url":"https://api.github.com/repos/romana/core/issues/events{/number}","events_url":"https://api.github.com/repos/romana/core/events","assignees_url":"https://api.github.com/repos/romana/core/assignees{/user}","branches_url":"https://api.github.com/repos/romana/core/branches{/branch}","tags_url":"https://api.github.com/repos/romana/core/tags","blobs_url":"https://api.github.com/repos/romana/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romana/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romana/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/romana/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romana/core/statuses/{sha}","languages_url":"https://api.github.com/repos/romana/core/languages","stargazers_url":"https://api.github.com/repos/romana/core/stargazers","contributors_url":"https://api.github.com/repos/romana/core/contributors","subscribers_url":"https://api.github.com/repos/romana/core/subscribers","subscription_url":"https://api.github.com/repos/romana/core/subscription","commits_url":"https://api.github.com/repos/romana/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/romana/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/romana/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/romana/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/romana/core/contents/{+path}","compare_url":"https://api.github.com/repos/romana/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romana/core/merges","archive_url":"https://api.github.com/repos/romana/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romana/core/downloads","issues_url":"https://api.github.com/repos/romana/core/issues{/number}","pulls_url":"https://api.github.com/repos/romana/core/pulls{/number}","milestones_url":"https://api.github.com/repos/romana/core/milestones{/number}","notifications_url":"https://api.github.com/repos/romana/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romana/core/labels{/name}","releases_url":"https://api.github.com/repos/romana/core/releases{/id}","deployments_url":"https://api.github.com/repos/romana/core/deployments","created_at":"2015-10-08T01:45:35Z","updated_at":"2016-04-13T22:10:15Z","pushed_at":"2016-05-06T00:29:50Z","git_url":"git://github.com/romana/core.git","ssh_url":"git@github.com:romana/core.git","clone_url":"https://github.com/romana/core.git","svn_url":"https://github.com/romana/core","homepage":"","size":646,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/romana/core/pulls/85"},"html":{"href":"https://github.com/romana/core/pull/85"},"issue":{"href":"https://api.github.com/repos/romana/core/issues/85"},"comments":{"href":"https://api.github.com/repos/romana/core/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/romana/core/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/romana/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/romana/core/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/romana/core/statuses/fbd8eb6edc4d75db863fedca1267d77ceb030970"}}}}