{"action":"created","comment":{"url":"https://api.github.com/repos/almighty/almighty-core/pulls/comments/80442900","id":80442900,"diff_hunk":"@@ -0,0 +1,96 @@\n+package configuration\n+\n+import (\n+\t\"fmt\"\n+\t\"log\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\tyaml \"gopkg.in/yaml.v2\"\n+\n+\t\"github.com/fsnotify/fsnotify\"\n+\t\"github.com/spf13/viper\"\n+)\n+\n+const (\n+\t// DefaultConfigFilePath is the path to the configuration file that is used if no other\n+\t// file is specified via the -config switch or via the ALMIGHTY_CONFIG_FILE_PATH environment\n+\t// variable.\n+\tDefaultConfigFilePath = \"config.yaml\"\n+)\n+\n+// GetConfiguration returns the current configuration as a string\n+func GetConfiguration() string {\n+\tallSettings := viper.AllSettings()\n+\ty, err := yaml.Marshal(&allSettings)\n+\tif err != nil {\n+\t\tpanic(fmt.Errorf(\"Failed to marshall config to string: %s\", err.Error()))\n+\t}\n+\treturn fmt.Sprintf(\"%s\\n\", y)\n+}\n+\n+// SetupConfiguration sets up defaults for viper configuration options and\n+// overrides these values with the values from the given configuration file\n+// if it is not empty. Those values again are overwritten by environment\n+// variables.\n+func SetupConfiguration(configFilePath string) error {","path":"configuration/configuration.go","position":null,"original_position":36,"commit_id":"0b018d356dbe664bb0eea903eeccd2b004f8f5ac","original_commit_id":"fe64a8e8497f56f45ecf4f917b31e6546cb19584","user":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"body":"Done in 28507e4","created_at":"2016-09-26T09:58:54Z","updated_at":"2016-09-26T09:58:55Z","html_url":"https://github.com/almighty/almighty-core/pull/274#discussion_r80442900","pull_request_url":"https://api.github.com/repos/almighty/almighty-core/pulls/274","_links":{"self":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/comments/80442900"},"html":{"href":"https://github.com/almighty/almighty-core/pull/274#discussion_r80442900"},"pull_request":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/274"}}},"pull_request":{"url":"https://api.github.com/repos/almighty/almighty-core/pulls/274","id":86550357,"html_url":"https://github.com/almighty/almighty-core/pull/274","diff_url":"https://github.com/almighty/almighty-core/pull/274.diff","patch_url":"https://github.com/almighty/almighty-core/pull/274.patch","issue_url":"https://api.github.com/repos/almighty/almighty-core/issues/274","number":274,"state":"open","locked":false,"title":"Add configuration mechanism","user":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"body":"Fixes #176\r\n\r\nYou can now either use a config file or environment variables to manipulate the way that the ALM core starts.\r\n\r\nWe no longer have any but these two command line switches for the core process:\r\n\r\n* `-config`: Takes a filepath to the config file to read\r\n * To override the path to the config file with an environment variable, use set `ALMIGHTY_CONFIG_FILE_PATH` to point to the config file.\r\n* `-printConfig`: Prints the config (including merged environment variables) and exits\r\n\r\nIf no configuration file is specified when the core is started, these are the defaults:\r\n\r\n```yaml\r\n#------------------------\r\n# Postgres configuration\r\n#------------------------\r\n\r\npostgres.host: localhost\r\npostgres.user: postgres\r\npostgres.password: mysecretpassword\r\npostgres.port: 5432\r\npostgres.sslmode: disable\r\n# The number of times alm server will attempt to open a connection to the database before it gives up\r\npostgres.connection.maxretries: 50\r\n# Duration to wait before trying to connect again\r\npostgres.connection.retrysleep: 1s\r\n\r\n#------------------------\r\n# HTTP configuration\r\n#------------------------\r\n\r\nhttp.address: 0.0.0.0:8080\r\n\r\n#------------------------\r\n# Misc.\r\n#------------------------\r\n\r\n# Enable development related features, e.g. token generation endpoint\r\ndeveloper.mode.enabled: false\r\n```\r\n\r\nAlthough this is a YAML file, we highly suggest to stick to this rather lenghty notation instead of nesting structs.\r\n\r\nTo override configuration values using environment variables, use the prefix\r\n`ALMIGHTY_` and replace the dots in the variables names with underscores.\r\n\r\nFor example to override `postgres.password`, set the environment variable `ALMIGHTY_POSTGRES_PASSWORD` to the value of you liking.\r\n\r\nNOTE: Environment variables override the default values and the ones you've set in your config file. \r\n\r\nTo load the default settings and setup the configuration system, one must call [`configuration.SetupConfiguration()`](https://github.com/almighty/almighty-core/pull/274/files#diff-786c8376feaa68e9ebee88ca950d2774R32).","created_at":"2016-09-23T17:26:17Z","updated_at":"2016-09-26T09:58:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"983fa2b080f5e633403a0cd2fbc7d2cad9bcae80","assignee":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"assignees":[{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/almighty/almighty-core/milestones/4","html_url":"https://github.com/almighty/almighty-core/milestones/Sprint%20%23120","labels_url":"https://api.github.com/repos/almighty/almighty-core/milestones/4/labels","id":1987329,"number":4,"title":"Sprint #120","description":"","creator":{"login":"aslakknutsen","id":132158,"avatar_url":"https://avatars.githubusercontent.com/u/132158?v=3","gravatar_id":"","url":"https://api.github.com/users/aslakknutsen","html_url":"https://github.com/aslakknutsen","followers_url":"https://api.github.com/users/aslakknutsen/followers","following_url":"https://api.github.com/users/aslakknutsen/following{/other_user}","gists_url":"https://api.github.com/users/aslakknutsen/gists{/gist_id}","starred_url":"https://api.github.com/users/aslakknutsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aslakknutsen/subscriptions","organizations_url":"https://api.github.com/users/aslakknutsen/orgs","repos_url":"https://api.github.com/users/aslakknutsen/repos","events_url":"https://api.github.com/users/aslakknutsen/events{/privacy}","received_events_url":"https://api.github.com/users/aslakknutsen/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":21,"state":"open","created_at":"2016-09-06T21:00:02Z","updated_at":"2016-09-26T08:29:36Z","due_on":"2016-09-27T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/almighty/almighty-core/pulls/274/commits","review_comments_url":"https://api.github.com/repos/almighty/almighty-core/pulls/274/comments","review_comment_url":"https://api.github.com/repos/almighty/almighty-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/almighty/almighty-core/issues/274/comments","statuses_url":"https://api.github.com/repos/almighty/almighty-core/statuses/0b018d356dbe664bb0eea903eeccd2b004f8f5ac","head":{"label":"kwk:fix-176","ref":"fix-176","sha":"0b018d356dbe664bb0eea903eeccd2b004f8f5ac","user":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"repo":{"id":61216531,"name":"almighty-core","full_name":"kwk/almighty-core","owner":{"login":"kwk","id":193408,"avatar_url":"https://avatars.githubusercontent.com/u/193408?v=3","gravatar_id":"","url":"https://api.github.com/users/kwk","html_url":"https://github.com/kwk","followers_url":"https://api.github.com/users/kwk/followers","following_url":"https://api.github.com/users/kwk/following{/other_user}","gists_url":"https://api.github.com/users/kwk/gists{/gist_id}","starred_url":"https://api.github.com/users/kwk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwk/subscriptions","organizations_url":"https://api.github.com/users/kwk/orgs","repos_url":"https://api.github.com/users/kwk/repos","events_url":"https://api.github.com/users/kwk/events{/privacy}","received_events_url":"https://api.github.com/users/kwk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kwk/almighty-core","description":"","fork":true,"url":"https://api.github.com/repos/kwk/almighty-core","forks_url":"https://api.github.com/repos/kwk/almighty-core/forks","keys_url":"https://api.github.com/repos/kwk/almighty-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kwk/almighty-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kwk/almighty-core/teams","hooks_url":"https://api.github.com/repos/kwk/almighty-core/hooks","issue_events_url":"https://api.github.com/repos/kwk/almighty-core/issues/events{/number}","events_url":"https://api.github.com/repos/kwk/almighty-core/events","assignees_url":"https://api.github.com/repos/kwk/almighty-core/assignees{/user}","branches_url":"https://api.github.com/repos/kwk/almighty-core/branches{/branch}","tags_url":"https://api.github.com/repos/kwk/almighty-core/tags","blobs_url":"https://api.github.com/repos/kwk/almighty-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kwk/almighty-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kwk/almighty-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/kwk/almighty-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kwk/almighty-core/statuses/{sha}","languages_url":"https://api.github.com/repos/kwk/almighty-core/languages","stargazers_url":"https://api.github.com/repos/kwk/almighty-core/stargazers","contributors_url":"https://api.github.com/repos/kwk/almighty-core/contributors","subscribers_url":"https://api.github.com/repos/kwk/almighty-core/subscribers","subscription_url":"https://api.github.com/repos/kwk/almighty-core/subscription","commits_url":"https://api.github.com/repos/kwk/almighty-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/kwk/almighty-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/kwk/almighty-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/kwk/almighty-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/kwk/almighty-core/contents/{+path}","compare_url":"https://api.github.com/repos/kwk/almighty-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kwk/almighty-core/merges","archive_url":"https://api.github.com/repos/kwk/almighty-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kwk/almighty-core/downloads","issues_url":"https://api.github.com/repos/kwk/almighty-core/issues{/number}","pulls_url":"https://api.github.com/repos/kwk/almighty-core/pulls{/number}","milestones_url":"https://api.github.com/repos/kwk/almighty-core/milestones{/number}","notifications_url":"https://api.github.com/repos/kwk/almighty-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kwk/almighty-core/labels{/name}","releases_url":"https://api.github.com/repos/kwk/almighty-core/releases{/id}","deployments_url":"https://api.github.com/repos/kwk/almighty-core/deployments","created_at":"2016-06-15T14:55:29Z","updated_at":"2016-06-15T14:55:30Z","pushed_at":"2016-09-26T09:54:08Z","git_url":"git://github.com/kwk/almighty-core.git","ssh_url":"git@github.com:kwk/almighty-core.git","clone_url":"https://github.com/kwk/almighty-core.git","svn_url":"https://github.com/kwk/almighty-core","homepage":null,"size":419,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"almighty:master","ref":"master","sha":"1efe0b9f0f10f3c751215a7637405ac555482e92","user":{"login":"almighty","id":17783151,"avatar_url":"https://avatars.githubusercontent.com/u/17783151?v=3","gravatar_id":"","url":"https://api.github.com/users/almighty","html_url":"https://github.com/almighty","followers_url":"https://api.github.com/users/almighty/followers","following_url":"https://api.github.com/users/almighty/following{/other_user}","gists_url":"https://api.github.com/users/almighty/gists{/gist_id}","starred_url":"https://api.github.com/users/almighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almighty/subscriptions","organizations_url":"https://api.github.com/users/almighty/orgs","repos_url":"https://api.github.com/users/almighty/repos","events_url":"https://api.github.com/users/almighty/events{/privacy}","received_events_url":"https://api.github.com/users/almighty/received_events","type":"Organization","site_admin":false},"repo":{"id":54260706,"name":"almighty-core","full_name":"almighty/almighty-core","owner":{"login":"almighty","id":17783151,"avatar_url":"https://avatars.githubusercontent.com/u/17783151?v=3","gravatar_id":"","url":"https://api.github.com/users/almighty","html_url":"https://github.com/almighty","followers_url":"https://api.github.com/users/almighty/followers","following_url":"https://api.github.com/users/almighty/following{/other_user}","gists_url":"https://api.github.com/users/almighty/gists{/gist_id}","starred_url":"https://api.github.com/users/almighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almighty/subscriptions","organizations_url":"https://api.github.com/users/almighty/orgs","repos_url":"https://api.github.com/users/almighty/repos","events_url":"https://api.github.com/users/almighty/events{/privacy}","received_events_url":"https://api.github.com/users/almighty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/almighty/almighty-core","description":"","fork":false,"url":"https://api.github.com/repos/almighty/almighty-core","forks_url":"https://api.github.com/repos/almighty/almighty-core/forks","keys_url":"https://api.github.com/repos/almighty/almighty-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/almighty/almighty-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/almighty/almighty-core/teams","hooks_url":"https://api.github.com/repos/almighty/almighty-core/hooks","issue_events_url":"https://api.github.com/repos/almighty/almighty-core/issues/events{/number}","events_url":"https://api.github.com/repos/almighty/almighty-core/events","assignees_url":"https://api.github.com/repos/almighty/almighty-core/assignees{/user}","branches_url":"https://api.github.com/repos/almighty/almighty-core/branches{/branch}","tags_url":"https://api.github.com/repos/almighty/almighty-core/tags","blobs_url":"https://api.github.com/repos/almighty/almighty-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/almighty/almighty-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/almighty/almighty-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/almighty/almighty-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/almighty/almighty-core/statuses/{sha}","languages_url":"https://api.github.com/repos/almighty/almighty-core/languages","stargazers_url":"https://api.github.com/repos/almighty/almighty-core/stargazers","contributors_url":"https://api.github.com/repos/almighty/almighty-core/contributors","subscribers_url":"https://api.github.com/repos/almighty/almighty-core/subscribers","subscription_url":"https://api.github.com/repos/almighty/almighty-core/subscription","commits_url":"https://api.github.com/repos/almighty/almighty-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/almighty/almighty-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/almighty/almighty-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/almighty/almighty-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/almighty/almighty-core/contents/{+path}","compare_url":"https://api.github.com/repos/almighty/almighty-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/almighty/almighty-core/merges","archive_url":"https://api.github.com/repos/almighty/almighty-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/almighty/almighty-core/downloads","issues_url":"https://api.github.com/repos/almighty/almighty-core/issues{/number}","pulls_url":"https://api.github.com/repos/almighty/almighty-core/pulls{/number}","milestones_url":"https://api.github.com/repos/almighty/almighty-core/milestones{/number}","notifications_url":"https://api.github.com/repos/almighty/almighty-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/almighty/almighty-core/labels{/name}","releases_url":"https://api.github.com/repos/almighty/almighty-core/releases{/id}","deployments_url":"https://api.github.com/repos/almighty/almighty-core/deployments","created_at":"2016-03-19T10:42:15Z","updated_at":"2016-09-21T20:02:55Z","pushed_at":"2016-09-26T09:54:08Z","git_url":"git://github.com/almighty/almighty-core.git","ssh_url":"git@github.com:almighty/almighty-core.git","clone_url":"https://github.com/almighty/almighty-core.git","svn_url":"https://github.com/almighty/almighty-core","homepage":"http://devdoc.almighty.io/","size":4659,"stargazers_count":12,"watchers_count":12,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":80,"forks":27,"open_issues":80,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/274"},"html":{"href":"https://github.com/almighty/almighty-core/pull/274"},"issue":{"href":"https://api.github.com/repos/almighty/almighty-core/issues/274"},"comments":{"href":"https://api.github.com/repos/almighty/almighty-core/issues/274/comments"},"review_comments":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/274/comments"},"review_comment":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/274/commits"},"statuses":{"href":"https://api.github.com/repos/almighty/almighty-core/statuses/0b018d356dbe664bb0eea903eeccd2b004f8f5ac"}}}}
{"actor":{"display_login":"kwk"}}