{"action":"created","issue":{"url":"https://api.github.com/repos/hilbert/hilbert-cli/issues/16","repository_url":"https://api.github.com/repos/hilbert/hilbert-cli","labels_url":"https://api.github.com/repos/hilbert/hilbert-cli/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/hilbert/hilbert-cli/issues/16/comments","events_url":"https://api.github.com/repos/hilbert/hilbert-cli/issues/16/events","html_url":"https://github.com/hilbert/hilbert-cli/issues/16","id":184106874,"number":16,"title":"Configuration design: Use of YAML Anchors/aliases","user":{"login":"malex984","id":391009,"avatar_url":"https://avatars.githubusercontent.com/u/391009?v=3","gravatar_id":"","url":"https://api.github.com/users/malex984","html_url":"https://github.com/malex984","followers_url":"https://api.github.com/users/malex984/followers","following_url":"https://api.github.com/users/malex984/following{/other_user}","gists_url":"https://api.github.com/users/malex984/gists{/gist_id}","starred_url":"https://api.github.com/users/malex984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malex984/subscriptions","organizations_url":"https://api.github.com/users/malex984/orgs","repos_url":"https://api.github.com/users/malex984/repos","events_url":"https://api.github.com/users/malex984/events{/privacy}","received_events_url":"https://api.github.com/users/malex984/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-20T00:23:32Z","updated_at":"2016-10-20T10:36:59Z","closed_at":null,"body":"Note: this is a separation of super-issue hilbert/hilbert-cli#13\r\n\r\n**General: 1.1:** Yes, anchors seem to be used wrong. I wouldn't use them at all... a simple / plain config is enough and it's not really necessary, nor useful if it makes it more verbose instead of less (which is the intent of anchors).\r\n\r\n**Profile: 3.5** Use strings instead of anchors for apps and services."},"comment":{"url":"https://api.github.com/repos/hilbert/hilbert-cli/issues/comments/255070890","html_url":"https://github.com/hilbert/hilbert-cli/issues/16#issuecomment-255070890","issue_url":"https://api.github.com/repos/hilbert/hilbert-cli/issues/16","id":255070890,"user":{"login":"malex984","id":391009,"avatar_url":"https://avatars.githubusercontent.com/u/391009?v=3","gravatar_id":"","url":"https://api.github.com/users/malex984","html_url":"https://github.com/malex984","followers_url":"https://api.github.com/users/malex984/followers","following_url":"https://api.github.com/users/malex984/following{/other_user}","gists_url":"https://api.github.com/users/malex984/gists{/gist_id}","starred_url":"https://api.github.com/users/malex984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malex984/subscriptions","organizations_url":"https://api.github.com/users/malex984/orgs","repos_url":"https://api.github.com/users/malex984/repos","events_url":"https://api.github.com/users/malex984/events{/privacy}","received_events_url":"https://api.github.com/users/malex984/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T10:36:59Z","updated_at":"2016-10-20T10:36:59Z","body":"**Eric:** \r\n\r\nThe fact that we have to send each other code samples to show how the parser interprets the file **should** be enough to make it clear that this feature isn't obvious enough to be used in cfg. The cfg should be obvious to the user.\r\n\r\nHowever...\r\n\r\n```\r\nimport yaml\r\n\r\ncfg_file = \"\"\"\r\npeople:\r\n  alice: &alice {name: 'Alice Anderson', age: 29, email: 'alice@example.com'}\r\n  john: &john {name: 'John Jameson', age: 30, email: 'john@example.com'}\r\n  peter: &peter {name: 'Peter Parker', age: 25, email: 'peter@example.com'}\r\nteams:\r\n  alpha: [*john, *peter]\r\n  beta: [*peter, {name: 'Green Goblin', age: 60, email: 'hacker@example.com'}]\r\n  gamma: [*john, {name: 'Peter Parker', age: 85, email: 'peter@example.com'}]\r\n\"\"\"\r\n\r\ncfg = yaml.load(cfg_file)\r\n\r\nprint cfg.get('teams')['alpha']\r\n# output:\r\n# [{'age': 30, 'name': 'John Jameson', 'email': 'john@example.com'},\r\n# {'age': 25, 'name': 'Peter Parker', 'email': 'peter@example.com'}]\r\n\r\nprint cfg.get('teams')['beta']\r\n# output:\r\n# [{'age': 25, 'name': 'Peter Parker', 'email': 'peter@example.com'},\r\n# {'age': 60, 'name': 'Green Goblin', 'email': 'hacker@example.com'}]\r\n\r\nprint cfg.get('teams')['gamma']\r\n# [{'age': 30, 'name': 'John Jameson', 'email': 'john@example.com'}, \r\n# {'age': 85, 'name': 'Peter Parker', 'email': 'peter@example.com'}]\r\n```\r\n\r\nNotice the **Green Goblin** was added to team **beta** and when we do `cfg.get('teams')['beta']` it looks JUST like Peter Parker, which is a valid user that exists in the \"people\" table. So if I validate the teams table it looks like everything is OK, but the user did something illegal.\r\n\r\nSo how can I validate? Suppose I check that every user in a team is also on the **people** table... I could do that... but consider team **gamma** where I added a Peter Parker with the wrong age... so to pick that error in the cfg I would have to compare EVERY FIELD of each person to make sure **teams** and **people** are consistent.\r\n\r\nSomething else: Notice that on the **people** table I indexed each member with an ID that's non repeatable, because **people** is a map. If I repeat an ID the parser will overwrite the former occurrence with the latter... just like would happen on an INI file if I set a value twice.\r\n\r\n... but now the ID is not accessible on the copies of the **people** that are on the teams. If I do `cfg.get('teams')['gamma'][0]` I can't get the ID... unless I repeat the ID within the map, which is error prone, redundant, etc.\r\n"}}
{"actor":{"display_login":"malex984"}}