{"action":"created","comment":{"url":"https://api.github.com/repos/banzaicloud/pipeline/pulls/comments/224484804","pull_request_review_id":163864036,"id":224484804,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDQ4NDgwNA==","diff_hunk":"@@ -0,0 +1,113 @@\n+// Copyright © 2018 Banzai Cloud\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 api\n+\n+import (\n+\t\"context\"\n+\t\"net/http\"\n+\n+\t\"github.com/banzaicloud/pipeline/auth\"\n+\t\"github.com/banzaicloud/pipeline/internal/platform/gin/utils\"\n+\t\"github.com/banzaicloud/pipeline/pkg/providers\"\n+\t\"github.com/banzaicloud/pipeline/secret/verify\"\n+\t\"github.com/gin-gonic/gin\"\n+\t\"github.com/sirupsen/logrus\"\n+\t\"google.golang.org/api/cloudresourcemanager/v1\"\n+)\n+\n+type ListProjectsResponse struct {\n+\tProjects []*cloudresourcemanager.Project\n+}\n+\n+// servicesContext encapsulates contextual information required for performing services related operations\n+// Primarily it's intended to be populated with information coming from the Gin context (header, path, request ...)\n+type servicesContext struct {\n+\tlog      logrus.FieldLogger\n+\torgId    uint\n+\tsecretId string\n+}\n+\n+// newServicesCtx\n+func newServicesCtx(orgId uint, secretId string) *servicesContext {\n+\treturn &servicesContext{\n+\t\torgId:    orgId,\n+\t\tsecretId: secretId,\n+\t\tlog:      log.WithFields(logrus.Fields{\"cloud\": \"google\", \"service\": \"projects\"}),\n+\t}\n+}\n+\n+// GetProjects retrieves from the cloud the list of projects visible for the user represented by the secret passed in the header\n+func GetProjects(c *gin.Context) {\n+\n+\torganization := auth.GetCurrentOrganization(c.Request)\n+\n+\tsecretID, ok := ginutils.GetRequiredHeader(c, secretIdHeader)\n+\tif !ok {\n+\t\treturn\n+\t}\n+\tlog.Debugf(\"retrieving projects for orgId: [%d], secretId [%s]\",\n+\t\torganization.ID, secretID)\n+\tservicesCtx := newServicesCtx(organization.ID, secretID)\n+\n+\tcli, err := servicesCtx.HttpClient()\n+\tif err != nil {\n+\t\tlog.WithError(err).Error(\"could not build http client\")\n+\t\tginutils.ReplyWithErrorResponse(c, errorResponseFrom(err))\n+\t}\n+\n+\tprojectsSvc, err := servicesCtx.ProjectsService(cli)\n+\tif err != nil {\n+\t\tlog.WithError(err).Error(\"could not build projects service\")\n+\t\tginutils.ReplyWithErrorResponse(c, errorResponseFrom(err))","path":"api/projects.go","position":73,"original_position":73,"commit_id":"fc853a819536ed5296431681016b05470c3b194c","original_commit_id":"fc853a819536ed5296431681016b05470c3b194c","user":{"login":"colin014","id":6968817,"node_id":"MDQ6VXNlcjY5Njg4MTc=","avatar_url":"https://avatars3.githubusercontent.com/u/6968817?v=4","gravatar_id":"","url":"https://api.github.com/users/colin014","html_url":"https://github.com/colin014","followers_url":"https://api.github.com/users/colin014/followers","following_url":"https://api.github.com/users/colin014/following{/other_user}","gists_url":"https://api.github.com/users/colin014/gists{/gist_id}","starred_url":"https://api.github.com/users/colin014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colin014/subscriptions","organizations_url":"https://api.github.com/users/colin014/orgs","repos_url":"https://api.github.com/users/colin014/repos","events_url":"https://api.github.com/users/colin014/events{/privacy}","received_events_url":"https://api.github.com/users/colin014/received_events","type":"User","site_admin":false},"body":"Same as above","created_at":"2018-10-11T15:03:05Z","updated_at":"2018-10-11T15:03:05Z","html_url":"https://github.com/banzaicloud/pipeline/pull/1184#discussion_r224484804","pull_request_url":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/banzaicloud/pipeline/pulls/comments/224484804"},"html":{"href":"https://github.com/banzaicloud/pipeline/pull/1184#discussion_r224484804"},"pull_request":{"href":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184"}}},"pull_request":{"url":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184","id":222156389,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyMTU2Mzg5","html_url":"https://github.com/banzaicloud/pipeline/pull/1184","diff_url":"https://github.com/banzaicloud/pipeline/pull/1184.diff","patch_url":"https://github.com/banzaicloud/pipeline/pull/1184.patch","issue_url":"https://api.github.com/repos/banzaicloud/pipeline/issues/1184","number":1184,"state":"open","locked":false,"title":"endpoint and API for listing projects for a given secret on google","user":{"login":"lpuskas","id":3776655,"node_id":"MDQ6VXNlcjM3NzY2NTU=","avatar_url":"https://avatars0.githubusercontent.com/u/3776655?v=4","gravatar_id":"","url":"https://api.github.com/users/lpuskas","html_url":"https://github.com/lpuskas","followers_url":"https://api.github.com/users/lpuskas/followers","following_url":"https://api.github.com/users/lpuskas/following{/other_user}","gists_url":"https://api.github.com/users/lpuskas/gists{/gist_id}","starred_url":"https://api.github.com/users/lpuskas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpuskas/subscriptions","organizations_url":"https://api.github.com/users/lpuskas/orgs","repos_url":"https://api.github.com/users/lpuskas/repos","events_url":"https://api.github.com/users/lpuskas/events{/privacy}","received_events_url":"https://api.github.com/users/lpuskas/received_events","type":"User","site_admin":false},"body":"- new endpoint to retrieve google projects visible for a given secret\r\n- extended the openapi spec with the new call\r\n- generated client\r\n\r\nrelates to #1092 ","created_at":"2018-10-11T14:18:34Z","updated_at":"2018-10-11T15:03:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96968de8c04684e9e1e2f0d7d3184b8a4191a862","assignee":null,"assignees":[],"requested_reviewers":[{"login":"sagikazarmark","id":1226384,"node_id":"MDQ6VXNlcjEyMjYzODQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1226384?v=4","gravatar_id":"","url":"https://api.github.com/users/sagikazarmark","html_url":"https://github.com/sagikazarmark","followers_url":"https://api.github.com/users/sagikazarmark/followers","following_url":"https://api.github.com/users/sagikazarmark/following{/other_user}","gists_url":"https://api.github.com/users/sagikazarmark/gists{/gist_id}","starred_url":"https://api.github.com/users/sagikazarmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagikazarmark/subscriptions","organizations_url":"https://api.github.com/users/sagikazarmark/orgs","repos_url":"https://api.github.com/users/sagikazarmark/repos","events_url":"https://api.github.com/users/sagikazarmark/events{/privacy}","received_events_url":"https://api.github.com/users/sagikazarmark/received_events","type":"User","site_admin":false},{"login":"matyix","id":6003104,"node_id":"MDQ6VXNlcjYwMDMxMDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6003104?v=4","gravatar_id":"","url":"https://api.github.com/users/matyix","html_url":"https://github.com/matyix","followers_url":"https://api.github.com/users/matyix/followers","following_url":"https://api.github.com/users/matyix/following{/other_user}","gists_url":"https://api.github.com/users/matyix/gists{/gist_id}","starred_url":"https://api.github.com/users/matyix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matyix/subscriptions","organizations_url":"https://api.github.com/users/matyix/orgs","repos_url":"https://api.github.com/users/matyix/repos","events_url":"https://api.github.com/users/matyix/events{/privacy}","received_events_url":"https://api.github.com/users/matyix/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184/commits","review_comments_url":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184/comments","review_comment_url":"https://api.github.com/repos/banzaicloud/pipeline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/banzaicloud/pipeline/issues/1184/comments","statuses_url":"https://api.github.com/repos/banzaicloud/pipeline/statuses/fc853a819536ed5296431681016b05470c3b194c","head":{"label":"banzaicloud:gcprj","ref":"gcprj","sha":"fc853a819536ed5296431681016b05470c3b194c","user":{"login":"banzaicloud","id":32848483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyODQ4NDgz","avatar_url":"https://avatars2.githubusercontent.com/u/32848483?v=4","gravatar_id":"","url":"https://api.github.com/users/banzaicloud","html_url":"https://github.com/banzaicloud","followers_url":"https://api.github.com/users/banzaicloud/followers","following_url":"https://api.github.com/users/banzaicloud/following{/other_user}","gists_url":"https://api.github.com/users/banzaicloud/gists{/gist_id}","starred_url":"https://api.github.com/users/banzaicloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/banzaicloud/subscriptions","organizations_url":"https://api.github.com/users/banzaicloud/orgs","repos_url":"https://api.github.com/users/banzaicloud/repos","events_url":"https://api.github.com/users/banzaicloud/events{/privacy}","received_events_url":"https://api.github.com/users/banzaicloud/received_events","type":"Organization","site_admin":false},"repo":{"id":108758373,"node_id":"MDEwOlJlcG9zaXRvcnkxMDg3NTgzNzM=","name":"pipeline","full_name":"banzaicloud/pipeline","private":false,"owner":{"login":"banzaicloud","id":32848483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyODQ4NDgz","avatar_url":"https://avatars2.githubusercontent.com/u/32848483?v=4","gravatar_id":"","url":"https://api.github.com/users/banzaicloud","html_url":"https://github.com/banzaicloud","followers_url":"https://api.github.com/users/banzaicloud/followers","following_url":"https://api.github.com/users/banzaicloud/following{/other_user}","gists_url":"https://api.github.com/users/banzaicloud/gists{/gist_id}","starred_url":"https://api.github.com/users/banzaicloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/banzaicloud/subscriptions","organizations_url":"https://api.github.com/users/banzaicloud/orgs","repos_url":"https://api.github.com/users/banzaicloud/repos","events_url":"https://api.github.com/users/banzaicloud/events{/privacy}","received_events_url":"https://api.github.com/users/banzaicloud/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/banzaicloud/pipeline","description":"Pipeline enables developers to go from commit to scale in minutes by turning Kubernetes into a feature rich application platform integrating CI/CD, centralized logging, monitoring, enterprise-grade security and autoscaling.","fork":false,"url":"https://api.github.com/repos/banzaicloud/pipeline","forks_url":"https://api.github.com/repos/banzaicloud/pipeline/forks","keys_url":"https://api.github.com/repos/banzaicloud/pipeline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/banzaicloud/pipeline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/banzaicloud/pipeline/teams","hooks_url":"https://api.github.com/repos/banzaicloud/pipeline/hooks","issue_events_url":"https://api.github.com/repos/banzaicloud/pipeline/issues/events{/number}","events_url":"https://api.github.com/repos/banzaicloud/pipeline/events","assignees_url":"https://api.github.com/repos/banzaicloud/pipeline/assignees{/user}","branches_url":"https://api.github.com/repos/banzaicloud/pipeline/branches{/branch}","tags_url":"https://api.github.com/repos/banzaicloud/pipeline/tags","blobs_url":"https://api.github.com/repos/banzaicloud/pipeline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/banzaicloud/pipeline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/banzaicloud/pipeline/git/refs{/sha}","trees_url":"https://api.github.com/repos/banzaicloud/pipeline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/banzaicloud/pipeline/statuses/{sha}","languages_url":"https://api.github.com/repos/banzaicloud/pipeline/languages","stargazers_url":"https://api.github.com/repos/banzaicloud/pipeline/stargazers","contributors_url":"https://api.github.com/repos/banzaicloud/pipeline/contributors","subscribers_url":"https://api.github.com/repos/banzaicloud/pipeline/subscribers","subscription_url":"https://api.github.com/repos/banzaicloud/pipeline/subscription","commits_url":"https://api.github.com/repos/banzaicloud/pipeline/commits{/sha}","git_commits_url":"https://api.github.com/repos/banzaicloud/pipeline/git/commits{/sha}","comments_url":"https://api.github.com/repos/banzaicloud/pipeline/comments{/number}","issue_comment_url":"https://api.github.com/repos/banzaicloud/pipeline/issues/comments{/number}","contents_url":"https://api.github.com/repos/banzaicloud/pipeline/contents/{+path}","compare_url":"https://api.github.com/repos/banzaicloud/pipeline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/banzaicloud/pipeline/merges","archive_url":"https://api.github.com/repos/banzaicloud/pipeline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/banzaicloud/pipeline/downloads","issues_url":"https://api.github.com/repos/banzaicloud/pipeline/issues{/number}","pulls_url":"https://api.github.com/repos/banzaicloud/pipeline/pulls{/number}","milestones_url":"https://api.github.com/repos/banzaicloud/pipeline/milestones{/number}","notifications_url":"https://api.github.com/repos/banzaicloud/pipeline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/banzaicloud/pipeline/labels{/name}","releases_url":"https://api.github.com/repos/banzaicloud/pipeline/releases{/id}","deployments_url":"https://api.github.com/repos/banzaicloud/pipeline/deployments","created_at":"2017-10-29T18:07:56Z","updated_at":"2018-10-11T13:50:44Z","pushed_at":"2018-10-11T14:29:04Z","git_url":"git://github.com/banzaicloud/pipeline.git","ssh_url":"git@github.com:banzaicloud/pipeline.git","clone_url":"https://github.com/banzaicloud/pipeline.git","svn_url":"https://github.com/banzaicloud/pipeline","homepage":"","size":84692,"stargazers_count":675,"watchers_count":675,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":65,"mirror_url":null,"archived":false,"open_issues_count":54,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":65,"open_issues":54,"watchers":675,"default_branch":"master"}},"base":{"label":"banzaicloud:master","ref":"master","sha":"8160d287b2e57af3a6579ff3afc6d6cb8f5891e7","user":{"login":"banzaicloud","id":32848483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyODQ4NDgz","avatar_url":"https://avatars2.githubusercontent.com/u/32848483?v=4","gravatar_id":"","url":"https://api.github.com/users/banzaicloud","html_url":"https://github.com/banzaicloud","followers_url":"https://api.github.com/users/banzaicloud/followers","following_url":"https://api.github.com/users/banzaicloud/following{/other_user}","gists_url":"https://api.github.com/users/banzaicloud/gists{/gist_id}","starred_url":"https://api.github.com/users/banzaicloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/banzaicloud/subscriptions","organizations_url":"https://api.github.com/users/banzaicloud/orgs","repos_url":"https://api.github.com/users/banzaicloud/repos","events_url":"https://api.github.com/users/banzaicloud/events{/privacy}","received_events_url":"https://api.github.com/users/banzaicloud/received_events","type":"Organization","site_admin":false},"repo":{"id":108758373,"node_id":"MDEwOlJlcG9zaXRvcnkxMDg3NTgzNzM=","name":"pipeline","full_name":"banzaicloud/pipeline","private":false,"owner":{"login":"banzaicloud","id":32848483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyODQ4NDgz","avatar_url":"https://avatars2.githubusercontent.com/u/32848483?v=4","gravatar_id":"","url":"https://api.github.com/users/banzaicloud","html_url":"https://github.com/banzaicloud","followers_url":"https://api.github.com/users/banzaicloud/followers","following_url":"https://api.github.com/users/banzaicloud/following{/other_user}","gists_url":"https://api.github.com/users/banzaicloud/gists{/gist_id}","starred_url":"https://api.github.com/users/banzaicloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/banzaicloud/subscriptions","organizations_url":"https://api.github.com/users/banzaicloud/orgs","repos_url":"https://api.github.com/users/banzaicloud/repos","events_url":"https://api.github.com/users/banzaicloud/events{/privacy}","received_events_url":"https://api.github.com/users/banzaicloud/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/banzaicloud/pipeline","description":"Pipeline enables developers to go from commit to scale in minutes by turning Kubernetes into a feature rich application platform integrating CI/CD, centralized logging, monitoring, enterprise-grade security and autoscaling.","fork":false,"url":"https://api.github.com/repos/banzaicloud/pipeline","forks_url":"https://api.github.com/repos/banzaicloud/pipeline/forks","keys_url":"https://api.github.com/repos/banzaicloud/pipeline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/banzaicloud/pipeline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/banzaicloud/pipeline/teams","hooks_url":"https://api.github.com/repos/banzaicloud/pipeline/hooks","issue_events_url":"https://api.github.com/repos/banzaicloud/pipeline/issues/events{/number}","events_url":"https://api.github.com/repos/banzaicloud/pipeline/events","assignees_url":"https://api.github.com/repos/banzaicloud/pipeline/assignees{/user}","branches_url":"https://api.github.com/repos/banzaicloud/pipeline/branches{/branch}","tags_url":"https://api.github.com/repos/banzaicloud/pipeline/tags","blobs_url":"https://api.github.com/repos/banzaicloud/pipeline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/banzaicloud/pipeline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/banzaicloud/pipeline/git/refs{/sha}","trees_url":"https://api.github.com/repos/banzaicloud/pipeline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/banzaicloud/pipeline/statuses/{sha}","languages_url":"https://api.github.com/repos/banzaicloud/pipeline/languages","stargazers_url":"https://api.github.com/repos/banzaicloud/pipeline/stargazers","contributors_url":"https://api.github.com/repos/banzaicloud/pipeline/contributors","subscribers_url":"https://api.github.com/repos/banzaicloud/pipeline/subscribers","subscription_url":"https://api.github.com/repos/banzaicloud/pipeline/subscription","commits_url":"https://api.github.com/repos/banzaicloud/pipeline/commits{/sha}","git_commits_url":"https://api.github.com/repos/banzaicloud/pipeline/git/commits{/sha}","comments_url":"https://api.github.com/repos/banzaicloud/pipeline/comments{/number}","issue_comment_url":"https://api.github.com/repos/banzaicloud/pipeline/issues/comments{/number}","contents_url":"https://api.github.com/repos/banzaicloud/pipeline/contents/{+path}","compare_url":"https://api.github.com/repos/banzaicloud/pipeline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/banzaicloud/pipeline/merges","archive_url":"https://api.github.com/repos/banzaicloud/pipeline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/banzaicloud/pipeline/downloads","issues_url":"https://api.github.com/repos/banzaicloud/pipeline/issues{/number}","pulls_url":"https://api.github.com/repos/banzaicloud/pipeline/pulls{/number}","milestones_url":"https://api.github.com/repos/banzaicloud/pipeline/milestones{/number}","notifications_url":"https://api.github.com/repos/banzaicloud/pipeline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/banzaicloud/pipeline/labels{/name}","releases_url":"https://api.github.com/repos/banzaicloud/pipeline/releases{/id}","deployments_url":"https://api.github.com/repos/banzaicloud/pipeline/deployments","created_at":"2017-10-29T18:07:56Z","updated_at":"2018-10-11T13:50:44Z","pushed_at":"2018-10-11T14:29:04Z","git_url":"git://github.com/banzaicloud/pipeline.git","ssh_url":"git@github.com:banzaicloud/pipeline.git","clone_url":"https://github.com/banzaicloud/pipeline.git","svn_url":"https://github.com/banzaicloud/pipeline","homepage":"","size":84692,"stargazers_count":675,"watchers_count":675,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":65,"mirror_url":null,"archived":false,"open_issues_count":54,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":65,"open_issues":54,"watchers":675,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184"},"html":{"href":"https://github.com/banzaicloud/pipeline/pull/1184"},"issue":{"href":"https://api.github.com/repos/banzaicloud/pipeline/issues/1184"},"comments":{"href":"https://api.github.com/repos/banzaicloud/pipeline/issues/1184/comments"},"review_comments":{"href":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184/comments"},"review_comment":{"href":"https://api.github.com/repos/banzaicloud/pipeline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/banzaicloud/pipeline/pulls/1184/commits"},"statuses":{"href":"https://api.github.com/repos/banzaicloud/pipeline/statuses/fc853a819536ed5296431681016b05470c3b194c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"colin014"}}