{"action":"created","comment":{"url":"https://api.github.com/repos/purpleidea/mgmt/pulls/comments/241967213","pull_request_review_id":185374018,"id":241967213,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTk2NzIxMw==","diff_hunk":"@@ -425,13 +434,55 @@ func (obj *SvcResAutoEdges) Test(input []bool) bool {\n \treturn true // keep going\n }\n \n-// AutoEdges returns the AutoEdge interface. In this case the systemd units.\n+// SvcResAutoEdgesCron holds the state of the svc -> cron auto edge generator.\n+type SvcResAutoEdgesCron struct {\n+\tunit    string // target unit\n+\tsession bool   // user session\n+}\n+\n+// Next returns the next automatic edge.\n+func (obj *SvcResAutoEdgesCron) Next() []engine.ResUID {\n+\t// XXX: should this be true if SvcRes State == \"stopped\"?\n+\treversed := false\n+\tvalue := &CronUID{\n+\t\tBaseUID: engine.BaseUID{\n+\t\t\tKind:     \"CronRes\",\n+\t\t\tReversed: &reversed,\n+\t\t},\n+\t\tunit:    obj.unit,    // target unit\n+\t\tsession: obj.session, // user session\n+\t}\n+\treturn []engine.ResUID{value} // we return one, even though api supports N\n+}\n+\n+// Test takes the output of the last call to Next() and outputs true if we\n+// should continue.\n+func (obj *SvcResAutoEdgesCron) Test([]bool) bool {\n+\treturn false // only get one svc -> cron edge\n+}\n+\n+// AutoEdges returns the AutoEdge interface. In this case, systemd unit file\n+// resources and cron (systemd-timer) resources.\n func (obj *SvcRes) AutoEdges() (engine.AutoEdge, error) {\n \tvar data []engine.ResUID\n-\tsvcFiles := []string{\n+\tvar svcFiles []string\n+\tsvcFiles = []string{\n \t\tfmt.Sprintf(\"/etc/systemd/system/%s.service\", obj.Name()),     // takes precedence\n \t\tfmt.Sprintf(\"/usr/lib/systemd/system/%s.service\", obj.Name()), // pkg default\n \t}\n+\tif obj.Session {\n+\t\t// user timer\n+\t\tu, err := user.Current()\n+\t\tif err != nil {\n+\t\t\treturn nil, errwrap.Wrapf(err, \"error getting current user\")\n+\t\t}\n+\t\tif u.HomeDir == \"\" {\n+\t\t\treturn nil, fmt.Errorf(\"user has no home directory\")\n+\t\t}\n+\t\tsvcFiles = []string{\n+\t\t\tfmt.Sprintf(\"%s/.config/systemd/user/%s.timer\", u.HomeDir, obj.Name()), // user svc","path":"engine/resources/svc.go","position":89,"original_position":89,"commit_id":"254923b6ad4024018016e103157c875b92cd64fd","original_commit_id":"254923b6ad4024018016e103157c875b92cd64fd","user":{"login":"purpleidea","id":135091,"node_id":"MDQ6VXNlcjEzNTA5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135091?v=4","gravatar_id":"","url":"https://api.github.com/users/purpleidea","html_url":"https://github.com/purpleidea","followers_url":"https://api.github.com/users/purpleidea/followers","following_url":"https://api.github.com/users/purpleidea/following{/other_user}","gists_url":"https://api.github.com/users/purpleidea/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleidea/subscriptions","organizations_url":"https://api.github.com/users/purpleidea/orgs","repos_url":"https://api.github.com/users/purpleidea/repos","events_url":"https://api.github.com/users/purpleidea/events{/privacy}","received_events_url":"https://api.github.com/users/purpleidea/received_events","type":"User","site_admin":false},"body":"same as above","created_at":"2018-12-16T03:57:00Z","updated_at":"2018-12-16T03:58:24Z","html_url":"https://github.com/purpleidea/mgmt/pull/418#discussion_r241967213","pull_request_url":"https://api.github.com/repos/purpleidea/mgmt/pulls/418","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/purpleidea/mgmt/pulls/comments/241967213"},"html":{"href":"https://github.com/purpleidea/mgmt/pull/418#discussion_r241967213"},"pull_request":{"href":"https://api.github.com/repos/purpleidea/mgmt/pulls/418"}}},"pull_request":{"url":"https://api.github.com/repos/purpleidea/mgmt/pulls/418","id":238349076,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4MzQ5MDc2","html_url":"https://github.com/purpleidea/mgmt/pull/418","diff_url":"https://github.com/purpleidea/mgmt/pull/418.diff","patch_url":"https://github.com/purpleidea/mgmt/pull/418.patch","issue_url":"https://api.github.com/repos/purpleidea/mgmt/issues/418","number":418,"state":"open","locked":false,"title":"[WIP] engine: resources: timer: Add a systemd-timer resource","user":{"login":"jonathangold","id":30417125,"node_id":"MDQ6VXNlcjMwNDE3MTI1","avatar_url":"https://avatars3.githubusercontent.com/u/30417125?v=4","gravatar_id":"","url":"https://api.github.com/users/jonathangold","html_url":"https://github.com/jonathangold","followers_url":"https://api.github.com/users/jonathangold/followers","following_url":"https://api.github.com/users/jonathangold/following{/other_user}","gists_url":"https://api.github.com/users/jonathangold/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathangold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathangold/subscriptions","organizations_url":"https://api.github.com/users/jonathangold/orgs","repos_url":"https://api.github.com/users/jonathangold/repos","events_url":"https://api.github.com/users/jonathangold/events{/privacy}","received_events_url":"https://api.github.com/users/jonathangold/received_events","type":"User","site_admin":false},"body":"For early feedback. Still have to ~~add autoedges to svc and~~ validate the time.\r\n\r\nI didn't initially realize there was already a timer resource :P so I can rename this to something else, but is https://github.com/purpleidea/mgmt/blob/master/engine/resources/timer.go still useful given language functions?\r\n\r\nEither way, I think it makes sense to call this resource 'timer' or 'systemd:timer' rather than cron.\r\n\r\nEdit: also tests","created_at":"2018-12-13T11:06:27Z","updated_at":"2018-12-16T03:58:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e45233e13d688f50d18f5b967ab160e66b1b3411","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/purpleidea/mgmt/pulls/418/commits","review_comments_url":"https://api.github.com/repos/purpleidea/mgmt/pulls/418/comments","review_comment_url":"https://api.github.com/repos/purpleidea/mgmt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/purpleidea/mgmt/issues/418/comments","statuses_url":"https://api.github.com/repos/purpleidea/mgmt/statuses/254923b6ad4024018016e103157c875b92cd64fd","head":{"label":"jonathangold:res/timer","ref":"res/timer","sha":"254923b6ad4024018016e103157c875b92cd64fd","user":{"login":"jonathangold","id":30417125,"node_id":"MDQ6VXNlcjMwNDE3MTI1","avatar_url":"https://avatars3.githubusercontent.com/u/30417125?v=4","gravatar_id":"","url":"https://api.github.com/users/jonathangold","html_url":"https://github.com/jonathangold","followers_url":"https://api.github.com/users/jonathangold/followers","following_url":"https://api.github.com/users/jonathangold/following{/other_user}","gists_url":"https://api.github.com/users/jonathangold/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathangold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathangold/subscriptions","organizations_url":"https://api.github.com/users/jonathangold/orgs","repos_url":"https://api.github.com/users/jonathangold/repos","events_url":"https://api.github.com/users/jonathangold/events{/privacy}","received_events_url":"https://api.github.com/users/jonathangold/received_events","type":"User","site_admin":false},"repo":{"id":159148942,"node_id":"MDEwOlJlcG9zaXRvcnkxNTkxNDg5NDI=","name":"mgmt","full_name":"jonathangold/mgmt","private":false,"owner":{"login":"jonathangold","id":30417125,"node_id":"MDQ6VXNlcjMwNDE3MTI1","avatar_url":"https://avatars3.githubusercontent.com/u/30417125?v=4","gravatar_id":"","url":"https://api.github.com/users/jonathangold","html_url":"https://github.com/jonathangold","followers_url":"https://api.github.com/users/jonathangold/followers","following_url":"https://api.github.com/users/jonathangold/following{/other_user}","gists_url":"https://api.github.com/users/jonathangold/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathangold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathangold/subscriptions","organizations_url":"https://api.github.com/users/jonathangold/orgs","repos_url":"https://api.github.com/users/jonathangold/repos","events_url":"https://api.github.com/users/jonathangold/events{/privacy}","received_events_url":"https://api.github.com/users/jonathangold/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jonathangold/mgmt","description":"Next generation distributed, event-driven, parallel config management!","fork":true,"url":"https://api.github.com/repos/jonathangold/mgmt","forks_url":"https://api.github.com/repos/jonathangold/mgmt/forks","keys_url":"https://api.github.com/repos/jonathangold/mgmt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonathangold/mgmt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonathangold/mgmt/teams","hooks_url":"https://api.github.com/repos/jonathangold/mgmt/hooks","issue_events_url":"https://api.github.com/repos/jonathangold/mgmt/issues/events{/number}","events_url":"https://api.github.com/repos/jonathangold/mgmt/events","assignees_url":"https://api.github.com/repos/jonathangold/mgmt/assignees{/user}","branches_url":"https://api.github.com/repos/jonathangold/mgmt/branches{/branch}","tags_url":"https://api.github.com/repos/jonathangold/mgmt/tags","blobs_url":"https://api.github.com/repos/jonathangold/mgmt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonathangold/mgmt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonathangold/mgmt/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonathangold/mgmt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonathangold/mgmt/statuses/{sha}","languages_url":"https://api.github.com/repos/jonathangold/mgmt/languages","stargazers_url":"https://api.github.com/repos/jonathangold/mgmt/stargazers","contributors_url":"https://api.github.com/repos/jonathangold/mgmt/contributors","subscribers_url":"https://api.github.com/repos/jonathangold/mgmt/subscribers","subscription_url":"https://api.github.com/repos/jonathangold/mgmt/subscription","commits_url":"https://api.github.com/repos/jonathangold/mgmt/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonathangold/mgmt/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonathangold/mgmt/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonathangold/mgmt/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonathangold/mgmt/contents/{+path}","compare_url":"https://api.github.com/repos/jonathangold/mgmt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonathangold/mgmt/merges","archive_url":"https://api.github.com/repos/jonathangold/mgmt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonathangold/mgmt/downloads","issues_url":"https://api.github.com/repos/jonathangold/mgmt/issues{/number}","pulls_url":"https://api.github.com/repos/jonathangold/mgmt/pulls{/number}","milestones_url":"https://api.github.com/repos/jonathangold/mgmt/milestones{/number}","notifications_url":"https://api.github.com/repos/jonathangold/mgmt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonathangold/mgmt/labels{/name}","releases_url":"https://api.github.com/repos/jonathangold/mgmt/releases{/id}","deployments_url":"https://api.github.com/repos/jonathangold/mgmt/deployments","created_at":"2018-11-26T10:09:15Z","updated_at":"2018-12-04T21:57:26Z","pushed_at":"2018-12-15T23:47:24Z","git_url":"git://github.com/jonathangold/mgmt.git","ssh_url":"git@github.com:jonathangold/mgmt.git","clone_url":"https://github.com/jonathangold/mgmt.git","svn_url":"https://github.com/jonathangold/mgmt","homepage":"https://purpleidea.com/tags/mgmtconfig/","size":2882,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"purpleidea:master","ref":"master","sha":"8282f3b59c19e636b9d371a9dff88dbfe7321a25","user":{"login":"purpleidea","id":135091,"node_id":"MDQ6VXNlcjEzNTA5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135091?v=4","gravatar_id":"","url":"https://api.github.com/users/purpleidea","html_url":"https://github.com/purpleidea","followers_url":"https://api.github.com/users/purpleidea/followers","following_url":"https://api.github.com/users/purpleidea/following{/other_user}","gists_url":"https://api.github.com/users/purpleidea/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleidea/subscriptions","organizations_url":"https://api.github.com/users/purpleidea/orgs","repos_url":"https://api.github.com/users/purpleidea/repos","events_url":"https://api.github.com/users/purpleidea/events{/privacy}","received_events_url":"https://api.github.com/users/purpleidea/received_events","type":"User","site_admin":false},"repo":{"id":43111018,"node_id":"MDEwOlJlcG9zaXRvcnk0MzExMTAxOA==","name":"mgmt","full_name":"purpleidea/mgmt","private":false,"owner":{"login":"purpleidea","id":135091,"node_id":"MDQ6VXNlcjEzNTA5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135091?v=4","gravatar_id":"","url":"https://api.github.com/users/purpleidea","html_url":"https://github.com/purpleidea","followers_url":"https://api.github.com/users/purpleidea/followers","following_url":"https://api.github.com/users/purpleidea/following{/other_user}","gists_url":"https://api.github.com/users/purpleidea/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleidea/subscriptions","organizations_url":"https://api.github.com/users/purpleidea/orgs","repos_url":"https://api.github.com/users/purpleidea/repos","events_url":"https://api.github.com/users/purpleidea/events{/privacy}","received_events_url":"https://api.github.com/users/purpleidea/received_events","type":"User","site_admin":false},"html_url":"https://github.com/purpleidea/mgmt","description":"Next generation distributed, event-driven, parallel config management!","fork":false,"url":"https://api.github.com/repos/purpleidea/mgmt","forks_url":"https://api.github.com/repos/purpleidea/mgmt/forks","keys_url":"https://api.github.com/repos/purpleidea/mgmt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/purpleidea/mgmt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/purpleidea/mgmt/teams","hooks_url":"https://api.github.com/repos/purpleidea/mgmt/hooks","issue_events_url":"https://api.github.com/repos/purpleidea/mgmt/issues/events{/number}","events_url":"https://api.github.com/repos/purpleidea/mgmt/events","assignees_url":"https://api.github.com/repos/purpleidea/mgmt/assignees{/user}","branches_url":"https://api.github.com/repos/purpleidea/mgmt/branches{/branch}","tags_url":"https://api.github.com/repos/purpleidea/mgmt/tags","blobs_url":"https://api.github.com/repos/purpleidea/mgmt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/purpleidea/mgmt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/purpleidea/mgmt/git/refs{/sha}","trees_url":"https://api.github.com/repos/purpleidea/mgmt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/purpleidea/mgmt/statuses/{sha}","languages_url":"https://api.github.com/repos/purpleidea/mgmt/languages","stargazers_url":"https://api.github.com/repos/purpleidea/mgmt/stargazers","contributors_url":"https://api.github.com/repos/purpleidea/mgmt/contributors","subscribers_url":"https://api.github.com/repos/purpleidea/mgmt/subscribers","subscription_url":"https://api.github.com/repos/purpleidea/mgmt/subscription","commits_url":"https://api.github.com/repos/purpleidea/mgmt/commits{/sha}","git_commits_url":"https://api.github.com/repos/purpleidea/mgmt/git/commits{/sha}","comments_url":"https://api.github.com/repos/purpleidea/mgmt/comments{/number}","issue_comment_url":"https://api.github.com/repos/purpleidea/mgmt/issues/comments{/number}","contents_url":"https://api.github.com/repos/purpleidea/mgmt/contents/{+path}","compare_url":"https://api.github.com/repos/purpleidea/mgmt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/purpleidea/mgmt/merges","archive_url":"https://api.github.com/repos/purpleidea/mgmt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/purpleidea/mgmt/downloads","issues_url":"https://api.github.com/repos/purpleidea/mgmt/issues{/number}","pulls_url":"https://api.github.com/repos/purpleidea/mgmt/pulls{/number}","milestones_url":"https://api.github.com/repos/purpleidea/mgmt/milestones{/number}","notifications_url":"https://api.github.com/repos/purpleidea/mgmt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/purpleidea/mgmt/labels{/name}","releases_url":"https://api.github.com/repos/purpleidea/mgmt/releases{/id}","deployments_url":"https://api.github.com/repos/purpleidea/mgmt/deployments","created_at":"2015-09-25T05:15:41Z","updated_at":"2018-12-15T16:01:19Z","pushed_at":"2018-12-16T03:17:12Z","git_url":"git://github.com/purpleidea/mgmt.git","ssh_url":"git@github.com:purpleidea/mgmt.git","clone_url":"https://github.com/purpleidea/mgmt.git","svn_url":"https://github.com/purpleidea/mgmt","homepage":"https://purpleidea.com/tags/mgmtconfig/","size":2878,"stargazers_count":1526,"watchers_count":1526,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":178,"mirror_url":null,"archived":false,"open_issues_count":66,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":178,"open_issues":66,"watchers":1526,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/purpleidea/mgmt/pulls/418"},"html":{"href":"https://github.com/purpleidea/mgmt/pull/418"},"issue":{"href":"https://api.github.com/repos/purpleidea/mgmt/issues/418"},"comments":{"href":"https://api.github.com/repos/purpleidea/mgmt/issues/418/comments"},"review_comments":{"href":"https://api.github.com/repos/purpleidea/mgmt/pulls/418/comments"},"review_comment":{"href":"https://api.github.com/repos/purpleidea/mgmt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/purpleidea/mgmt/pulls/418/commits"},"statuses":{"href":"https://api.github.com/repos/purpleidea/mgmt/statuses/254923b6ad4024018016e103157c875b92cd64fd"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"purpleidea"}}