{"action":"created","comment":{"url":"https://api.github.com/repos/alces-software/adminware/pulls/comments/224528508","pull_request_review_id":163919777,"id":224528508,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDUyODUwOA==","diff_hunk":"@@ -1,30 +1,79 @@\n \n import glob\n import click\n-import os\n+import re\n+\n+from sys import exit\n+from os import listdir\n+from os.path import join, dirname, relpath, isfile, isdir\n from models.config import Config\n from collections import defaultdict\n from itertools import chain\n \n+#TODO DRY up the file leader - only define '/var/lib/adminware/tools' once\n class ClickGlob:\n-    def __glob_configs(namespace):\n-        parts = ['/var/lib/adminware/tools',\n-                 namespace, '*/config.yaml']\n-        paths = glob.glob(os.path.join(*parts))\n-        return list(map(lambda x: Config(x), paths))\n+    def __glob_dirs(namespace):\n+        parts = ['/var/lib/adminware/tools', namespace, '*']\n+        paths = glob.glob(join(*parts))\n+        return paths\n+\n+    # decorator for __glob_dir to get all valid paths (ending in config.yaml) at once\n+    def __glob_all(globbing_func):\n+        def __wrapper(*args, **kwargs):\n+            def __sub_wrapper(*args, **kwargs):\n+                paths = globbing_func(*args)\n+                for path in paths:\n+                    if isfile('{}/config.yaml'.format(path)):\n+                        kwargs['all_paths'] += [join(path, 'config.yaml')]\n+                    else:\n+                        namespace = path[len('/var/lib/adminware/tools/'):]\n+                        __sub_wrapper(namespace, **kwargs)\n+                return kwargs['all_paths']\n+\n+            kwargs['all_paths']=[]\n+            all_paths = __sub_wrapper(*args, **kwargs)\n+            return all_paths\n+\n+        return __wrapper\n \n     def command(click_group, namespace):\n         # command_func is either run_open or run_batch, what this is decorating\n         def __command(command_func):\n-            actions = list(map(lambda x: Action(x), ClickGlob.__glob_configs(namespace)))\n-            for action in actions:\n-                action.create(click_group, command_func)\n+            __command_helper(click_group, namespace, command_func)\n+\n+        def __command_helper(cur_group, cur_namespace, command_func):\n+            paths = ClickGlob.__glob_dirs(cur_namespace) # will generate a list of paths at level 'namespace'\n+            for path in paths:\n+                if isfile('{}/config.yaml'.format(path)):\n+                    # if there exists a sibling dir to any config.yaml this is currently an error\n+                    # TODO this will be removed with closure of issue #49 but more validation may be needed","path":"src/action.py","position":60,"original_position":58,"commit_id":"b33498dd7f903c73ce3d5a2c39a68db16ad85a84","original_commit_id":"8856765fa5c0348868178ff46d471016123a6d6e","user":{"login":"DavidMarchant","id":24327288,"node_id":"MDQ6VXNlcjI0MzI3Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/24327288?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidMarchant","html_url":"https://github.com/DavidMarchant","followers_url":"https://api.github.com/users/DavidMarchant/followers","following_url":"https://api.github.com/users/DavidMarchant/following{/other_user}","gists_url":"https://api.github.com/users/DavidMarchant/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidMarchant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidMarchant/subscriptions","organizations_url":"https://api.github.com/users/DavidMarchant/orgs","repos_url":"https://api.github.com/users/DavidMarchant/repos","events_url":"https://api.github.com/users/DavidMarchant/events{/privacy}","received_events_url":"https://api.github.com/users/DavidMarchant/received_events","type":"User","site_admin":false},"body":"Ah sure, I'll chuck the relevant info in #49 & delete the comment","created_at":"2018-10-11T17:05:26Z","updated_at":"2018-10-11T17:05:26Z","html_url":"https://github.com/alces-software/adminware/pull/87#discussion_r224528508","pull_request_url":"https://api.github.com/repos/alces-software/adminware/pulls/87","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/alces-software/adminware/pulls/comments/224528508"},"html":{"href":"https://github.com/alces-software/adminware/pull/87#discussion_r224528508"},"pull_request":{"href":"https://api.github.com/repos/alces-software/adminware/pulls/87"}},"in_reply_to_id":224146560},"pull_request":{"url":"https://api.github.com/repos/alces-software/adminware/pulls/87","id":221832737,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxODMyNzM3","html_url":"https://github.com/alces-software/adminware/pull/87","diff_url":"https://github.com/alces-software/adminware/pull/87.diff","patch_url":"https://github.com/alces-software/adminware/pull/87.patch","issue_url":"https://api.github.com/repos/alces-software/adminware/issues/87","number":87,"state":"open","locked":false,"title":"Feat/multiple namespaces","user":{"login":"DavidMarchant","id":24327288,"node_id":"MDQ6VXNlcjI0MzI3Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/24327288?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidMarchant","html_url":"https://github.com/DavidMarchant","followers_url":"https://api.github.com/users/DavidMarchant/followers","following_url":"https://api.github.com/users/DavidMarchant/following{/other_user}","gists_url":"https://api.github.com/users/DavidMarchant/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidMarchant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidMarchant/subscriptions","organizations_url":"https://api.github.com/users/DavidMarchant/orgs","repos_url":"https://api.github.com/users/DavidMarchant/repos","events_url":"https://api.github.com/users/DavidMarchant/events{/privacy}","received_events_url":"https://api.github.com/users/DavidMarchant/received_events","type":"User","site_admin":false},"body":"Closes #48 when merged\r\n\r\nTools can now be located in arbitrarily deeply nested file systems within `/var/lib/adminware/tools/{batch,open}` These extended file systems come up as autocomplete results in the CLI.\r\n\r\nAlso added some validation for the file system - any dir containing a config.yaml and another dir will throw a big ol' error on start up. Any file in the tree will now not register as a result in the CLI.\r\n\r\nAlso fixed multiple node arguments for `run-family` (oopsie)","created_at":"2018-10-10T15:22:23Z","updated_at":"2018-10-11T17:05:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a5ee4248daee877a75752ce27b752c1f16a2c9c3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/alces-software/adminware/pulls/87/commits","review_comments_url":"https://api.github.com/repos/alces-software/adminware/pulls/87/comments","review_comment_url":"https://api.github.com/repos/alces-software/adminware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alces-software/adminware/issues/87/comments","statuses_url":"https://api.github.com/repos/alces-software/adminware/statuses/b33498dd7f903c73ce3d5a2c39a68db16ad85a84","head":{"label":"alces-software:feat/multiple-namespaces","ref":"feat/multiple-namespaces","sha":"b33498dd7f903c73ce3d5a2c39a68db16ad85a84","user":{"login":"alces-software","id":945288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTI4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"repo":{"id":121500310,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE1MDAzMTA=","name":"adminware","full_name":"alces-software/adminware","private":false,"owner":{"login":"alces-software","id":945288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTI4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/alces-software/adminware","description":"A sandbox CLI for running commands remotely across nodes","fork":false,"url":"https://api.github.com/repos/alces-software/adminware","forks_url":"https://api.github.com/repos/alces-software/adminware/forks","keys_url":"https://api.github.com/repos/alces-software/adminware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alces-software/adminware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alces-software/adminware/teams","hooks_url":"https://api.github.com/repos/alces-software/adminware/hooks","issue_events_url":"https://api.github.com/repos/alces-software/adminware/issues/events{/number}","events_url":"https://api.github.com/repos/alces-software/adminware/events","assignees_url":"https://api.github.com/repos/alces-software/adminware/assignees{/user}","branches_url":"https://api.github.com/repos/alces-software/adminware/branches{/branch}","tags_url":"https://api.github.com/repos/alces-software/adminware/tags","blobs_url":"https://api.github.com/repos/alces-software/adminware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alces-software/adminware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alces-software/adminware/git/refs{/sha}","trees_url":"https://api.github.com/repos/alces-software/adminware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alces-software/adminware/statuses/{sha}","languages_url":"https://api.github.com/repos/alces-software/adminware/languages","stargazers_url":"https://api.github.com/repos/alces-software/adminware/stargazers","contributors_url":"https://api.github.com/repos/alces-software/adminware/contributors","subscribers_url":"https://api.github.com/repos/alces-software/adminware/subscribers","subscription_url":"https://api.github.com/repos/alces-software/adminware/subscription","commits_url":"https://api.github.com/repos/alces-software/adminware/commits{/sha}","git_commits_url":"https://api.github.com/repos/alces-software/adminware/git/commits{/sha}","comments_url":"https://api.github.com/repos/alces-software/adminware/comments{/number}","issue_comment_url":"https://api.github.com/repos/alces-software/adminware/issues/comments{/number}","contents_url":"https://api.github.com/repos/alces-software/adminware/contents/{+path}","compare_url":"https://api.github.com/repos/alces-software/adminware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alces-software/adminware/merges","archive_url":"https://api.github.com/repos/alces-software/adminware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alces-software/adminware/downloads","issues_url":"https://api.github.com/repos/alces-software/adminware/issues{/number}","pulls_url":"https://api.github.com/repos/alces-software/adminware/pulls{/number}","milestones_url":"https://api.github.com/repos/alces-software/adminware/milestones{/number}","notifications_url":"https://api.github.com/repos/alces-software/adminware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alces-software/adminware/labels{/name}","releases_url":"https://api.github.com/repos/alces-software/adminware/releases{/id}","deployments_url":"https://api.github.com/repos/alces-software/adminware/deployments","created_at":"2018-02-14T10:54:10Z","updated_at":"2018-10-11T15:45:14Z","pushed_at":"2018-10-11T16:36:11Z","git_url":"git://github.com/alces-software/adminware.git","ssh_url":"git@github.com:alces-software/adminware.git","clone_url":"https://github.com/alces-software/adminware.git","svn_url":"https://github.com/alces-software/adminware","homepage":"","size":357,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":0,"open_issues":14,"watchers":0,"default_branch":"develop"}},"base":{"label":"alces-software:develop","ref":"develop","sha":"4384ed4e94a0092f5f568e2f864c8a40084bc317","user":{"login":"alces-software","id":945288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTI4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"repo":{"id":121500310,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE1MDAzMTA=","name":"adminware","full_name":"alces-software/adminware","private":false,"owner":{"login":"alces-software","id":945288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTI4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/alces-software/adminware","description":"A sandbox CLI for running commands remotely across nodes","fork":false,"url":"https://api.github.com/repos/alces-software/adminware","forks_url":"https://api.github.com/repos/alces-software/adminware/forks","keys_url":"https://api.github.com/repos/alces-software/adminware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alces-software/adminware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alces-software/adminware/teams","hooks_url":"https://api.github.com/repos/alces-software/adminware/hooks","issue_events_url":"https://api.github.com/repos/alces-software/adminware/issues/events{/number}","events_url":"https://api.github.com/repos/alces-software/adminware/events","assignees_url":"https://api.github.com/repos/alces-software/adminware/assignees{/user}","branches_url":"https://api.github.com/repos/alces-software/adminware/branches{/branch}","tags_url":"https://api.github.com/repos/alces-software/adminware/tags","blobs_url":"https://api.github.com/repos/alces-software/adminware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alces-software/adminware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alces-software/adminware/git/refs{/sha}","trees_url":"https://api.github.com/repos/alces-software/adminware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alces-software/adminware/statuses/{sha}","languages_url":"https://api.github.com/repos/alces-software/adminware/languages","stargazers_url":"https://api.github.com/repos/alces-software/adminware/stargazers","contributors_url":"https://api.github.com/repos/alces-software/adminware/contributors","subscribers_url":"https://api.github.com/repos/alces-software/adminware/subscribers","subscription_url":"https://api.github.com/repos/alces-software/adminware/subscription","commits_url":"https://api.github.com/repos/alces-software/adminware/commits{/sha}","git_commits_url":"https://api.github.com/repos/alces-software/adminware/git/commits{/sha}","comments_url":"https://api.github.com/repos/alces-software/adminware/comments{/number}","issue_comment_url":"https://api.github.com/repos/alces-software/adminware/issues/comments{/number}","contents_url":"https://api.github.com/repos/alces-software/adminware/contents/{+path}","compare_url":"https://api.github.com/repos/alces-software/adminware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alces-software/adminware/merges","archive_url":"https://api.github.com/repos/alces-software/adminware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alces-software/adminware/downloads","issues_url":"https://api.github.com/repos/alces-software/adminware/issues{/number}","pulls_url":"https://api.github.com/repos/alces-software/adminware/pulls{/number}","milestones_url":"https://api.github.com/repos/alces-software/adminware/milestones{/number}","notifications_url":"https://api.github.com/repos/alces-software/adminware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alces-software/adminware/labels{/name}","releases_url":"https://api.github.com/repos/alces-software/adminware/releases{/id}","deployments_url":"https://api.github.com/repos/alces-software/adminware/deployments","created_at":"2018-02-14T10:54:10Z","updated_at":"2018-10-11T15:45:14Z","pushed_at":"2018-10-11T16:36:11Z","git_url":"git://github.com/alces-software/adminware.git","ssh_url":"git@github.com:alces-software/adminware.git","clone_url":"https://github.com/alces-software/adminware.git","svn_url":"https://github.com/alces-software/adminware","homepage":"","size":357,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":0,"open_issues":14,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/alces-software/adminware/pulls/87"},"html":{"href":"https://github.com/alces-software/adminware/pull/87"},"issue":{"href":"https://api.github.com/repos/alces-software/adminware/issues/87"},"comments":{"href":"https://api.github.com/repos/alces-software/adminware/issues/87/comments"},"review_comments":{"href":"https://api.github.com/repos/alces-software/adminware/pulls/87/comments"},"review_comment":{"href":"https://api.github.com/repos/alces-software/adminware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alces-software/adminware/pulls/87/commits"},"statuses":{"href":"https://api.github.com/repos/alces-software/adminware/statuses/b33498dd7f903c73ce3d5a2c39a68db16ad85a84"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"DavidMarchant"}}