{"action":"created","issue":{"url":"https://api.github.com/repos/cfengine/core/issues/2150","labels_url":"https://api.github.com/repos/cfengine/core/issues/2150/labels{/name}","comments_url":"https://api.github.com/repos/cfengine/core/issues/2150/comments","events_url":"https://api.github.com/repos/cfengine/core/issues/2150/events","html_url":"https://github.com/cfengine/core/pull/2150","id":64251326,"number":2150,"title":"Redmine#2504: allow string contexts","user":{"login":"tzz","id":67764,"avatar_url":"https://avatars.githubusercontent.com/u/67764?v=3","gravatar_id":"","url":"https://api.github.com/users/tzz","html_url":"https://github.com/tzz","followers_url":"https://api.github.com/users/tzz/followers","following_url":"https://api.github.com/users/tzz/following{/other_user}","gists_url":"https://api.github.com/users/tzz/gists{/gist_id}","starred_url":"https://api.github.com/users/tzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzz/subscriptions","organizations_url":"https://api.github.com/users/tzz/orgs","repos_url":"https://api.github.com/users/tzz/repos","events_url":"https://api.github.com/users/tzz/events{/privacy}","received_events_url":"https://api.github.com/users/tzz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"kacfengine","id":4037094,"avatar_url":"https://avatars.githubusercontent.com/u/4037094?v=3","gravatar_id":"","url":"https://api.github.com/users/kacfengine","html_url":"https://github.com/kacfengine","followers_url":"https://api.github.com/users/kacfengine/followers","following_url":"https://api.github.com/users/kacfengine/following{/other_user}","gists_url":"https://api.github.com/users/kacfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/kacfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kacfengine/subscriptions","organizations_url":"https://api.github.com/users/kacfengine/orgs","repos_url":"https://api.github.com/users/kacfengine/repos","events_url":"https://api.github.com/users/kacfengine/events{/privacy}","received_events_url":"https://api.github.com/users/kacfengine/received_events","type":"User","site_admin":false},"milestone":null,"comments":9,"created_at":"2015-03-25T11:52:46Z","updated_at":"2015-04-21T07:33:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cfengine/core/pulls/2150","html_url":"https://github.com/cfengine/core/pull/2150","diff_url":"https://github.com/cfengine/core/pull/2150.diff","patch_url":"https://github.com/cfengine/core/pull/2150.patch"},"body":"This PR addresses https://dev.cfengine.com/issues/2504 to allow the syntax sugar of specifying a string as a context.  The underlying implementation simply creates an `ifvarclass` promise attribute with that string, and if such an attribute is also specified directly, the two will be appended.\r\n\r\nBecause we relay the logic to `ifvarclass`, this should have **no effect** on the CFEngine evaluation behavior.  But that needs to be thoroughly tested, so community help is warmly welcome.\r\n\r\nSample usage:\r\n\r\n```\r\nbundle agent main\r\n{\r\n  reports:\r\n      \"hello, this is OS $(sys.os)\"\r\n      ifvarclass => \"$(sys.os)\";\r\n    any::\r\n      \"any hello\";\r\n    \"any\"::\r\n      \"string hello\";\r\n    \"$(sys.os)\"::\r\n      \"variable context hello!!!\";\r\n    \"not$(sys.os)\"::\r\n      \"BAD variable context hello!!!\";\r\n    \"$(sys.os)\"::\r\n      \"augmented variable context hello!!!\"\r\n      ifvarclass => \"any\";\r\n\r\n    \"$(sys.os)\"::\r\n      \"BAD augmented variable context hello!!!\"\r\n      ifvarclass => \"nonesuch\";\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```console\r\n% cf-agent -KI -f ./test_variable_contexts.cf\r\nR: hello, this is OS darwin\r\nR: any hello\r\nR: string hello\r\nR: variable context hello!!!\r\nR: augmented variable context hello!!!\r\n```\r\n\r\nIssues and concerns:\r\n\r\n* in `policy.c` I may have a leak because of the rval item manipulation (marked with a TODO).  Needs review.\r\n* in `promises.c` I shut up the \"apparent bundle\" warning if the constraint was `ifvarclass` or `if`.  That seems flimsy.\r\n* touching these internals is always tricky and I don't know if I covered all the cases\r\n"},"comment":{"url":"https://api.github.com/repos/cfengine/core/issues/comments/94671265","html_url":"https://github.com/cfengine/core/pull/2150#issuecomment-94671265","issue_url":"https://api.github.com/repos/cfengine/core/issues/2150","id":94671265,"user":{"login":"kacfengine","id":4037094,"avatar_url":"https://avatars.githubusercontent.com/u/4037094?v=3","gravatar_id":"","url":"https://api.github.com/users/kacfengine","html_url":"https://github.com/kacfengine","followers_url":"https://api.github.com/users/kacfengine/followers","following_url":"https://api.github.com/users/kacfengine/following{/other_user}","gists_url":"https://api.github.com/users/kacfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/kacfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kacfengine/subscriptions","organizations_url":"https://api.github.com/users/kacfengine/orgs","repos_url":"https://api.github.com/users/kacfengine/repos","events_url":"https://api.github.com/users/kacfengine/events{/privacy}","received_events_url":"https://api.github.com/users/kacfengine/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T07:33:05Z","updated_at":"2015-04-21T07:33:05Z","body":"Merged manually.\r\n\r\nI messed up the merge commit, so it's going to say \"canonical-json\", but it is really string contexts. Too many PRs in the air... :-P"}}