{"action":"created","issue":{"url":"https://api.github.com/repos/vweevers/node-docker-machine/issues/2","repository_url":"https://api.github.com/repos/vweevers/node-docker-machine","labels_url":"https://api.github.com/repos/vweevers/node-docker-machine/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/vweevers/node-docker-machine/issues/2/comments","events_url":"https://api.github.com/repos/vweevers/node-docker-machine/issues/2/events","html_url":"https://github.com/vweevers/node-docker-machine/pull/2","id":178233295,"number":2,"title":"Add Machine.list() function to list machines","user":{"login":"dikarel","id":15131271,"avatar_url":"https://avatars.githubusercontent.com/u/15131271?v=3","gravatar_id":"","url":"https://api.github.com/users/dikarel","html_url":"https://github.com/dikarel","followers_url":"https://api.github.com/users/dikarel/followers","following_url":"https://api.github.com/users/dikarel/following{/other_user}","gists_url":"https://api.github.com/users/dikarel/gists{/gist_id}","starred_url":"https://api.github.com/users/dikarel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dikarel/subscriptions","organizations_url":"https://api.github.com/users/dikarel/orgs","repos_url":"https://api.github.com/users/dikarel/repos","events_url":"https://api.github.com/users/dikarel/events{/privacy}","received_events_url":"https://api.github.com/users/dikarel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-21T03:00:18Z","updated_at":"2016-09-25T12:36:46Z","closed_at":"2016-09-25T09:17:30Z","pull_request":{"url":"https://api.github.com/repos/vweevers/node-docker-machine/pulls/2","html_url":"https://github.com/vweevers/node-docker-machine/pull/2","diff_url":"https://github.com/vweevers/node-docker-machine/pull/2.diff","patch_url":"https://github.com/vweevers/node-docker-machine/pull/2.patch"},"body":"Useful for writing utilities that need to invoke docker-machine ls. \r\n\r\n**Summary**\r\n\r\n- No additional dependencies\r\n- OutputParser utility class to read CLI output into JavaScript objects\r\n- Sample result and explanation in the readme for the new function\r\n- Readme using UNIX line endings\r\n\r\nI explored docker-machine's docs, and found out that the `--format` parameter of the `ls` command doesn't support JSON output (e.g. can't do `{{json .Name}}`). Ended up reformatting the output into tab-delimited lines instead, before parsing them into JavaScript objects.\r\n\r\nTo keep the main class small enough to understand, I modularized parser logic into a separate class.\r\n\r\nI noticed that the line endings used in the project are mixed. I assume for now that UNIX-style is the correct one, as most files in the project use UNIX-style line endings.\r\n\r\nTested on OS X El Capitan\r\n\r\n```bash\r\n$ node examples/list-machines.js\r\n[ { name: 'agent-1',\r\n    active: false,\r\n    activeHost: false,\r\n    activeSwarm: false,\r\n    driverName: 'virtualbox',\r\n    state: 'running',\r\n    url: 'tcp://192.168.99.101:2376',\r\n    swarm: null,\r\n    dockerVersion: '1.12.0',\r\n    responseTime: null,\r\n    error: null },\r\n  { name: 'agent-2',\r\n    active: false,\r\n    activeHost: false,\r\n    activeSwarm: false,\r\n    driverName: 'virtualbox',\r\n    state: 'stopped',\r\n    url: null,\r\n    swarm: null,\r\n    dockerVersion: null,\r\n    responseTime: 475,\r\n    error: null },\r\n  { name: 'default',\r\n    active: true,\r\n    activeHost: true,\r\n    activeSwarm: false,\r\n    driverName: 'virtualbox',\r\n    state: 'running',\r\n    url: 'tcp://192.168.99.100:2376',\r\n    swarm: null,\r\n    dockerVersion: '1.12.0',\r\n    responseTime: null,\r\n    error: null },\r\n  { name: 'testong',\r\n    active: false,\r\n    activeHost: false,\r\n    activeSwarm: false,\r\n    driverName: 'virtualbox',\r\n    state: 'stopped',\r\n    url: null,\r\n    swarm: null,\r\n    dockerVersion: null,\r\n    responseTime: null,\r\n    error: null } ]\r\n\r\n$ node examples/run-command.js ls /\r\nUsers\r\nbin\r\ndev\r\netc\r\nhome\r\ninit\r\nlib\r\nlib64\r\nlinuxrc\r\nmnt\r\nopt\r\nproc\r\nroot\r\nrun\r\nsbin\r\nsys\r\ntmp\r\nusr\r\nvar\r\n```"},"comment":{"url":"https://api.github.com/repos/vweevers/node-docker-machine/issues/comments/249419537","html_url":"https://github.com/vweevers/node-docker-machine/pull/2#issuecomment-249419537","issue_url":"https://api.github.com/repos/vweevers/node-docker-machine/issues/2","id":249419537,"user":{"login":"dikarel","id":15131271,"avatar_url":"https://avatars.githubusercontent.com/u/15131271?v=3","gravatar_id":"","url":"https://api.github.com/users/dikarel","html_url":"https://github.com/dikarel","followers_url":"https://api.github.com/users/dikarel/followers","following_url":"https://api.github.com/users/dikarel/following{/other_user}","gists_url":"https://api.github.com/users/dikarel/gists{/gist_id}","starred_url":"https://api.github.com/users/dikarel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dikarel/subscriptions","organizations_url":"https://api.github.com/users/dikarel/orgs","repos_url":"https://api.github.com/users/dikarel/repos","events_url":"https://api.github.com/users/dikarel/events{/privacy}","received_events_url":"https://api.github.com/users/dikarel/received_events","type":"User","site_admin":false},"created_at":"2016-09-25T12:36:46Z","updated_at":"2016-09-25T12:36:46Z","body":"I'm running 10-20 docker machines on VirtualBox in Windows 7; I noticed that running `docker-machine ls`will return Timeout for *all* machines' states. I think that there are 2 possibilities here:\r\n\r\n1. docker-machine's timeout is applied globally and not per-machine\r\n2. docker-machine is querying all my machines at the same time, causing each of them to respond sluggishly\r\n\r\nI had to increase the timeout for it to work, like this: `docker-machine ls -t 30`\r\n\r\nA configurable timeout option would also be useful in case of busy machines or remote machines over slow connection, as mentioned in [this issue](https://github.com/docker/machine/issues/1696)\r\n\r\nRelevant: https://github.com/docker/machine/commit/02c235b8b91e093fc185713e965fd17d7c462873"}}
{"actor":{"display_login":"dikarel"}}