{"action":"created","comment":{"url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/comments/166545965","pull_request_review_id":94622002,"id":166545965,"diff_hunk":"@@ -0,0 +1,95 @@\n+package clusterrolebinding\n+\n+import (\n+\t\"context\"\n+\t\"fmt\"\n+\n+\t\"github.com/giantswarm/apiextensions/pkg/apis/provider/v1alpha1\"\n+\t\"github.com/giantswarm/microerror\"\n+\tapiv1 \"k8s.io/api/rbac/v1beta1\"\n+\tapismetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n+\n+\t\"github.com/giantswarm/kvm-operator/service/kvmconfig/v4/key\"\n+)\n+\n+func (r *Resource) GetDesiredState(ctx context.Context, obj interface{}) (interface{}, error) {\n+\tcustomObject, err := key.ToCustomObject(obj)\n+\tif err != nil {\n+\t\treturn nil, microerror.Mask(err)\n+\t}\n+\n+\tr.logger.LogCtx(ctx, \"debug\", \"computing the new cluster role bindings\")\n+\n+\tclusterRoleBindings, err := r.newClusterRoleBindings(customObject)\n+\tif err != nil {\n+\t\treturn nil, microerror.Mask(err)\n+\t}\n+\n+\tr.logger.LogCtx(ctx, \"debug\", fmt.Sprintf(\"computed the %d new cluster role bindings\", len(clusterRoleBindings)))\n+\n+\treturn clusterRoleBindings, nil\n+}\n+\n+func (r *Resource) newClusterRoleBindings(customObject v1alpha1.KVMConfig) ([]*apiv1.ClusterRoleBinding, error) {\n+\tvar clusterRoleBindings []*apiv1.ClusterRoleBinding\n+\n+\tgeneralClusterRoleBinding := &apiv1.ClusterRoleBinding{\n+\t\tTypeMeta: apismetav1.TypeMeta{\n+\t\t\tKind:       \"ClusterRoleBinding\",\n+\t\t\tAPIVersion: apiv1.GroupName,\n+\t\t},\n+\t\tObjectMeta: apismetav1.ObjectMeta{\n+\t\t\tName: key.ClusterRoleBindingName(customObject),\n+\t\t\tLabels: map[string]string{\n+\t\t\t\t\"app\":         \"kvm-operator\",\n+\t\t\t\t\"cluster-id\":  key.ClusterID(customObject),\n+\t\t\t\t\"customer-id\": key.ClusterCustomer(customObject),","path":"service/kvmconfig/v4/resource/clusterrolebinding/desired.go","position":46,"original_position":46,"commit_id":"e47c8a84cbe6b0c63c6511fad6af8470738ba320","original_commit_id":"e47c8a84cbe6b0c63c6511fad6af8470738ba320","user":{"login":"kopiczko","id":4608994,"avatar_url":"https://avatars0.githubusercontent.com/u/4608994?v=4","gravatar_id":"","url":"https://api.github.com/users/kopiczko","html_url":"https://github.com/kopiczko","followers_url":"https://api.github.com/users/kopiczko/followers","following_url":"https://api.github.com/users/kopiczko/following{/other_user}","gists_url":"https://api.github.com/users/kopiczko/gists{/gist_id}","starred_url":"https://api.github.com/users/kopiczko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kopiczko/subscriptions","organizations_url":"https://api.github.com/users/kopiczko/orgs","repos_url":"https://api.github.com/users/kopiczko/repos","events_url":"https://api.github.com/users/kopiczko/events{/privacy}","received_events_url":"https://api.github.com/users/kopiczko/received_events","type":"User","site_admin":false},"body":"giantswarm.io/cluster-id & giantswarm.io/customer-id\r\nhttps://github.com/giantswarm/fmt/blob/master/kubernetes/annotations_and_labels.md","created_at":"2018-02-07T08:28:43Z","updated_at":"2018-02-07T08:32:15Z","html_url":"https://github.com/giantswarm/kvm-operator/pull/382#discussion_r166545965","pull_request_url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/comments/166545965"},"html":{"href":"https://github.com/giantswarm/kvm-operator/pull/382#discussion_r166545965"},"pull_request":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382"}}},"pull_request":{"url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382","id":167529785,"html_url":"https://github.com/giantswarm/kvm-operator/pull/382","diff_url":"https://github.com/giantswarm/kvm-operator/pull/382.diff","patch_url":"https://github.com/giantswarm/kvm-operator/pull/382.patch","issue_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues/382","number":382,"state":"open","locked":false,"title":"Add cluster role binding in v4 (copy v3)","user":{"login":"pipo02mix","id":892157,"avatar_url":"https://avatars2.githubusercontent.com/u/892157?v=4","gravatar_id":"","url":"https://api.github.com/users/pipo02mix","html_url":"https://github.com/pipo02mix","followers_url":"https://api.github.com/users/pipo02mix/followers","following_url":"https://api.github.com/users/pipo02mix/following{/other_user}","gists_url":"https://api.github.com/users/pipo02mix/gists{/gist_id}","starred_url":"https://api.github.com/users/pipo02mix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipo02mix/subscriptions","organizations_url":"https://api.github.com/users/pipo02mix/orgs","repos_url":"https://api.github.com/users/pipo02mix/repos","events_url":"https://api.github.com/users/pipo02mix/events{/privacy}","received_events_url":"https://api.github.com/users/pipo02mix/received_events","type":"User","site_admin":false},"body":"Towards [#2296](https://github.com/giantswarm/giantswarm/issues/2296)\r\n\r\nWhen a guest cluster is created, kvm operator creates three deployments (worker, master, node-controller) that should have a service account and a role bound to be able to manage resources. Same as cluster role binding v3.","created_at":"2018-02-06T21:09:28Z","updated_at":"2018-02-07T08:32:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0291eab7f6489f17a230beb0fce73cebc30daad5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382/commits","review_comments_url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382/comments","review_comment_url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues/382/comments","statuses_url":"https://api.github.com/repos/giantswarm/kvm-operator/statuses/e47c8a84cbe6b0c63c6511fad6af8470738ba320","head":{"label":"giantswarm:add_role_binding_for_guest_cluster_v4","ref":"add_role_binding_for_guest_cluster_v4","sha":"e47c8a84cbe6b0c63c6511fad6af8470738ba320","user":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars3.githubusercontent.com/u/7556340?v=4","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"repo":{"id":74021543,"name":"kvm-operator","full_name":"giantswarm/kvm-operator","owner":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars3.githubusercontent.com/u/7556340?v=4","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giantswarm/kvm-operator","description":"Handles Kubernetes clusters running on a Kubernetes cluster with workers and masters in KVMs on bare metal","fork":false,"url":"https://api.github.com/repos/giantswarm/kvm-operator","forks_url":"https://api.github.com/repos/giantswarm/kvm-operator/forks","keys_url":"https://api.github.com/repos/giantswarm/kvm-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giantswarm/kvm-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giantswarm/kvm-operator/teams","hooks_url":"https://api.github.com/repos/giantswarm/kvm-operator/hooks","issue_events_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues/events{/number}","events_url":"https://api.github.com/repos/giantswarm/kvm-operator/events","assignees_url":"https://api.github.com/repos/giantswarm/kvm-operator/assignees{/user}","branches_url":"https://api.github.com/repos/giantswarm/kvm-operator/branches{/branch}","tags_url":"https://api.github.com/repos/giantswarm/kvm-operator/tags","blobs_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giantswarm/kvm-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/giantswarm/kvm-operator/languages","stargazers_url":"https://api.github.com/repos/giantswarm/kvm-operator/stargazers","contributors_url":"https://api.github.com/repos/giantswarm/kvm-operator/contributors","subscribers_url":"https://api.github.com/repos/giantswarm/kvm-operator/subscribers","subscription_url":"https://api.github.com/repos/giantswarm/kvm-operator/subscription","commits_url":"https://api.github.com/repos/giantswarm/kvm-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/giantswarm/kvm-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/giantswarm/kvm-operator/contents/{+path}","compare_url":"https://api.github.com/repos/giantswarm/kvm-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giantswarm/kvm-operator/merges","archive_url":"https://api.github.com/repos/giantswarm/kvm-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giantswarm/kvm-operator/downloads","issues_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues{/number}","pulls_url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/giantswarm/kvm-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/giantswarm/kvm-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giantswarm/kvm-operator/labels{/name}","releases_url":"https://api.github.com/repos/giantswarm/kvm-operator/releases{/id}","deployments_url":"https://api.github.com/repos/giantswarm/kvm-operator/deployments","created_at":"2016-11-17T11:40:50Z","updated_at":"2018-02-01T20:45:37Z","pushed_at":"2018-02-06T21:19:25Z","git_url":"git://github.com/giantswarm/kvm-operator.git","ssh_url":"git@github.com:giantswarm/kvm-operator.git","clone_url":"https://github.com/giantswarm/kvm-operator.git","svn_url":"https://github.com/giantswarm/kvm-operator","homepage":"https://giantswarm.io","size":43137,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":4,"open_issues":12,"watchers":9,"default_branch":"master"}},"base":{"label":"giantswarm:master","ref":"master","sha":"294b1c2bd1ec92ee91bd8c352cb4e91dc8f2fd1e","user":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars3.githubusercontent.com/u/7556340?v=4","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"repo":{"id":74021543,"name":"kvm-operator","full_name":"giantswarm/kvm-operator","owner":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars3.githubusercontent.com/u/7556340?v=4","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giantswarm/kvm-operator","description":"Handles Kubernetes clusters running on a Kubernetes cluster with workers and masters in KVMs on bare metal","fork":false,"url":"https://api.github.com/repos/giantswarm/kvm-operator","forks_url":"https://api.github.com/repos/giantswarm/kvm-operator/forks","keys_url":"https://api.github.com/repos/giantswarm/kvm-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giantswarm/kvm-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giantswarm/kvm-operator/teams","hooks_url":"https://api.github.com/repos/giantswarm/kvm-operator/hooks","issue_events_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues/events{/number}","events_url":"https://api.github.com/repos/giantswarm/kvm-operator/events","assignees_url":"https://api.github.com/repos/giantswarm/kvm-operator/assignees{/user}","branches_url":"https://api.github.com/repos/giantswarm/kvm-operator/branches{/branch}","tags_url":"https://api.github.com/repos/giantswarm/kvm-operator/tags","blobs_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giantswarm/kvm-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/giantswarm/kvm-operator/languages","stargazers_url":"https://api.github.com/repos/giantswarm/kvm-operator/stargazers","contributors_url":"https://api.github.com/repos/giantswarm/kvm-operator/contributors","subscribers_url":"https://api.github.com/repos/giantswarm/kvm-operator/subscribers","subscription_url":"https://api.github.com/repos/giantswarm/kvm-operator/subscription","commits_url":"https://api.github.com/repos/giantswarm/kvm-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/giantswarm/kvm-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/giantswarm/kvm-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/giantswarm/kvm-operator/contents/{+path}","compare_url":"https://api.github.com/repos/giantswarm/kvm-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giantswarm/kvm-operator/merges","archive_url":"https://api.github.com/repos/giantswarm/kvm-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giantswarm/kvm-operator/downloads","issues_url":"https://api.github.com/repos/giantswarm/kvm-operator/issues{/number}","pulls_url":"https://api.github.com/repos/giantswarm/kvm-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/giantswarm/kvm-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/giantswarm/kvm-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giantswarm/kvm-operator/labels{/name}","releases_url":"https://api.github.com/repos/giantswarm/kvm-operator/releases{/id}","deployments_url":"https://api.github.com/repos/giantswarm/kvm-operator/deployments","created_at":"2016-11-17T11:40:50Z","updated_at":"2018-02-01T20:45:37Z","pushed_at":"2018-02-06T21:19:25Z","git_url":"git://github.com/giantswarm/kvm-operator.git","ssh_url":"git@github.com:giantswarm/kvm-operator.git","clone_url":"https://github.com/giantswarm/kvm-operator.git","svn_url":"https://github.com/giantswarm/kvm-operator","homepage":"https://giantswarm.io","size":43137,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":4,"open_issues":12,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382"},"html":{"href":"https://github.com/giantswarm/kvm-operator/pull/382"},"issue":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/issues/382"},"comments":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/issues/382/comments"},"review_comments":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382/comments"},"review_comment":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/pulls/382/commits"},"statuses":{"href":"https://api.github.com/repos/giantswarm/kvm-operator/statuses/e47c8a84cbe6b0c63c6511fad6af8470738ba320"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kopiczko"}}