{"action":"created","comment":{"url":"https://api.github.com/repos/cisco-sso/mh/pulls/comments/199596754","pull_request_review_id":133747570,"id":199596754,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTU5Njc1NA==","diff_hunk":"@@ -0,0 +1,63 @@\n+// Copyright © 2018 Cisco Systems, Inc.\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 mhlib\n+\n+import (\n+\t\"github.com/imdario/mergo\"\n+)\n+\n+// MHConfigFile is the structure of a mh configuration file.\n+type MHConfigFile struct {\n+\tMH         MHConfig   `yaml:\"mh\"`\n+\tApps       Apps       `yaml:\"apps\"`\n+\tAppSources AppSources `yaml:\"appSources\"`\n+}\n+\n+// MHConfig is a set of options used during app deployment.\n+type MHConfig struct {\n+\tMaintainers   []string `yaml:\"maintainers\"`\n+\tNamespace     string   `yaml:\"namespace\"`\n+\tPrintRendered bool     `yaml:\"printRendered\"`\n+\tSimulate      bool     `yaml:\"simulate\"`\n+\tTargetContext string   `yaml:\"targetContext\"`\n+\tTeam          string   `yaml:\"team\"`\n+}\n+\n+// DefaultMHConfig is the default mh config and will most likely be modified\n+// during execution with the following sources by rising priority:\n+//\n+// 1. This default configuration\n+// 2. The \"mh\" key in the configuration file\n+// 3. Environment variables starting with \"MH_\"\n+// 4. Command line flags\n+// 5. app-specific overrides in MH_CONFIG.","path":"mhlib/mhConfig.go","position":39,"original_position":45,"commit_id":"8895df45b222123e081ac281ae1370da875d042d","original_commit_id":"76ac715934ff2969c94db27001cdf285aa731d80","user":{"login":"drekle","id":1883554,"node_id":"MDQ6VXNlcjE4ODM1NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1883554?v=4","gravatar_id":"","url":"https://api.github.com/users/drekle","html_url":"https://github.com/drekle","followers_url":"https://api.github.com/users/drekle/followers","following_url":"https://api.github.com/users/drekle/following{/other_user}","gists_url":"https://api.github.com/users/drekle/gists{/gist_id}","starred_url":"https://api.github.com/users/drekle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drekle/subscriptions","organizations_url":"https://api.github.com/users/drekle/orgs","repos_url":"https://api.github.com/users/drekle/repos","events_url":"https://api.github.com/users/drekle/events{/privacy}","received_events_url":"https://api.github.com/users/drekle/received_events","type":"User","site_admin":false},"body":"Your described order is what I would expect as well.","created_at":"2018-07-02T19:22:38Z","updated_at":"2018-07-02T19:22:38Z","html_url":"https://github.com/cisco-sso/mh/pull/9#discussion_r199596754","pull_request_url":"https://api.github.com/repos/cisco-sso/mh/pulls/9","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/cisco-sso/mh/pulls/comments/199596754"},"html":{"href":"https://github.com/cisco-sso/mh/pull/9#discussion_r199596754"},"pull_request":{"href":"https://api.github.com/repos/cisco-sso/mh/pulls/9"}},"in_reply_to_id":197477028},"pull_request":{"url":"https://api.github.com/repos/cisco-sso/mh/pulls/9","id":196765156,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2NzY1MTU2","html_url":"https://github.com/cisco-sso/mh/pull/9","diff_url":"https://github.com/cisco-sso/mh/pull/9.diff","patch_url":"https://github.com/cisco-sso/mh/pull/9.patch","issue_url":"https://api.github.com/repos/cisco-sso/mh/issues/9","number":9,"state":"open","locked":false,"title":"Refactor configuration, logging and general structure","user":{"login":"simt2","id":11369081,"node_id":"MDQ6VXNlcjExMzY5MDgx","avatar_url":"https://avatars0.githubusercontent.com/u/11369081?v=4","gravatar_id":"","url":"https://api.github.com/users/simt2","html_url":"https://github.com/simt2","followers_url":"https://api.github.com/users/simt2/followers","following_url":"https://api.github.com/users/simt2/following{/other_user}","gists_url":"https://api.github.com/users/simt2/gists{/gist_id}","starred_url":"https://api.github.com/users/simt2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simt2/subscriptions","organizations_url":"https://api.github.com/users/simt2/orgs","repos_url":"https://api.github.com/users/simt2/repos","events_url":"https://api.github.com/users/simt2/events{/privacy}","received_events_url":"https://api.github.com/users/simt2/received_events","type":"User","site_admin":false},"body":"As discussed yesterday with @josdotso and @rtluckie , I did some refactoring in mh. I think most of these changes are necessary for easy addition of new features and automated tests. I would like feedback to know if this is the right direction.\r\n\r\n### Configuration changes\r\n* Move global configuration in under the `mh` key in `MH_CONFIG`. This is the only breaking change in this PR to make it easier to understand how configuration is overridden later.\r\n* Make it possible to override global configuration on a per-app basis. This lays the ground for features like native namespaces or even different kubectl contexts. \r\n\r\nExample configuration outlining this new structure:\r\n```yaml\r\n# should: seperate actual configuration(\"namespace\") from information(\"maintainers\")\r\nmh:\r\n  maintainers:\r\n  - sitesar@cisco.com\r\n  namespace: default\r\n  printRendered: true\r\n  targetContext: localhost\r\n  team: sre\r\n\r\nappSources:\r\n- name: apps\r\n  kind: configPath\r\n  source: apps\r\n\r\napps:\r\n- name: foo\r\n- name: bar-0.1.0\r\n  alias: bar\r\n  key: .bar\r\n  namespace: bar-namespace # bar is deployed in a different namespace than foo\r\n```\r\nAn app definition in `MH_CONFIG` allows to override all global values, see the types `MHConfig` and `AppConfig` which is a superset of the first.\r\nGlobal options could be moved to another key or to the topmost level again. TBD is also how to deal with attributes like `team` that are no configuration but information. Some could be kept for logging purposes, e.g. app-specific `maintainers`. \r\n\r\n### Changes in logging and general structure\r\n* Reflect the above configuration logic entirely in yaml-tagged structs and merge them together where necessary\r\n* Introduce a `NewApp` method to sanitize and initialize app configuration\r\n* Code in `mhlib/` now only logs info messages\r\n* Loggers should be passed around the code and extended with additional fields depending on the level they reach -> DRY logging \r\n* `mhlib/` does not exit on fatal errors anymore, but passes errors upstream to be handled by command logic\r\n* Removed unnecessary and/or slow helper methods that were called sometimes multiple times per run \r\n* Check pointers for nil instead of values for zero \r\n\r\nI tested manually using [this](https://dpaste.cisco.com/HPOKt) configuration, not pasted here because it still includes internal information. WIP also because logging messages still need some love and more useful information.  ","created_at":"2018-06-22T15:05:16Z","updated_at":"2018-07-02T19:22:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c99bc8b776e7733783b6694c679053c015a38b58","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cisco-sso/mh/pulls/9/commits","review_comments_url":"https://api.github.com/repos/cisco-sso/mh/pulls/9/comments","review_comment_url":"https://api.github.com/repos/cisco-sso/mh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cisco-sso/mh/issues/9/comments","statuses_url":"https://api.github.com/repos/cisco-sso/mh/statuses/8895df45b222123e081ac281ae1370da875d042d","head":{"label":"simt2:refactor","ref":"refactor","sha":"8895df45b222123e081ac281ae1370da875d042d","user":{"login":"simt2","id":11369081,"node_id":"MDQ6VXNlcjExMzY5MDgx","avatar_url":"https://avatars0.githubusercontent.com/u/11369081?v=4","gravatar_id":"","url":"https://api.github.com/users/simt2","html_url":"https://github.com/simt2","followers_url":"https://api.github.com/users/simt2/followers","following_url":"https://api.github.com/users/simt2/following{/other_user}","gists_url":"https://api.github.com/users/simt2/gists{/gist_id}","starred_url":"https://api.github.com/users/simt2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simt2/subscriptions","organizations_url":"https://api.github.com/users/simt2/orgs","repos_url":"https://api.github.com/users/simt2/repos","events_url":"https://api.github.com/users/simt2/events{/privacy}","received_events_url":"https://api.github.com/users/simt2/received_events","type":"User","site_admin":false},"repo":{"id":137988609,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc5ODg2MDk=","name":"mh","full_name":"simt2/mh","owner":{"login":"simt2","id":11369081,"node_id":"MDQ6VXNlcjExMzY5MDgx","avatar_url":"https://avatars0.githubusercontent.com/u/11369081?v=4","gravatar_id":"","url":"https://api.github.com/users/simt2","html_url":"https://github.com/simt2","followers_url":"https://api.github.com/users/simt2/followers","following_url":"https://api.github.com/users/simt2/following{/other_user}","gists_url":"https://api.github.com/users/simt2/gists{/gist_id}","starred_url":"https://api.github.com/users/simt2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simt2/subscriptions","organizations_url":"https://api.github.com/users/simt2/orgs","repos_url":"https://api.github.com/users/simt2/repos","events_url":"https://api.github.com/users/simt2/events{/privacy}","received_events_url":"https://api.github.com/users/simt2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/simt2/mh","description":"A templating tool to manage and deploy multiple Helm charts.","fork":true,"url":"https://api.github.com/repos/simt2/mh","forks_url":"https://api.github.com/repos/simt2/mh/forks","keys_url":"https://api.github.com/repos/simt2/mh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simt2/mh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simt2/mh/teams","hooks_url":"https://api.github.com/repos/simt2/mh/hooks","issue_events_url":"https://api.github.com/repos/simt2/mh/issues/events{/number}","events_url":"https://api.github.com/repos/simt2/mh/events","assignees_url":"https://api.github.com/repos/simt2/mh/assignees{/user}","branches_url":"https://api.github.com/repos/simt2/mh/branches{/branch}","tags_url":"https://api.github.com/repos/simt2/mh/tags","blobs_url":"https://api.github.com/repos/simt2/mh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simt2/mh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simt2/mh/git/refs{/sha}","trees_url":"https://api.github.com/repos/simt2/mh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simt2/mh/statuses/{sha}","languages_url":"https://api.github.com/repos/simt2/mh/languages","stargazers_url":"https://api.github.com/repos/simt2/mh/stargazers","contributors_url":"https://api.github.com/repos/simt2/mh/contributors","subscribers_url":"https://api.github.com/repos/simt2/mh/subscribers","subscription_url":"https://api.github.com/repos/simt2/mh/subscription","commits_url":"https://api.github.com/repos/simt2/mh/commits{/sha}","git_commits_url":"https://api.github.com/repos/simt2/mh/git/commits{/sha}","comments_url":"https://api.github.com/repos/simt2/mh/comments{/number}","issue_comment_url":"https://api.github.com/repos/simt2/mh/issues/comments{/number}","contents_url":"https://api.github.com/repos/simt2/mh/contents/{+path}","compare_url":"https://api.github.com/repos/simt2/mh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simt2/mh/merges","archive_url":"https://api.github.com/repos/simt2/mh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simt2/mh/downloads","issues_url":"https://api.github.com/repos/simt2/mh/issues{/number}","pulls_url":"https://api.github.com/repos/simt2/mh/pulls{/number}","milestones_url":"https://api.github.com/repos/simt2/mh/milestones{/number}","notifications_url":"https://api.github.com/repos/simt2/mh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simt2/mh/labels{/name}","releases_url":"https://api.github.com/repos/simt2/mh/releases{/id}","deployments_url":"https://api.github.com/repos/simt2/mh/deployments","created_at":"2018-06-20T06:19:43Z","updated_at":"2018-06-20T06:19:46Z","pushed_at":"2018-07-02T12:16:11Z","git_url":"git://github.com/simt2/mh.git","ssh_url":"git@github.com:simt2/mh.git","clone_url":"https://github.com/simt2/mh.git","svn_url":"https://github.com/simt2/mh","homepage":"","size":74,"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":"cisco-sso:master","ref":"master","sha":"0131ee3a802da13552b358845db8de520e869866","user":{"login":"cisco-sso","id":39065680,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5MDY1Njgw","avatar_url":"https://avatars0.githubusercontent.com/u/39065680?v=4","gravatar_id":"","url":"https://api.github.com/users/cisco-sso","html_url":"https://github.com/cisco-sso","followers_url":"https://api.github.com/users/cisco-sso/followers","following_url":"https://api.github.com/users/cisco-sso/following{/other_user}","gists_url":"https://api.github.com/users/cisco-sso/gists{/gist_id}","starred_url":"https://api.github.com/users/cisco-sso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cisco-sso/subscriptions","organizations_url":"https://api.github.com/users/cisco-sso/orgs","repos_url":"https://api.github.com/users/cisco-sso/repos","events_url":"https://api.github.com/users/cisco-sso/events{/privacy}","received_events_url":"https://api.github.com/users/cisco-sso/received_events","type":"Organization","site_admin":false},"repo":{"id":132523619,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI1MjM2MTk=","name":"mh","full_name":"cisco-sso/mh","owner":{"login":"cisco-sso","id":39065680,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5MDY1Njgw","avatar_url":"https://avatars0.githubusercontent.com/u/39065680?v=4","gravatar_id":"","url":"https://api.github.com/users/cisco-sso","html_url":"https://github.com/cisco-sso","followers_url":"https://api.github.com/users/cisco-sso/followers","following_url":"https://api.github.com/users/cisco-sso/following{/other_user}","gists_url":"https://api.github.com/users/cisco-sso/gists{/gist_id}","starred_url":"https://api.github.com/users/cisco-sso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cisco-sso/subscriptions","organizations_url":"https://api.github.com/users/cisco-sso/orgs","repos_url":"https://api.github.com/users/cisco-sso/repos","events_url":"https://api.github.com/users/cisco-sso/events{/privacy}","received_events_url":"https://api.github.com/users/cisco-sso/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cisco-sso/mh","description":"A templating tool to manage and deploy multiple Helm charts.","fork":false,"url":"https://api.github.com/repos/cisco-sso/mh","forks_url":"https://api.github.com/repos/cisco-sso/mh/forks","keys_url":"https://api.github.com/repos/cisco-sso/mh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cisco-sso/mh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cisco-sso/mh/teams","hooks_url":"https://api.github.com/repos/cisco-sso/mh/hooks","issue_events_url":"https://api.github.com/repos/cisco-sso/mh/issues/events{/number}","events_url":"https://api.github.com/repos/cisco-sso/mh/events","assignees_url":"https://api.github.com/repos/cisco-sso/mh/assignees{/user}","branches_url":"https://api.github.com/repos/cisco-sso/mh/branches{/branch}","tags_url":"https://api.github.com/repos/cisco-sso/mh/tags","blobs_url":"https://api.github.com/repos/cisco-sso/mh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cisco-sso/mh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cisco-sso/mh/git/refs{/sha}","trees_url":"https://api.github.com/repos/cisco-sso/mh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cisco-sso/mh/statuses/{sha}","languages_url":"https://api.github.com/repos/cisco-sso/mh/languages","stargazers_url":"https://api.github.com/repos/cisco-sso/mh/stargazers","contributors_url":"https://api.github.com/repos/cisco-sso/mh/contributors","subscribers_url":"https://api.github.com/repos/cisco-sso/mh/subscribers","subscription_url":"https://api.github.com/repos/cisco-sso/mh/subscription","commits_url":"https://api.github.com/repos/cisco-sso/mh/commits{/sha}","git_commits_url":"https://api.github.com/repos/cisco-sso/mh/git/commits{/sha}","comments_url":"https://api.github.com/repos/cisco-sso/mh/comments{/number}","issue_comment_url":"https://api.github.com/repos/cisco-sso/mh/issues/comments{/number}","contents_url":"https://api.github.com/repos/cisco-sso/mh/contents/{+path}","compare_url":"https://api.github.com/repos/cisco-sso/mh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cisco-sso/mh/merges","archive_url":"https://api.github.com/repos/cisco-sso/mh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cisco-sso/mh/downloads","issues_url":"https://api.github.com/repos/cisco-sso/mh/issues{/number}","pulls_url":"https://api.github.com/repos/cisco-sso/mh/pulls{/number}","milestones_url":"https://api.github.com/repos/cisco-sso/mh/milestones{/number}","notifications_url":"https://api.github.com/repos/cisco-sso/mh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cisco-sso/mh/labels{/name}","releases_url":"https://api.github.com/repos/cisco-sso/mh/releases{/id}","deployments_url":"https://api.github.com/repos/cisco-sso/mh/deployments","created_at":"2018-05-07T22:36:38Z","updated_at":"2018-06-30T21:59:31Z","pushed_at":"2018-07-02T12:16:12Z","git_url":"git://github.com/cisco-sso/mh.git","ssh_url":"git@github.com:cisco-sso/mh.git","clone_url":"https://github.com/cisco-sso/mh.git","svn_url":"https://github.com/cisco-sso/mh","homepage":"","size":61,"stargazers_count":13,"watchers_count":13,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":7,"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":6,"open_issues":7,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cisco-sso/mh/pulls/9"},"html":{"href":"https://github.com/cisco-sso/mh/pull/9"},"issue":{"href":"https://api.github.com/repos/cisco-sso/mh/issues/9"},"comments":{"href":"https://api.github.com/repos/cisco-sso/mh/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/cisco-sso/mh/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/cisco-sso/mh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cisco-sso/mh/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/cisco-sso/mh/statuses/8895df45b222123e081ac281ae1370da875d042d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"drekle"}}