{"action":"created","comment":{"url":"https://api.github.com/repos/cilium/cilium/pulls/comments/115403636","pull_request_review_id":36936994,"id":115403636,"diff_hunk":"@@ -163,82 +164,89 @@ func (d *Daemon) enablePolicyEnforcement() {\n \td.endpointsMU.RUnlock()\n }\n \n-func (d *Daemon) PolicyAdd(path string, node *policy.Node) *apierror.APIError {\n-\tlog.Debugf(\"Policy Add Request: %s %+v\", path, node)\n+// PolicyAdd adds a slice of rules to the policy repository owned by the\n+// daemon.  Policy enforcement is automatically enabled if currently disabled.\n+// Eventual changes in policy rules are propagated to all locally managed\n+// endpoints.\n+func (d *Daemon) PolicyAdd(rules []*api.Rule) *apierror.APIError {\n+\tlog.Debugf(\"Policy Add Request: %+v\", rules)\n \n \t// Enable policy if not already enabled\n \tif !d.conf.Opts.IsEnabled(endpoint.OptionPolicy) {\n \t\td.enablePolicyEnforcement()\n \t}\n \n-\tif policyModified, err := d.policy.Add(path, node); err != nil {\n-\t\treturn apierror.Error(PutPolicyPathFailureCode, err)\n-\t} else if policyModified {\n-\t\tlog.Info(\"New policy imported, regenerating...\")\n-\t\td.TriggerPolicyUpdates([]policy.NumericIdentity{})\n+\tif err := d.policy.AddList(rules); err != nil {\n+\t\treturn apierror.Error(PutPolicyFailureCode, err)\n \t}\n \n+\tlog.Info(\"New policy imported, regenerating...\")\n+\td.TriggerPolicyUpdates([]policy.NumericIdentity{})\n+\n \treturn nil\n }\n \n // PolicyDelete deletes the policy set in the given path from the policy tree.\n // If cover256Sum is set it finds the rule with the respective coverage that\n // rule from the node. If the path's node becomes ruleless it is removed from\n // the tree.\n-func (d *Daemon) PolicyDelete(path, cover256Sum string) *apierror.APIError {\n-\tlog.Debugf(\"Policy Delete Request: %s, cover256Sum %s\", path, cover256Sum)\n+func (d *Daemon) PolicyDelete(labels labels.LabelArray) *apierror.APIError {\n+\t//log.Debugf(\"Policy Delete Request: %s, cover256Sum %s\", path, cover256Sum)\n+\tlog.Debugf(\"Policy Delete Request: %+v\", labels)\n \n-\tif cover256Sum != \"\" && len(cover256Sum) != policy.CoverageSHASize {\n-\t\treturn apierror.New(DeletePolicyPathInvalidCode,\n-\t\t\t\"invalid length of hash, must be %d\", policy.CoverageSHASize)\n-\t}\n+\t//if cover256Sum != \"\" && len(cover256Sum) != policy.CoverageSHASize {\n+\t//\treturn apierror.New(DeleteInvalidCode,\n+\t//\t\t\"invalid length of hash, must be %d\", policy.CoverageSHASize)\n+\t//}\n \n-\tif !d.policy.Delete(path, cover256Sum) {\n-\t\treturn apierror.New(DeletePolicyPathNotFoundCode, \"policy not found\")\n+\tif d.policy.DeleteByLabels(labels) == 0 {\n+\t\treturn apierror.New(DeletePolicyNotFoundCode, \"policy not found\")\n \t}\n \n \td.TriggerPolicyUpdates([]policy.NumericIdentity{})\n \treturn nil\n }\n \n-type deletePolicyPath struct {\n+type deletePolicy struct {\n \tdaemon *Daemon\n }\n \n-func NewDeletePolicyPathHandler(d *Daemon) DeletePolicyPathHandler {\n-\treturn &deletePolicyPath{daemon: d}\n+func NewDeletePolicyHandler(d *Daemon) DeletePolicyHandler {\n+\treturn &deletePolicy{daemon: d}\n }\n \n-func (h *deletePolicyPath) Handle(params DeletePolicyPathParams) middleware.Responder {\n+func (h *deletePolicy) Handle(params DeletePolicyParams) middleware.Responder {\n \td := h.daemon\n-\tif err := d.PolicyDelete(params.Path, \"\"); err != nil {\n-\t\treturn apierror.Error(DeletePolicyPathFailureCode, err)\n+\t// FIXME\n+\tif err := d.PolicyDelete(labels.LabelArray{}); err != nil {\n+\t\treturn apierror.Error(DeletePolicyFailureCode, err)\n \t}\n \n-\treturn NewDeletePolicyPathNoContent()\n+\treturn NewDeletePolicyNoContent()\n }\n \n-type putPolicyPath struct {\n+type putPolicy struct {\n \tdaemon *Daemon\n }\n \n-func NewPutPolicyPathHandler(d *Daemon) PutPolicyPathHandler {\n-\treturn &putPolicyPath{daemon: d}\n+func NewPutPolicyHandler(d *Daemon) PutPolicyHandler {","path":"daemon/policy.go","position":102,"original_position":102,"commit_id":"b14fcfc130082459f22fd6410ddd802fe57be235","original_commit_id":"b14fcfc130082459f22fd6410ddd802fe57be235","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars3.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"exported function NewPutPolicyHandler should have comment or be unexported","created_at":"2017-05-09T04:07:06Z","updated_at":"2017-05-09T04:07:06Z","html_url":"https://github.com/cilium/cilium/pull/670#discussion_r115403636","pull_request_url":"https://api.github.com/repos/cilium/cilium/pulls/670","_links":{"self":{"href":"https://api.github.com/repos/cilium/cilium/pulls/comments/115403636"},"html":{"href":"https://github.com/cilium/cilium/pull/670#discussion_r115403636"},"pull_request":{"href":"https://api.github.com/repos/cilium/cilium/pulls/670"}}},"pull_request":{"url":"https://api.github.com/repos/cilium/cilium/pulls/670","id":119552325,"html_url":"https://github.com/cilium/cilium/pull/670","diff_url":"https://github.com/cilium/cilium/pull/670.diff","patch_url":"https://github.com/cilium/cilium/pull/670.patch","issue_url":"https://api.github.com/repos/cilium/cilium/issues/670","number":670,"state":"open","locked":false,"title":"Policy simplification","user":{"login":"tgraf","id":1417913,"avatar_url":"https://avatars2.githubusercontent.com/u/1417913?v=3","gravatar_id":"","url":"https://api.github.com/users/tgraf","html_url":"https://github.com/tgraf","followers_url":"https://api.github.com/users/tgraf/followers","following_url":"https://api.github.com/users/tgraf/following{/other_user}","gists_url":"https://api.github.com/users/tgraf/gists{/gist_id}","starred_url":"https://api.github.com/users/tgraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgraf/subscriptions","organizations_url":"https://api.github.com/users/tgraf/orgs","repos_url":"https://api.github.com/users/tgraf/repos","events_url":"https://api.github.com/users/tgraf/events{/privacy}","received_events_url":"https://api.github.com/users/tgraf/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-05-08T22:59:00Z","updated_at":"2017-05-09T04:07:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cilium/cilium/pulls/670/commits","review_comments_url":"https://api.github.com/repos/cilium/cilium/pulls/670/comments","review_comment_url":"https://api.github.com/repos/cilium/cilium/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cilium/cilium/issues/670/comments","statuses_url":"https://api.github.com/repos/cilium/cilium/statuses/b14fcfc130082459f22fd6410ddd802fe57be235","head":{"label":"cilium:policy-simplification","ref":"policy-simplification","sha":"b14fcfc130082459f22fd6410ddd802fe57be235","user":{"login":"cilium","id":21054566,"avatar_url":"https://avatars3.githubusercontent.com/u/21054566?v=3","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"repo":{"id":48109239,"name":"cilium","full_name":"cilium/cilium","owner":{"login":"cilium","id":21054566,"avatar_url":"https://avatars3.githubusercontent.com/u/21054566?v=3","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cilium/cilium","description":"Linux Native, HTTP Aware Networking and Security for Containers","fork":false,"url":"https://api.github.com/repos/cilium/cilium","forks_url":"https://api.github.com/repos/cilium/cilium/forks","keys_url":"https://api.github.com/repos/cilium/cilium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cilium/cilium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cilium/cilium/teams","hooks_url":"https://api.github.com/repos/cilium/cilium/hooks","issue_events_url":"https://api.github.com/repos/cilium/cilium/issues/events{/number}","events_url":"https://api.github.com/repos/cilium/cilium/events","assignees_url":"https://api.github.com/repos/cilium/cilium/assignees{/user}","branches_url":"https://api.github.com/repos/cilium/cilium/branches{/branch}","tags_url":"https://api.github.com/repos/cilium/cilium/tags","blobs_url":"https://api.github.com/repos/cilium/cilium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cilium/cilium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cilium/cilium/git/refs{/sha}","trees_url":"https://api.github.com/repos/cilium/cilium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cilium/cilium/statuses/{sha}","languages_url":"https://api.github.com/repos/cilium/cilium/languages","stargazers_url":"https://api.github.com/repos/cilium/cilium/stargazers","contributors_url":"https://api.github.com/repos/cilium/cilium/contributors","subscribers_url":"https://api.github.com/repos/cilium/cilium/subscribers","subscription_url":"https://api.github.com/repos/cilium/cilium/subscription","commits_url":"https://api.github.com/repos/cilium/cilium/commits{/sha}","git_commits_url":"https://api.github.com/repos/cilium/cilium/git/commits{/sha}","comments_url":"https://api.github.com/repos/cilium/cilium/comments{/number}","issue_comment_url":"https://api.github.com/repos/cilium/cilium/issues/comments{/number}","contents_url":"https://api.github.com/repos/cilium/cilium/contents/{+path}","compare_url":"https://api.github.com/repos/cilium/cilium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cilium/cilium/merges","archive_url":"https://api.github.com/repos/cilium/cilium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cilium/cilium/downloads","issues_url":"https://api.github.com/repos/cilium/cilium/issues{/number}","pulls_url":"https://api.github.com/repos/cilium/cilium/pulls{/number}","milestones_url":"https://api.github.com/repos/cilium/cilium/milestones{/number}","notifications_url":"https://api.github.com/repos/cilium/cilium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cilium/cilium/labels{/name}","releases_url":"https://api.github.com/repos/cilium/cilium/releases{/id}","deployments_url":"https://api.github.com/repos/cilium/cilium/deployments","created_at":"2015-12-16T12:33:31Z","updated_at":"2017-05-08T15:39:23Z","pushed_at":"2017-05-09T04:06:52Z","git_url":"git://github.com/cilium/cilium.git","ssh_url":"git@github.com:cilium/cilium.git","clone_url":"https://github.com/cilium/cilium.git","svn_url":"https://github.com/cilium/cilium","homepage":"","size":26890,"stargazers_count":525,"watchers_count":525,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":52,"mirror_url":null,"open_issues_count":77,"forks":52,"open_issues":77,"watchers":525,"default_branch":"master"}},"base":{"label":"cilium:master","ref":"master","sha":"3dd63a5aeff173448cf9bfc3112901344e4909ce","user":{"login":"cilium","id":21054566,"avatar_url":"https://avatars3.githubusercontent.com/u/21054566?v=3","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"repo":{"id":48109239,"name":"cilium","full_name":"cilium/cilium","owner":{"login":"cilium","id":21054566,"avatar_url":"https://avatars3.githubusercontent.com/u/21054566?v=3","gravatar_id":"","url":"https://api.github.com/users/cilium","html_url":"https://github.com/cilium","followers_url":"https://api.github.com/users/cilium/followers","following_url":"https://api.github.com/users/cilium/following{/other_user}","gists_url":"https://api.github.com/users/cilium/gists{/gist_id}","starred_url":"https://api.github.com/users/cilium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cilium/subscriptions","organizations_url":"https://api.github.com/users/cilium/orgs","repos_url":"https://api.github.com/users/cilium/repos","events_url":"https://api.github.com/users/cilium/events{/privacy}","received_events_url":"https://api.github.com/users/cilium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cilium/cilium","description":"Linux Native, HTTP Aware Networking and Security for Containers","fork":false,"url":"https://api.github.com/repos/cilium/cilium","forks_url":"https://api.github.com/repos/cilium/cilium/forks","keys_url":"https://api.github.com/repos/cilium/cilium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cilium/cilium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cilium/cilium/teams","hooks_url":"https://api.github.com/repos/cilium/cilium/hooks","issue_events_url":"https://api.github.com/repos/cilium/cilium/issues/events{/number}","events_url":"https://api.github.com/repos/cilium/cilium/events","assignees_url":"https://api.github.com/repos/cilium/cilium/assignees{/user}","branches_url":"https://api.github.com/repos/cilium/cilium/branches{/branch}","tags_url":"https://api.github.com/repos/cilium/cilium/tags","blobs_url":"https://api.github.com/repos/cilium/cilium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cilium/cilium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cilium/cilium/git/refs{/sha}","trees_url":"https://api.github.com/repos/cilium/cilium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cilium/cilium/statuses/{sha}","languages_url":"https://api.github.com/repos/cilium/cilium/languages","stargazers_url":"https://api.github.com/repos/cilium/cilium/stargazers","contributors_url":"https://api.github.com/repos/cilium/cilium/contributors","subscribers_url":"https://api.github.com/repos/cilium/cilium/subscribers","subscription_url":"https://api.github.com/repos/cilium/cilium/subscription","commits_url":"https://api.github.com/repos/cilium/cilium/commits{/sha}","git_commits_url":"https://api.github.com/repos/cilium/cilium/git/commits{/sha}","comments_url":"https://api.github.com/repos/cilium/cilium/comments{/number}","issue_comment_url":"https://api.github.com/repos/cilium/cilium/issues/comments{/number}","contents_url":"https://api.github.com/repos/cilium/cilium/contents/{+path}","compare_url":"https://api.github.com/repos/cilium/cilium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cilium/cilium/merges","archive_url":"https://api.github.com/repos/cilium/cilium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cilium/cilium/downloads","issues_url":"https://api.github.com/repos/cilium/cilium/issues{/number}","pulls_url":"https://api.github.com/repos/cilium/cilium/pulls{/number}","milestones_url":"https://api.github.com/repos/cilium/cilium/milestones{/number}","notifications_url":"https://api.github.com/repos/cilium/cilium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cilium/cilium/labels{/name}","releases_url":"https://api.github.com/repos/cilium/cilium/releases{/id}","deployments_url":"https://api.github.com/repos/cilium/cilium/deployments","created_at":"2015-12-16T12:33:31Z","updated_at":"2017-05-08T15:39:23Z","pushed_at":"2017-05-09T04:06:52Z","git_url":"git://github.com/cilium/cilium.git","ssh_url":"git@github.com:cilium/cilium.git","clone_url":"https://github.com/cilium/cilium.git","svn_url":"https://github.com/cilium/cilium","homepage":"","size":26890,"stargazers_count":525,"watchers_count":525,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":52,"mirror_url":null,"open_issues_count":77,"forks":52,"open_issues":77,"watchers":525,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cilium/cilium/pulls/670"},"html":{"href":"https://github.com/cilium/cilium/pull/670"},"issue":{"href":"https://api.github.com/repos/cilium/cilium/issues/670"},"comments":{"href":"https://api.github.com/repos/cilium/cilium/issues/670/comments"},"review_comments":{"href":"https://api.github.com/repos/cilium/cilium/pulls/670/comments"},"review_comment":{"href":"https://api.github.com/repos/cilium/cilium/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cilium/cilium/pulls/670/commits"},"statuses":{"href":"https://api.github.com/repos/cilium/cilium/statuses/b14fcfc130082459f22fd6410ddd802fe57be235"}}}}
{"actor":{"display_login":"houndci-bot"}}