{"action":"created","comment":{"url":"https://api.github.com/repos/ligato/cn-infra/pulls/comments/227452107","pull_request_review_id":167495751,"id":227452107,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzQ1MjEwNw==","diff_hunk":"@@ -0,0 +1,422 @@\n+//  Copyright (c) 2018 Cisco and/or its affiliates.\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 filedb\n+\n+import (\n+\t\"bytes\"\n+\t\"strings\"\n+\t\"sync\"\n+\n+\t\"github.com/ligato/cn-infra/db/keyval/filedb/database\"\n+\t\"github.com/ligato/cn-infra/db/keyval/filedb/decoder\"\n+\t\"github.com/ligato/cn-infra/db/keyval/filedb/filesystem\"\n+\n+\t\"github.com/pkg/errors\"\n+\n+\t\"github.com/fsnotify/fsnotify\"\n+\t\"github.com/ligato/cn-infra/datasync\"\n+\t\"github.com/ligato/cn-infra/db/keyval\"\n+\t\"github.com/ligato/cn-infra/logging\"\n+)\n+\n+// Client arranges communication between file system and internal database, and is also responsible for upstream events.\n+type Client struct {\n+\tsync.Mutex\n+\tlog logging.Logger\n+\n+\t// A list of filesystem paths. It may be a specific file, or the whole directory. In case a path is a directory,\n+\t// all files within are processed. If there are another directories inside, they are skipped.\n+\tcfgPaths []string\n+\n+\t// Path where the status will be stored. Status will be stored either as json or yaml, determined by file suffix.\n+\t// If the field is empty or point to a directory, status is not propagated to any file.\n+\tstPath string\n+\t// Status reader is chosen according to status file extension.\n+\tstDc decoder.API\n+\n+\t// Internal database mirrors changes in file system. Since the configuration can be only read, it is up to client\n+\t// to handle difference between configuration revisions. Every database entry consists from three values:\n+\t//  - path (where the configuration is written)\n+\t//  - data key\n+\t//  - data value\n+\t// Note: database holds only configuration intended for agent with appropriate prefix\n+\tdb database.FilesSystemDB\n+\n+\t// Filesystem handler, provides methods to work with files/directories\n+\tfsh filesystem.API","path":"db/keyval/filedb/client.go","position":58,"original_position":58,"commit_id":"1f3029a2d1b3e4f0e27158499b5f101472e49277","original_commit_id":"cbd26417d9b06a9f80581b8f26e55a502bf04f8b","user":{"login":"ondrej-fabry","id":32484950,"node_id":"MDQ6VXNlcjMyNDg0OTUw","avatar_url":"https://avatars1.githubusercontent.com/u/32484950?v=4","gravatar_id":"","url":"https://api.github.com/users/ondrej-fabry","html_url":"https://github.com/ondrej-fabry","followers_url":"https://api.github.com/users/ondrej-fabry/followers","following_url":"https://api.github.com/users/ondrej-fabry/following{/other_user}","gists_url":"https://api.github.com/users/ondrej-fabry/gists{/gist_id}","starred_url":"https://api.github.com/users/ondrej-fabry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ondrej-fabry/subscriptions","organizations_url":"https://api.github.com/users/ondrej-fabry/orgs","repos_url":"https://api.github.com/users/ondrej-fabry/repos","events_url":"https://api.github.com/users/ondrej-fabry/events{/privacy}","received_events_url":"https://api.github.com/users/ondrej-fabry/received_events","type":"User","site_admin":false},"body":"Fields in structs, especially ones with several fields used across multiple files, should contain more verbose name for better code readability. It took me a few scrolls to figure out some of these fields. Few characters long variable names should mostly be used for local variables.\r\n\r\n`fsh` -> `fsHandler`\r\n`stPath` -> `statusPath`\r\n`stDc` -> `statusDecoder`\r\n","created_at":"2018-10-23T15:42:08Z","updated_at":"2018-10-23T15:42:09Z","html_url":"https://github.com/ligato/cn-infra/pull/350#discussion_r227452107","pull_request_url":"https://api.github.com/repos/ligato/cn-infra/pulls/350","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ligato/cn-infra/pulls/comments/227452107"},"html":{"href":"https://github.com/ligato/cn-infra/pull/350#discussion_r227452107"},"pull_request":{"href":"https://api.github.com/repos/ligato/cn-infra/pulls/350"}}},"pull_request":{"url":"https://api.github.com/repos/ligato/cn-infra/pulls/350","id":221767854,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNzY3ODU0","html_url":"https://github.com/ligato/cn-infra/pull/350","diff_url":"https://github.com/ligato/cn-infra/pull/350.diff","patch_url":"https://github.com/ligato/cn-infra/pull/350.patch","issue_url":"https://api.github.com/repos/ligato/cn-infra/issues/350","number":350,"state":"open","locked":false,"title":"filesystem as key-value data store","user":{"login":"VladoLavor","id":15376606,"node_id":"MDQ6VXNlcjE1Mzc2NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/15376606?v=4","gravatar_id":"","url":"https://api.github.com/users/VladoLavor","html_url":"https://github.com/VladoLavor","followers_url":"https://api.github.com/users/VladoLavor/followers","following_url":"https://api.github.com/users/VladoLavor/following{/other_user}","gists_url":"https://api.github.com/users/VladoLavor/gists{/gist_id}","starred_url":"https://api.github.com/users/VladoLavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladoLavor/subscriptions","organizations_url":"https://api.github.com/users/VladoLavor/orgs","repos_url":"https://api.github.com/users/VladoLavor/repos","events_url":"https://api.github.com/users/VladoLavor/events{/privacy}","received_events_url":"https://api.github.com/users/VladoLavor/received_events","type":"User","site_admin":false},"body":"Supported features:\r\n* files/directories to watch can be defined in config file (--filesystem-config=(path))\r\n* read configuration is applied during resync (same way as other kv stores)\r\n* changes in config files during runtime are propagated to plugin, and appropriate events are generated\r\n\r\nSigned-off-by: Vladimir Lavor vlavor@cisco.com","created_at":"2018-10-10T12:21:08Z","updated_at":"2018-10-23T15:42:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3d1d4d989b9882c2d6d1d45583dae9ccf472f05","assignee":{"login":"VladoLavor","id":15376606,"node_id":"MDQ6VXNlcjE1Mzc2NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/15376606?v=4","gravatar_id":"","url":"https://api.github.com/users/VladoLavor","html_url":"https://github.com/VladoLavor","followers_url":"https://api.github.com/users/VladoLavor/followers","following_url":"https://api.github.com/users/VladoLavor/following{/other_user}","gists_url":"https://api.github.com/users/VladoLavor/gists{/gist_id}","starred_url":"https://api.github.com/users/VladoLavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladoLavor/subscriptions","organizations_url":"https://api.github.com/users/VladoLavor/orgs","repos_url":"https://api.github.com/users/VladoLavor/repos","events_url":"https://api.github.com/users/VladoLavor/events{/privacy}","received_events_url":"https://api.github.com/users/VladoLavor/received_events","type":"User","site_admin":false},"assignees":[{"login":"VladoLavor","id":15376606,"node_id":"MDQ6VXNlcjE1Mzc2NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/15376606?v=4","gravatar_id":"","url":"https://api.github.com/users/VladoLavor","html_url":"https://github.com/VladoLavor","followers_url":"https://api.github.com/users/VladoLavor/followers","following_url":"https://api.github.com/users/VladoLavor/following{/other_user}","gists_url":"https://api.github.com/users/VladoLavor/gists{/gist_id}","starred_url":"https://api.github.com/users/VladoLavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladoLavor/subscriptions","organizations_url":"https://api.github.com/users/VladoLavor/orgs","repos_url":"https://api.github.com/users/VladoLavor/repos","events_url":"https://api.github.com/users/VladoLavor/events{/privacy}","received_events_url":"https://api.github.com/users/VladoLavor/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":906610626,"node_id":"MDU6TGFiZWw5MDY2MTA2MjY=","url":"https://api.github.com/repos/ligato/cn-infra/labels/%E2%9A%A1%EF%B8%8F%20Feature","name":"⚡️ Feature","color":"5319e7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ligato/cn-infra/pulls/350/commits","review_comments_url":"https://api.github.com/repos/ligato/cn-infra/pulls/350/comments","review_comment_url":"https://api.github.com/repos/ligato/cn-infra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ligato/cn-infra/issues/350/comments","statuses_url":"https://api.github.com/repos/ligato/cn-infra/statuses/1f3029a2d1b3e4f0e27158499b5f101472e49277","head":{"label":"VladoLavor:master","ref":"master","sha":"1f3029a2d1b3e4f0e27158499b5f101472e49277","user":{"login":"VladoLavor","id":15376606,"node_id":"MDQ6VXNlcjE1Mzc2NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/15376606?v=4","gravatar_id":"","url":"https://api.github.com/users/VladoLavor","html_url":"https://github.com/VladoLavor","followers_url":"https://api.github.com/users/VladoLavor/followers","following_url":"https://api.github.com/users/VladoLavor/following{/other_user}","gists_url":"https://api.github.com/users/VladoLavor/gists{/gist_id}","starred_url":"https://api.github.com/users/VladoLavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladoLavor/subscriptions","organizations_url":"https://api.github.com/users/VladoLavor/orgs","repos_url":"https://api.github.com/users/VladoLavor/repos","events_url":"https://api.github.com/users/VladoLavor/events{/privacy}","received_events_url":"https://api.github.com/users/VladoLavor/received_events","type":"User","site_admin":false},"repo":{"id":98873097,"node_id":"MDEwOlJlcG9zaXRvcnk5ODg3MzA5Nw==","name":"cn-infra","full_name":"VladoLavor/cn-infra","private":false,"owner":{"login":"VladoLavor","id":15376606,"node_id":"MDQ6VXNlcjE1Mzc2NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/15376606?v=4","gravatar_id":"","url":"https://api.github.com/users/VladoLavor","html_url":"https://github.com/VladoLavor","followers_url":"https://api.github.com/users/VladoLavor/followers","following_url":"https://api.github.com/users/VladoLavor/following{/other_user}","gists_url":"https://api.github.com/users/VladoLavor/gists{/gist_id}","starred_url":"https://api.github.com/users/VladoLavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladoLavor/subscriptions","organizations_url":"https://api.github.com/users/VladoLavor/orgs","repos_url":"https://api.github.com/users/VladoLavor/repos","events_url":"https://api.github.com/users/VladoLavor/events{/privacy}","received_events_url":"https://api.github.com/users/VladoLavor/received_events","type":"User","site_admin":false},"html_url":"https://github.com/VladoLavor/cn-infra","description":"Cloud-native Virtual Network Function (VNF) framework","fork":true,"url":"https://api.github.com/repos/VladoLavor/cn-infra","forks_url":"https://api.github.com/repos/VladoLavor/cn-infra/forks","keys_url":"https://api.github.com/repos/VladoLavor/cn-infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VladoLavor/cn-infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VladoLavor/cn-infra/teams","hooks_url":"https://api.github.com/repos/VladoLavor/cn-infra/hooks","issue_events_url":"https://api.github.com/repos/VladoLavor/cn-infra/issues/events{/number}","events_url":"https://api.github.com/repos/VladoLavor/cn-infra/events","assignees_url":"https://api.github.com/repos/VladoLavor/cn-infra/assignees{/user}","branches_url":"https://api.github.com/repos/VladoLavor/cn-infra/branches{/branch}","tags_url":"https://api.github.com/repos/VladoLavor/cn-infra/tags","blobs_url":"https://api.github.com/repos/VladoLavor/cn-infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VladoLavor/cn-infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VladoLavor/cn-infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/VladoLavor/cn-infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VladoLavor/cn-infra/statuses/{sha}","languages_url":"https://api.github.com/repos/VladoLavor/cn-infra/languages","stargazers_url":"https://api.github.com/repos/VladoLavor/cn-infra/stargazers","contributors_url":"https://api.github.com/repos/VladoLavor/cn-infra/contributors","subscribers_url":"https://api.github.com/repos/VladoLavor/cn-infra/subscribers","subscription_url":"https://api.github.com/repos/VladoLavor/cn-infra/subscription","commits_url":"https://api.github.com/repos/VladoLavor/cn-infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/VladoLavor/cn-infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/VladoLavor/cn-infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/VladoLavor/cn-infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/VladoLavor/cn-infra/contents/{+path}","compare_url":"https://api.github.com/repos/VladoLavor/cn-infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VladoLavor/cn-infra/merges","archive_url":"https://api.github.com/repos/VladoLavor/cn-infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VladoLavor/cn-infra/downloads","issues_url":"https://api.github.com/repos/VladoLavor/cn-infra/issues{/number}","pulls_url":"https://api.github.com/repos/VladoLavor/cn-infra/pulls{/number}","milestones_url":"https://api.github.com/repos/VladoLavor/cn-infra/milestones{/number}","notifications_url":"https://api.github.com/repos/VladoLavor/cn-infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VladoLavor/cn-infra/labels{/name}","releases_url":"https://api.github.com/repos/VladoLavor/cn-infra/releases{/id}","deployments_url":"https://api.github.com/repos/VladoLavor/cn-infra/deployments","created_at":"2017-07-31T09:40:33Z","updated_at":"2018-10-23T14:47:09Z","pushed_at":"2018-10-23T14:47:07Z","git_url":"git://github.com/VladoLavor/cn-infra.git","ssh_url":"git@github.com:VladoLavor/cn-infra.git","clone_url":"https://github.com/VladoLavor/cn-infra.git","svn_url":"https://github.com/VladoLavor/cn-infra","homepage":"","size":76006,"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":"ligato:master","ref":"master","sha":"27c16bc72ecce6e364b9b0c3fecf66846606eee7","user":{"login":"ligato","id":28989152,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTg5MTUy","avatar_url":"https://avatars0.githubusercontent.com/u/28989152?v=4","gravatar_id":"","url":"https://api.github.com/users/ligato","html_url":"https://github.com/ligato","followers_url":"https://api.github.com/users/ligato/followers","following_url":"https://api.github.com/users/ligato/following{/other_user}","gists_url":"https://api.github.com/users/ligato/gists{/gist_id}","starred_url":"https://api.github.com/users/ligato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ligato/subscriptions","organizations_url":"https://api.github.com/users/ligato/orgs","repos_url":"https://api.github.com/users/ligato/repos","events_url":"https://api.github.com/users/ligato/events{/privacy}","received_events_url":"https://api.github.com/users/ligato/received_events","type":"Organization","site_admin":false},"repo":{"id":94889501,"node_id":"MDEwOlJlcG9zaXRvcnk5NDg4OTUwMQ==","name":"cn-infra","full_name":"ligato/cn-infra","private":false,"owner":{"login":"ligato","id":28989152,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTg5MTUy","avatar_url":"https://avatars0.githubusercontent.com/u/28989152?v=4","gravatar_id":"","url":"https://api.github.com/users/ligato","html_url":"https://github.com/ligato","followers_url":"https://api.github.com/users/ligato/followers","following_url":"https://api.github.com/users/ligato/following{/other_user}","gists_url":"https://api.github.com/users/ligato/gists{/gist_id}","starred_url":"https://api.github.com/users/ligato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ligato/subscriptions","organizations_url":"https://api.github.com/users/ligato/orgs","repos_url":"https://api.github.com/users/ligato/repos","events_url":"https://api.github.com/users/ligato/events{/privacy}","received_events_url":"https://api.github.com/users/ligato/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ligato/cn-infra","description":"A platform for developing cloud-native VNFs","fork":false,"url":"https://api.github.com/repos/ligato/cn-infra","forks_url":"https://api.github.com/repos/ligato/cn-infra/forks","keys_url":"https://api.github.com/repos/ligato/cn-infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ligato/cn-infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ligato/cn-infra/teams","hooks_url":"https://api.github.com/repos/ligato/cn-infra/hooks","issue_events_url":"https://api.github.com/repos/ligato/cn-infra/issues/events{/number}","events_url":"https://api.github.com/repos/ligato/cn-infra/events","assignees_url":"https://api.github.com/repos/ligato/cn-infra/assignees{/user}","branches_url":"https://api.github.com/repos/ligato/cn-infra/branches{/branch}","tags_url":"https://api.github.com/repos/ligato/cn-infra/tags","blobs_url":"https://api.github.com/repos/ligato/cn-infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ligato/cn-infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ligato/cn-infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/ligato/cn-infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ligato/cn-infra/statuses/{sha}","languages_url":"https://api.github.com/repos/ligato/cn-infra/languages","stargazers_url":"https://api.github.com/repos/ligato/cn-infra/stargazers","contributors_url":"https://api.github.com/repos/ligato/cn-infra/contributors","subscribers_url":"https://api.github.com/repos/ligato/cn-infra/subscribers","subscription_url":"https://api.github.com/repos/ligato/cn-infra/subscription","commits_url":"https://api.github.com/repos/ligato/cn-infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/ligato/cn-infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/ligato/cn-infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/ligato/cn-infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/ligato/cn-infra/contents/{+path}","compare_url":"https://api.github.com/repos/ligato/cn-infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ligato/cn-infra/merges","archive_url":"https://api.github.com/repos/ligato/cn-infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ligato/cn-infra/downloads","issues_url":"https://api.github.com/repos/ligato/cn-infra/issues{/number}","pulls_url":"https://api.github.com/repos/ligato/cn-infra/pulls{/number}","milestones_url":"https://api.github.com/repos/ligato/cn-infra/milestones{/number}","notifications_url":"https://api.github.com/repos/ligato/cn-infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ligato/cn-infra/labels{/name}","releases_url":"https://api.github.com/repos/ligato/cn-infra/releases{/id}","deployments_url":"https://api.github.com/repos/ligato/cn-infra/deployments","created_at":"2017-06-20T12:37:37Z","updated_at":"2018-10-18T14:35:57Z","pushed_at":"2018-10-23T14:47:08Z","git_url":"git://github.com/ligato/cn-infra.git","ssh_url":"git@github.com:ligato/cn-infra.git","clone_url":"https://github.com/ligato/cn-infra.git","svn_url":"https://github.com/ligato/cn-infra","homepage":"","size":76391,"stargazers_count":35,"watchers_count":35,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"archived":false,"open_issues_count":5,"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":28,"open_issues":5,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ligato/cn-infra/pulls/350"},"html":{"href":"https://github.com/ligato/cn-infra/pull/350"},"issue":{"href":"https://api.github.com/repos/ligato/cn-infra/issues/350"},"comments":{"href":"https://api.github.com/repos/ligato/cn-infra/issues/350/comments"},"review_comments":{"href":"https://api.github.com/repos/ligato/cn-infra/pulls/350/comments"},"review_comment":{"href":"https://api.github.com/repos/ligato/cn-infra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ligato/cn-infra/pulls/350/commits"},"statuses":{"href":"https://api.github.com/repos/ligato/cn-infra/statuses/1f3029a2d1b3e4f0e27158499b5f101472e49277"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ondrej-fabry"}}