{"action":"created","comment":{"url":"https://api.github.com/repos/supergiant/supergiant/pulls/comments/194090623","pull_request_review_id":127203358,"id":194090623,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDA5MDYyMw==","diff_hunk":"@@ -1,92 +1,171 @@\n package kube\n \n import (\n+\t\"bytes\"\n \t\"context\"\n \t\"encoding/json\"\n \n-\t\"bytes\"\n-\n \t\"github.com/pkg/errors\"\n \t\"github.com/sirupsen/logrus\"\n \t\"github.com/supergiant/supergiant/pkg/storage\"\n+\t\"k8s.io/apimachinery/pkg/runtime/schema\"\n+\t\"k8s.io/client-go/discovery\"\n+\t\"k8s.io/client-go/rest\"\n )\n \n const prefix = \"/supergiant/kube/\"\n \n+// Service manages kubernetes clusters.\n type Service struct {\n-\trepository storage.Interface\n+\tdiscoveryClientFn func(k *Kube) (*discovery.DiscoveryClient, error)\n+\tclientForGroupFn  func(k *Kube, gv schema.GroupVersion) (rest.Interface, error)\n+\n+\tstorage storage.Interface\n }\n \n-func (s *Service) CreateKube(ctx context.Context, kube *Kube) (*Kube, error) {\n-\tlogrus.Debug(\"kube.Service.CreateKube start\")\n-\t//TODO VALIDATION\n-\traw, err := json.Marshal(kube)\n+// NewService constructs a Service.\n+func NewService(s storage.Interface) *Service {\n+\treturn &Service{\n+\t\tclientForGroupFn:  restClientForGroupVersion,\n+\t\tdiscoveryClientFn: discoveryClient,\n+\t\tstorage:           s,\n+\t}\n+}\n+\n+// Create stores a kube in the provided storage.\n+func (s *Service) CreateKube(ctx context.Context, k *Kube) (*Kube, error) {\n+\traw, err := json.Marshal(k)\n \tif err != nil {\n-\t\treturn nil, errors.WithStack(err)\n+\t\treturn nil, errors.Wrap(err, \"marshal\")\n \t}\n-\terr = s.repository.Put(ctx, prefix, kube.Name, raw)\n+\n+\terr = s.storage.Put(ctx, prefix, k.Name, raw)\n \tif err != nil {\n-\t\treturn nil, err\n+\t\treturn nil, errors.Wrap(err, \"storage\")","path":"internal/kube/service.go","position":54,"original_position":54,"commit_id":"a455c985ed2dfdf946c8b107f67e80d74d5a184f","original_commit_id":"a455c985ed2dfdf946c8b107f67e80d74d5a184f","user":{"login":"yegorch","id":1738270,"node_id":"MDQ6VXNlcjE3MzgyNzA=","avatar_url":"https://avatars3.githubusercontent.com/u/1738270?v=4","gravatar_id":"","url":"https://api.github.com/users/yegorch","html_url":"https://github.com/yegorch","followers_url":"https://api.github.com/users/yegorch/followers","following_url":"https://api.github.com/users/yegorch/following{/other_user}","gists_url":"https://api.github.com/users/yegorch/gists{/gist_id}","starred_url":"https://api.github.com/users/yegorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yegorch/subscriptions","organizations_url":"https://api.github.com/users/yegorch/orgs","repos_url":"https://api.github.com/users/yegorch/repos","events_url":"https://api.github.com/users/yegorch/events{/privacy}","received_events_url":"https://api.github.com/users/yegorch/received_events","type":"User","site_admin":false},"body":"Nice error message - \"storage\" ","created_at":"2018-06-08T15:14:29Z","updated_at":"2018-06-08T15:14:29Z","html_url":"https://github.com/supergiant/supergiant/pull/520#discussion_r194090623","pull_request_url":"https://api.github.com/repos/supergiant/supergiant/pulls/520","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/supergiant/supergiant/pulls/comments/194090623"},"html":{"href":"https://github.com/supergiant/supergiant/pull/520#discussion_r194090623"},"pull_request":{"href":"https://api.github.com/repos/supergiant/supergiant/pulls/520"}}},"pull_request":{"url":"https://api.github.com/repos/supergiant/supergiant/pulls/520","id":193616569,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzNjE2NTY5","html_url":"https://github.com/supergiant/supergiant/pull/520","diff_url":"https://github.com/supergiant/supergiant/pull/520.diff","patch_url":"https://github.com/supergiant/supergiant/pull/520.patch","issue_url":"https://api.github.com/repos/supergiant/supergiant/issues/520","number":520,"state":"open","locked":false,"title":"Extend a kube service: add proxy getter for kubernetes resources. ","user":{"login":"saheienko","id":26225544,"node_id":"MDQ6VXNlcjI2MjI1NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/26225544?v=4","gravatar_id":"","url":"https://api.github.com/users/saheienko","html_url":"https://github.com/saheienko","followers_url":"https://api.github.com/users/saheienko/followers","following_url":"https://api.github.com/users/saheienko/following{/other_user}","gists_url":"https://api.github.com/users/saheienko/gists{/gist_id}","starred_url":"https://api.github.com/users/saheienko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saheienko/subscriptions","organizations_url":"https://api.github.com/users/saheienko/orgs","repos_url":"https://api.github.com/users/saheienko/repos","events_url":"https://api.github.com/users/saheienko/events{/privacy}","received_events_url":"https://api.github.com/users/saheienko/received_events","type":"User","site_admin":false},"body":"This change extends a functionality of a supergiant server.\r\nIt will be possible to:\r\n- list all supported kubernetes resources;\r\n- retrieve filtered list of the specified resources.","created_at":"2018-06-08T13:37:28Z","updated_at":"2018-06-08T15:14:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c96e3f56dae8cc35df7d76f7b2cd3a52feab7eab","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/supergiant/supergiant/pulls/520/commits","review_comments_url":"https://api.github.com/repos/supergiant/supergiant/pulls/520/comments","review_comment_url":"https://api.github.com/repos/supergiant/supergiant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/supergiant/supergiant/issues/520/comments","statuses_url":"https://api.github.com/repos/supergiant/supergiant/statuses/a455c985ed2dfdf946c8b107f67e80d74d5a184f","head":{"label":"saheienko:kube_proxy","ref":"kube_proxy","sha":"a455c985ed2dfdf946c8b107f67e80d74d5a184f","user":{"login":"saheienko","id":26225544,"node_id":"MDQ6VXNlcjI2MjI1NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/26225544?v=4","gravatar_id":"","url":"https://api.github.com/users/saheienko","html_url":"https://github.com/saheienko","followers_url":"https://api.github.com/users/saheienko/followers","following_url":"https://api.github.com/users/saheienko/following{/other_user}","gists_url":"https://api.github.com/users/saheienko/gists{/gist_id}","starred_url":"https://api.github.com/users/saheienko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saheienko/subscriptions","organizations_url":"https://api.github.com/users/saheienko/orgs","repos_url":"https://api.github.com/users/saheienko/repos","events_url":"https://api.github.com/users/saheienko/events{/privacy}","received_events_url":"https://api.github.com/users/saheienko/received_events","type":"User","site_admin":false},"repo":{"id":132445753,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI0NDU3NTM=","name":"supergiant","full_name":"saheienko/supergiant","owner":{"login":"saheienko","id":26225544,"node_id":"MDQ6VXNlcjI2MjI1NTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/26225544?v=4","gravatar_id":"","url":"https://api.github.com/users/saheienko","html_url":"https://github.com/saheienko","followers_url":"https://api.github.com/users/saheienko/followers","following_url":"https://api.github.com/users/saheienko/following{/other_user}","gists_url":"https://api.github.com/users/saheienko/gists{/gist_id}","starred_url":"https://api.github.com/users/saheienko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saheienko/subscriptions","organizations_url":"https://api.github.com/users/saheienko/orgs","repos_url":"https://api.github.com/users/saheienko/repos","events_url":"https://api.github.com/users/saheienko/events{/privacy}","received_events_url":"https://api.github.com/users/saheienko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/saheienko/supergiant","description":"Automatically scale hardware and easily run stateful applications using Kubernetes.","fork":true,"url":"https://api.github.com/repos/saheienko/supergiant","forks_url":"https://api.github.com/repos/saheienko/supergiant/forks","keys_url":"https://api.github.com/repos/saheienko/supergiant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saheienko/supergiant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saheienko/supergiant/teams","hooks_url":"https://api.github.com/repos/saheienko/supergiant/hooks","issue_events_url":"https://api.github.com/repos/saheienko/supergiant/issues/events{/number}","events_url":"https://api.github.com/repos/saheienko/supergiant/events","assignees_url":"https://api.github.com/repos/saheienko/supergiant/assignees{/user}","branches_url":"https://api.github.com/repos/saheienko/supergiant/branches{/branch}","tags_url":"https://api.github.com/repos/saheienko/supergiant/tags","blobs_url":"https://api.github.com/repos/saheienko/supergiant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saheienko/supergiant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saheienko/supergiant/git/refs{/sha}","trees_url":"https://api.github.com/repos/saheienko/supergiant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saheienko/supergiant/statuses/{sha}","languages_url":"https://api.github.com/repos/saheienko/supergiant/languages","stargazers_url":"https://api.github.com/repos/saheienko/supergiant/stargazers","contributors_url":"https://api.github.com/repos/saheienko/supergiant/contributors","subscribers_url":"https://api.github.com/repos/saheienko/supergiant/subscribers","subscription_url":"https://api.github.com/repos/saheienko/supergiant/subscription","commits_url":"https://api.github.com/repos/saheienko/supergiant/commits{/sha}","git_commits_url":"https://api.github.com/repos/saheienko/supergiant/git/commits{/sha}","comments_url":"https://api.github.com/repos/saheienko/supergiant/comments{/number}","issue_comment_url":"https://api.github.com/repos/saheienko/supergiant/issues/comments{/number}","contents_url":"https://api.github.com/repos/saheienko/supergiant/contents/{+path}","compare_url":"https://api.github.com/repos/saheienko/supergiant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saheienko/supergiant/merges","archive_url":"https://api.github.com/repos/saheienko/supergiant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saheienko/supergiant/downloads","issues_url":"https://api.github.com/repos/saheienko/supergiant/issues{/number}","pulls_url":"https://api.github.com/repos/saheienko/supergiant/pulls{/number}","milestones_url":"https://api.github.com/repos/saheienko/supergiant/milestones{/number}","notifications_url":"https://api.github.com/repos/saheienko/supergiant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saheienko/supergiant/labels{/name}","releases_url":"https://api.github.com/repos/saheienko/supergiant/releases{/id}","deployments_url":"https://api.github.com/repos/saheienko/supergiant/deployments","created_at":"2018-05-07T10:37:07Z","updated_at":"2018-06-05T09:09:39Z","pushed_at":"2018-06-08T13:57:01Z","git_url":"git://github.com/saheienko/supergiant.git","ssh_url":"git@github.com:saheienko/supergiant.git","clone_url":"https://github.com/saheienko/supergiant.git","svn_url":"https://github.com/saheienko/supergiant","homepage":"https://supergiant.io/","size":25599,"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,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"supergiant:master","ref":"master","sha":"c5c6a8cad852627a1466b3a34243fadf250ff5e6","user":{"login":"supergiant","id":17504253,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NTA0MjUz","avatar_url":"https://avatars0.githubusercontent.com/u/17504253?v=4","gravatar_id":"","url":"https://api.github.com/users/supergiant","html_url":"https://github.com/supergiant","followers_url":"https://api.github.com/users/supergiant/followers","following_url":"https://api.github.com/users/supergiant/following{/other_user}","gists_url":"https://api.github.com/users/supergiant/gists{/gist_id}","starred_url":"https://api.github.com/users/supergiant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supergiant/subscriptions","organizations_url":"https://api.github.com/users/supergiant/orgs","repos_url":"https://api.github.com/users/supergiant/repos","events_url":"https://api.github.com/users/supergiant/events{/privacy}","received_events_url":"https://api.github.com/users/supergiant/received_events","type":"Organization","site_admin":false},"repo":{"id":52634092,"node_id":"MDEwOlJlcG9zaXRvcnk1MjYzNDA5Mg==","name":"supergiant","full_name":"supergiant/supergiant","owner":{"login":"supergiant","id":17504253,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NTA0MjUz","avatar_url":"https://avatars0.githubusercontent.com/u/17504253?v=4","gravatar_id":"","url":"https://api.github.com/users/supergiant","html_url":"https://github.com/supergiant","followers_url":"https://api.github.com/users/supergiant/followers","following_url":"https://api.github.com/users/supergiant/following{/other_user}","gists_url":"https://api.github.com/users/supergiant/gists{/gist_id}","starred_url":"https://api.github.com/users/supergiant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supergiant/subscriptions","organizations_url":"https://api.github.com/users/supergiant/orgs","repos_url":"https://api.github.com/users/supergiant/repos","events_url":"https://api.github.com/users/supergiant/events{/privacy}","received_events_url":"https://api.github.com/users/supergiant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/supergiant/supergiant","description":"Automatically scale hardware and easily run stateful applications using Kubernetes.","fork":false,"url":"https://api.github.com/repos/supergiant/supergiant","forks_url":"https://api.github.com/repos/supergiant/supergiant/forks","keys_url":"https://api.github.com/repos/supergiant/supergiant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/supergiant/supergiant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/supergiant/supergiant/teams","hooks_url":"https://api.github.com/repos/supergiant/supergiant/hooks","issue_events_url":"https://api.github.com/repos/supergiant/supergiant/issues/events{/number}","events_url":"https://api.github.com/repos/supergiant/supergiant/events","assignees_url":"https://api.github.com/repos/supergiant/supergiant/assignees{/user}","branches_url":"https://api.github.com/repos/supergiant/supergiant/branches{/branch}","tags_url":"https://api.github.com/repos/supergiant/supergiant/tags","blobs_url":"https://api.github.com/repos/supergiant/supergiant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/supergiant/supergiant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/supergiant/supergiant/git/refs{/sha}","trees_url":"https://api.github.com/repos/supergiant/supergiant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/supergiant/supergiant/statuses/{sha}","languages_url":"https://api.github.com/repos/supergiant/supergiant/languages","stargazers_url":"https://api.github.com/repos/supergiant/supergiant/stargazers","contributors_url":"https://api.github.com/repos/supergiant/supergiant/contributors","subscribers_url":"https://api.github.com/repos/supergiant/supergiant/subscribers","subscription_url":"https://api.github.com/repos/supergiant/supergiant/subscription","commits_url":"https://api.github.com/repos/supergiant/supergiant/commits{/sha}","git_commits_url":"https://api.github.com/repos/supergiant/supergiant/git/commits{/sha}","comments_url":"https://api.github.com/repos/supergiant/supergiant/comments{/number}","issue_comment_url":"https://api.github.com/repos/supergiant/supergiant/issues/comments{/number}","contents_url":"https://api.github.com/repos/supergiant/supergiant/contents/{+path}","compare_url":"https://api.github.com/repos/supergiant/supergiant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/supergiant/supergiant/merges","archive_url":"https://api.github.com/repos/supergiant/supergiant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/supergiant/supergiant/downloads","issues_url":"https://api.github.com/repos/supergiant/supergiant/issues{/number}","pulls_url":"https://api.github.com/repos/supergiant/supergiant/pulls{/number}","milestones_url":"https://api.github.com/repos/supergiant/supergiant/milestones{/number}","notifications_url":"https://api.github.com/repos/supergiant/supergiant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/supergiant/supergiant/labels{/name}","releases_url":"https://api.github.com/repos/supergiant/supergiant/releases{/id}","deployments_url":"https://api.github.com/repos/supergiant/supergiant/deployments","created_at":"2016-02-26T21:32:33Z","updated_at":"2018-06-05T21:19:55Z","pushed_at":"2018-06-08T15:03:24Z","git_url":"git://github.com/supergiant/supergiant.git","ssh_url":"git@github.com:supergiant/supergiant.git","clone_url":"https://github.com/supergiant/supergiant.git","svn_url":"https://github.com/supergiant/supergiant","homepage":"https://supergiant.io/","size":11766,"stargazers_count":564,"watchers_count":564,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"archived":false,"open_issues_count":45,"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":49,"open_issues":45,"watchers":564,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/supergiant/supergiant/pulls/520"},"html":{"href":"https://github.com/supergiant/supergiant/pull/520"},"issue":{"href":"https://api.github.com/repos/supergiant/supergiant/issues/520"},"comments":{"href":"https://api.github.com/repos/supergiant/supergiant/issues/520/comments"},"review_comments":{"href":"https://api.github.com/repos/supergiant/supergiant/pulls/520/comments"},"review_comment":{"href":"https://api.github.com/repos/supergiant/supergiant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/supergiant/supergiant/pulls/520/commits"},"statuses":{"href":"https://api.github.com/repos/supergiant/supergiant/statuses/a455c985ed2dfdf946c8b107f67e80d74d5a184f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"yegorch"}}