{"action":"created","comment":{"url":"https://api.github.com/repos/google/nel-collector/pulls/comments/183494243","pull_request_review_id":114503328,"id":183494243,"diff_hunk":"@@ -0,0 +1,112 @@\n+// Copyright 2018 Google LLC\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+//     https://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 collector\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/BurntSushi/toml\"\n+)\n+\n+// LoadFromConfig loads pipeline processors based on the contents of a TOML\n+// configuration file, and adds them to the pipeline.\n+//\n+// The configuration must have sections named `processor`, each of which defines\n+// one processor that should be added to the pipeline.  For instance, this\n+// configuration could look like:\n+//\n+//     [[processor]]\n+//     type = \"KeepNelReports\"\n+//\n+//     [[processor]]\n+//     type = \"DumpReportsAsCLF\"\n+//     use_utc = true\n+//\n+// The `type` field of each element identifies which kind of processor to add;\n+// any additional fields let you specify any processor-specific configuration.\n+func (p *Pipeline) LoadFromConfig(configBytes []byte) error {\n+\n+\tvar config struct {\n+\t\tProcessors []toml.Primitive `toml:\"processor\"`\n+\t}\n+\terr := toml.Unmarshal(configBytes, &config)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Invalid NEL configuration\")\n+\t}\n+\n+\tif config.Processors == nil {\n+\t\treturn fmt.Errorf(\"NEL configuration missing `processors`\")\n+\t}\n+\n+\tif len(config.Processors) == 0 {\n+\t\treturn fmt.Errorf(\"NEL configuration `processors` array must be non-empty\")\n+\t}\n+\n+\tfor idx, processorPrimitive := range config.Processors {\n+\t\tvar processorConfig struct {\n+\t\t\tType string `toml:\"type\"`\n+\t\t}\n+\t\terr := toml.PrimitiveDecode(processorPrimitive, &processorConfig)\n+\t\tif err != nil {\n+\t\t\treturn fmt.Errorf(\"Processor config 0 must be an object\")","path":"pkg/collector/config.go","position":63,"original_position":63,"commit_id":"03da17a68866407832f05b7639339f8222f5987a","original_commit_id":"03da17a68866407832f05b7639339f8222f5987a","user":{"login":"sburnett","id":370425,"avatar_url":"https://avatars1.githubusercontent.com/u/370425?v=4","gravatar_id":"","url":"https://api.github.com/users/sburnett","html_url":"https://github.com/sburnett","followers_url":"https://api.github.com/users/sburnett/followers","following_url":"https://api.github.com/users/sburnett/following{/other_user}","gists_url":"https://api.github.com/users/sburnett/gists{/gist_id}","starred_url":"https://api.github.com/users/sburnett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sburnett/subscriptions","organizations_url":"https://api.github.com/users/sburnett/orgs","repos_url":"https://api.github.com/users/sburnett/repos","events_url":"https://api.github.com/users/sburnett/events{/privacy}","received_events_url":"https://api.github.com/users/sburnett/received_events","type":"User","site_admin":false},"body":"Is this the only reason that err != nil? Or should you pass along err as well?","created_at":"2018-04-23T18:28:48Z","updated_at":"2018-04-23T18:32:53Z","html_url":"https://github.com/google/nel-collector/pull/21#discussion_r183494243","pull_request_url":"https://api.github.com/repos/google/nel-collector/pulls/21","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/google/nel-collector/pulls/comments/183494243"},"html":{"href":"https://github.com/google/nel-collector/pull/21#discussion_r183494243"},"pull_request":{"href":"https://api.github.com/repos/google/nel-collector/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/google/nel-collector/pulls/21","id":181866725,"html_url":"https://github.com/google/nel-collector/pull/21","diff_url":"https://github.com/google/nel-collector/pull/21.diff","patch_url":"https://github.com/google/nel-collector/pull/21.patch","issue_url":"https://api.github.com/repos/google/nel-collector/issues/21","number":21,"state":"open","locked":false,"title":"Use configuration file to define report processors","user":{"login":"dcreager","id":7499,"avatar_url":"https://avatars2.githubusercontent.com/u/7499?v=4","gravatar_id":"","url":"https://api.github.com/users/dcreager","html_url":"https://github.com/dcreager","followers_url":"https://api.github.com/users/dcreager/followers","following_url":"https://api.github.com/users/dcreager/following{/other_user}","gists_url":"https://api.github.com/users/dcreager/gists{/gist_id}","starred_url":"https://api.github.com/users/dcreager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcreager/subscriptions","organizations_url":"https://api.github.com/users/dcreager/orgs","repos_url":"https://api.github.com/users/dcreager/repos","events_url":"https://api.github.com/users/dcreager/events{/privacy}","received_events_url":"https://api.github.com/users/dcreager/received_events","type":"User","site_admin":false},"body":"We're going to use TOML as the syntax.  You'll add a top-level `processor` clause for each processor you want to instantiate.  The `type` element determines which kind of processor to instantiate, and the processor's loader function can use any other elements to configure the new processor.\r\n\r\nThis patch also adds a new test helper function that instantiates the pipeline to be tested using a configuration string.  Each of the per-processor test cases is now really clean and simple.","created_at":"2018-04-16T13:48:25Z","updated_at":"2018-04-23T18:32:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"883412609ccb97ff52f7ceb228e29d8a469e81e5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/nel-collector/pulls/21/commits","review_comments_url":"https://api.github.com/repos/google/nel-collector/pulls/21/comments","review_comment_url":"https://api.github.com/repos/google/nel-collector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/nel-collector/issues/21/comments","statuses_url":"https://api.github.com/repos/google/nel-collector/statuses/03da17a68866407832f05b7639339f8222f5987a","head":{"label":"dcreager:config","ref":"config","sha":"03da17a68866407832f05b7639339f8222f5987a","user":{"login":"dcreager","id":7499,"avatar_url":"https://avatars2.githubusercontent.com/u/7499?v=4","gravatar_id":"","url":"https://api.github.com/users/dcreager","html_url":"https://github.com/dcreager","followers_url":"https://api.github.com/users/dcreager/followers","following_url":"https://api.github.com/users/dcreager/following{/other_user}","gists_url":"https://api.github.com/users/dcreager/gists{/gist_id}","starred_url":"https://api.github.com/users/dcreager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcreager/subscriptions","organizations_url":"https://api.github.com/users/dcreager/orgs","repos_url":"https://api.github.com/users/dcreager/repos","events_url":"https://api.github.com/users/dcreager/events{/privacy}","received_events_url":"https://api.github.com/users/dcreager/received_events","type":"User","site_admin":false},"repo":{"id":124238344,"name":"nel-collector","full_name":"dcreager/nel-collector","owner":{"login":"dcreager","id":7499,"avatar_url":"https://avatars2.githubusercontent.com/u/7499?v=4","gravatar_id":"","url":"https://api.github.com/users/dcreager","html_url":"https://github.com/dcreager","followers_url":"https://api.github.com/users/dcreager/followers","following_url":"https://api.github.com/users/dcreager/following{/other_user}","gists_url":"https://api.github.com/users/dcreager/gists{/gist_id}","starred_url":"https://api.github.com/users/dcreager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcreager/subscriptions","organizations_url":"https://api.github.com/users/dcreager/orgs","repos_url":"https://api.github.com/users/dcreager/repos","events_url":"https://api.github.com/users/dcreager/events{/privacy}","received_events_url":"https://api.github.com/users/dcreager/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dcreager/nel-collector","description":null,"fork":true,"url":"https://api.github.com/repos/dcreager/nel-collector","forks_url":"https://api.github.com/repos/dcreager/nel-collector/forks","keys_url":"https://api.github.com/repos/dcreager/nel-collector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcreager/nel-collector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcreager/nel-collector/teams","hooks_url":"https://api.github.com/repos/dcreager/nel-collector/hooks","issue_events_url":"https://api.github.com/repos/dcreager/nel-collector/issues/events{/number}","events_url":"https://api.github.com/repos/dcreager/nel-collector/events","assignees_url":"https://api.github.com/repos/dcreager/nel-collector/assignees{/user}","branches_url":"https://api.github.com/repos/dcreager/nel-collector/branches{/branch}","tags_url":"https://api.github.com/repos/dcreager/nel-collector/tags","blobs_url":"https://api.github.com/repos/dcreager/nel-collector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcreager/nel-collector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcreager/nel-collector/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcreager/nel-collector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcreager/nel-collector/statuses/{sha}","languages_url":"https://api.github.com/repos/dcreager/nel-collector/languages","stargazers_url":"https://api.github.com/repos/dcreager/nel-collector/stargazers","contributors_url":"https://api.github.com/repos/dcreager/nel-collector/contributors","subscribers_url":"https://api.github.com/repos/dcreager/nel-collector/subscribers","subscription_url":"https://api.github.com/repos/dcreager/nel-collector/subscription","commits_url":"https://api.github.com/repos/dcreager/nel-collector/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcreager/nel-collector/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcreager/nel-collector/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcreager/nel-collector/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcreager/nel-collector/contents/{+path}","compare_url":"https://api.github.com/repos/dcreager/nel-collector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcreager/nel-collector/merges","archive_url":"https://api.github.com/repos/dcreager/nel-collector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcreager/nel-collector/downloads","issues_url":"https://api.github.com/repos/dcreager/nel-collector/issues{/number}","pulls_url":"https://api.github.com/repos/dcreager/nel-collector/pulls{/number}","milestones_url":"https://api.github.com/repos/dcreager/nel-collector/milestones{/number}","notifications_url":"https://api.github.com/repos/dcreager/nel-collector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcreager/nel-collector/labels{/name}","releases_url":"https://api.github.com/repos/dcreager/nel-collector/releases{/id}","deployments_url":"https://api.github.com/repos/dcreager/nel-collector/deployments","created_at":"2018-03-07T13:16:07Z","updated_at":"2018-03-23T19:16:20Z","pushed_at":"2018-04-23T18:04:14Z","git_url":"git://github.com/dcreager/nel-collector.git","ssh_url":"git@github.com:dcreager/nel-collector.git","clone_url":"https://github.com/dcreager/nel-collector.git","svn_url":"https://github.com/dcreager/nel-collector","homepage":null,"size":73,"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"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"4bf82b0cfb585ea4151d19e2f3948b4412404320","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":124237907,"name":"nel-collector","full_name":"google/nel-collector","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/nel-collector","description":"Network Error Logging (NEL) collector","fork":false,"url":"https://api.github.com/repos/google/nel-collector","forks_url":"https://api.github.com/repos/google/nel-collector/forks","keys_url":"https://api.github.com/repos/google/nel-collector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/nel-collector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/nel-collector/teams","hooks_url":"https://api.github.com/repos/google/nel-collector/hooks","issue_events_url":"https://api.github.com/repos/google/nel-collector/issues/events{/number}","events_url":"https://api.github.com/repos/google/nel-collector/events","assignees_url":"https://api.github.com/repos/google/nel-collector/assignees{/user}","branches_url":"https://api.github.com/repos/google/nel-collector/branches{/branch}","tags_url":"https://api.github.com/repos/google/nel-collector/tags","blobs_url":"https://api.github.com/repos/google/nel-collector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/nel-collector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/nel-collector/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/nel-collector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/nel-collector/statuses/{sha}","languages_url":"https://api.github.com/repos/google/nel-collector/languages","stargazers_url":"https://api.github.com/repos/google/nel-collector/stargazers","contributors_url":"https://api.github.com/repos/google/nel-collector/contributors","subscribers_url":"https://api.github.com/repos/google/nel-collector/subscribers","subscription_url":"https://api.github.com/repos/google/nel-collector/subscription","commits_url":"https://api.github.com/repos/google/nel-collector/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/nel-collector/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/nel-collector/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/nel-collector/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/nel-collector/contents/{+path}","compare_url":"https://api.github.com/repos/google/nel-collector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/nel-collector/merges","archive_url":"https://api.github.com/repos/google/nel-collector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/nel-collector/downloads","issues_url":"https://api.github.com/repos/google/nel-collector/issues{/number}","pulls_url":"https://api.github.com/repos/google/nel-collector/pulls{/number}","milestones_url":"https://api.github.com/repos/google/nel-collector/milestones{/number}","notifications_url":"https://api.github.com/repos/google/nel-collector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/nel-collector/labels{/name}","releases_url":"https://api.github.com/repos/google/nel-collector/releases{/id}","deployments_url":"https://api.github.com/repos/google/nel-collector/deployments","created_at":"2018-03-07T13:12:16Z","updated_at":"2018-04-23T18:04:12Z","pushed_at":"2018-04-23T18:04:10Z","git_url":"git://github.com/google/nel-collector.git","ssh_url":"git@github.com:google/nel-collector.git","clone_url":"https://github.com/google/nel-collector.git","svn_url":"https://github.com/google/nel-collector","homepage":"https://wicg.github.io/network-error-logging/","size":64,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"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":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/nel-collector/pulls/21"},"html":{"href":"https://github.com/google/nel-collector/pull/21"},"issue":{"href":"https://api.github.com/repos/google/nel-collector/issues/21"},"comments":{"href":"https://api.github.com/repos/google/nel-collector/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/google/nel-collector/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/google/nel-collector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/nel-collector/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/google/nel-collector/statuses/03da17a68866407832f05b7639339f8222f5987a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"sburnett"}}