├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── LICENSE ├── README.md ├── index.js ├── package.json └── test └── index.js /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '38 12 * * 5' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'javascript' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | test/npm-debug.log 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | dockermachine node.js module 2 | ============================ 3 | 4 | A node.js wrapper for the docker-machine command line tool 5 | 6 | 7 | ## Installation 8 | 9 | ### Step 1: Prerequisites 10 | 11 | The docker-machine command line tool must be installed and accessible in the path 12 | 13 | 14 | ### Step 2: Installation 15 | 16 | To install it, use npm: 17 | 18 | npm install dockermachine 19 | 20 | 21 | ## The following docker-machine methods are implemented 22 | 23 | - active Get the active machine name 24 | - create Create a machine 25 | - inspect Inspect information about a machine 26 | - ip Get the IP address of a machine 27 | - kill Kill a machine 28 | - ls List machines 29 | - regenerate-certs Regenerate TLS Certificates for a machine 30 | - restart Restart a machine 31 | - rm Remove a machine 32 | - ssh Log into or run a command on a machine with SSH 33 | - start Start a machine 34 | - stop Stop a machine 35 | - upgrade Upgrade a machine to the latest version of Docker 36 | 37 | 38 | ## examples 39 | 40 | ### Specifying options 41 | 42 | Flags to pass to docker machine can be specified by using their fully qualified name without the -- 43 | 44 | Switch the below flags for the provider of your choice, make sure the driver is specified. 45 | 46 | ```javascript 47 | var options = { 48 | "driver" : "softlayer", 49 | "softlayer-api-key" : "XXXXXXXXXXXXXXXXXXXXXXXXXXX", 50 | "softlayer-user" : "your@email.com", 51 | "softlayer-domain" : "mytestdomain.com", 52 | "softlayer-region" : "ams01", 53 | "softlayer-hostname" : "testname" 54 | } 55 | ``` 56 | 57 | 58 | ### Create a machine 59 | 60 | ```javascript 61 | machine.create("mylovelymachine",options).then( 62 | function (output) { 63 | console.log(output); 64 | } 65 | ).fail(function(err){ 66 | 67 | console.log(err); 68 | }) 69 | ``` 70 | 71 | ### Delete a machine 72 | ```javascript 73 | machine.rm("mylovelymachine").then( 74 | function (output) { 75 | console.log(output); 76 | } 77 | ).fail(function(err){ 78 | console.log(err); 79 | }) 80 | ``` 81 | 82 | ### List machines 83 | This will return an array of objects representing each machine 84 | 85 | ```javascript 86 | machine.ls().then( 87 | function (output) { 88 | console.log(output); 89 | } 90 | ).fail(function(err){ 91 | console.log(err); 92 | }) 93 | ``` 94 | 95 | ### Inspect a machine 96 | This will return an object containing details of the named machine 97 | 98 | ```javascript 99 | machine.inspect("mylovelymachine").then( 100 | function (output) { 101 | console.log(output); 102 | } 103 | ).fail(function(err){ 104 | console.log(err); 105 | }) 106 | ``` 107 | ### Tests 108 | 109 | To run unit tests you must have virtualbox installed, a local VM will be created 110 | 111 | ``` 112 | npm test 113 | ``` 114 | 115 | ## License 116 | 117 | ``` 118 | Apache License 119 | Version 2.0, January 2004 120 | http://www.apache.org/licenses/ 121 | 122 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 123 | 124 | 1. Definitions. 125 | 126 | "License" shall mean the terms and conditions for use, reproduction, 127 | and distribution as defined by Sections 1 through 9 of this document. 128 | 129 | "Licensor" shall mean the copyright owner or entity authorized by 130 | the copyright owner that is granting the License. 131 | 132 | "Legal Entity" shall mean the union of the acting entity and all 133 | other entities that control, are controlled by, or are under common 134 | control with that entity. For the purposes of this definition, 135 | "control" means (i) the power, direct or indirect, to cause the 136 | direction or management of such entity, whether by contract or 137 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 138 | outstanding shares, or (iii) beneficial ownership of such entity. 139 | 140 | "You" (or "Your") shall mean an individual or Legal Entity 141 | exercising permissions granted by this License. 142 | 143 | "Source" form shall mean the preferred form for making modifications, 144 | including but not limited to software source code, documentation 145 | source, and configuration files. 146 | 147 | "Object" form shall mean any form resulting from mechanical 148 | transformation or translation of a Source form, including but 149 | not limited to compiled object code, generated documentation, 150 | and conversions to other media types. 151 | 152 | "Work" shall mean the work of authorship, whether in Source or 153 | Object form, made available under the License, as indicated by a 154 | copyright notice that is included in or attached to the work 155 | (an example is provided in the Appendix below). 156 | 157 | "Derivative Works" shall mean any work, whether in Source or Object 158 | form, that is based on (or derived from) the Work and for which the 159 | editorial revisions, annotations, elaborations, or other modifications 160 | represent, as a whole, an original work of authorship. For the purposes 161 | of this License, Derivative Works shall not include works that remain 162 | separable from, or merely link (or bind by name) to the interfaces of, 163 | the Work and Derivative Works thereof. 164 | 165 | "Contribution" shall mean any work of authorship, including 166 | the original version of the Work and any modifications or additions 167 | to that Work or Derivative Works thereof, that is intentionally 168 | submitted to Licensor for inclusion in the Work by the copyright owner 169 | or by an individual or Legal Entity authorized to submit on behalf of 170 | the copyright owner. For the purposes of this definition, "submitted" 171 | means any form of electronic, verbal, or written communication sent 172 | to the Licensor or its representatives, including but not limited to 173 | communication on electronic mailing lists, source code control systems, 174 | and issue tracking systems that are managed by, or on behalf of, the 175 | Licensor for the purpose of discussing and improving the Work, but 176 | excluding communication that is conspicuously marked or otherwise 177 | designated in writing by the copyright owner as "Not a Contribution." 178 | 179 | "Contributor" shall mean Licensor and any individual or Legal Entity 180 | on behalf of whom a Contribution has been received by Licensor and 181 | subsequently incorporated within the Work. 182 | 183 | 2. Grant of Copyright License. Subject to the terms and conditions of 184 | this License, each Contributor hereby grants to You a perpetual, 185 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 186 | copyright license to reproduce, prepare Derivative Works of, 187 | publicly display, publicly perform, sublicense, and distribute the 188 | Work and such Derivative Works in Source or Object form. 189 | 190 | 3. Grant of Patent License. Subject to the terms and conditions of 191 | this License, each Contributor hereby grants to You a perpetual, 192 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 193 | (except as stated in this section) patent license to make, have made, 194 | use, offer to sell, sell, import, and otherwise transfer the Work, 195 | where such license applies only to those patent claims licensable 196 | by such Contributor that are necessarily infringed by their 197 | Contribution(s) alone or by combination of their Contribution(s) 198 | with the Work to which such Contribution(s) was submitted. If You 199 | institute patent litigation against any entity (including a 200 | cross-claim or counterclaim in a lawsuit) alleging that the Work 201 | or a Contribution incorporated within the Work constitutes direct 202 | or contributory patent infringement, then any patent licenses 203 | granted to You under this License for that Work shall terminate 204 | as of the date such litigation is filed. 205 | 206 | 4. Redistribution. You may reproduce and distribute copies of the 207 | Work or Derivative Works thereof in any medium, with or without 208 | modifications, and in Source or Object form, provided that You 209 | meet the following conditions: 210 | 211 | (a) You must give any other recipients of the Work or 212 | Derivative Works a copy of this License; and 213 | 214 | (b) You must cause any modified files to carry prominent notices 215 | stating that You changed the files; and 216 | 217 | (c) You must retain, in the Source form of any Derivative Works 218 | that You distribute, all copyright, patent, trademark, and 219 | attribution notices from the Source form of the Work, 220 | excluding those notices that do not pertain to any part of 221 | the Derivative Works; and 222 | 223 | (d) If the Work includes a "NOTICE" text file as part of its 224 | distribution, then any Derivative Works that You distribute must 225 | include a readable copy of the attribution notices contained 226 | within such NOTICE file, excluding those notices that do not 227 | pertain to any part of the Derivative Works, in at least one 228 | of the following places: within a NOTICE text file distributed 229 | as part of the Derivative Works; within the Source form or 230 | documentation, if provided along with the Derivative Works; or, 231 | within a display generated by the Derivative Works, if and 232 | wherever such third-party notices normally appear. The contents 233 | of the NOTICE file are for informational purposes only and 234 | do not modify the License. You may add Your own attribution 235 | notices within Derivative Works that You distribute, alongside 236 | or as an addendum to the NOTICE text from the Work, provided 237 | that such additional attribution notices cannot be construed 238 | as modifying the License. 239 | 240 | You may add Your own copyright statement to Your modifications and 241 | may provide additional or different license terms and conditions 242 | for use, reproduction, or distribution of Your modifications, or 243 | for any such Derivative Works as a whole, provided Your use, 244 | reproduction, and distribution of the Work otherwise complies with 245 | the conditions stated in this License. 246 | 247 | 5. Submission of Contributions. Unless You explicitly state otherwise, 248 | any Contribution intentionally submitted for inclusion in the Work 249 | by You to the Licensor shall be under the terms and conditions of 250 | this License, without any additional terms or conditions. 251 | Notwithstanding the above, nothing herein shall supersede or modify 252 | the terms of any separate license agreement you may have executed 253 | with Licensor regarding such Contributions. 254 | 255 | 6. Trademarks. This License does not grant permission to use the trade 256 | names, trademarks, service marks, or product names of the Licensor, 257 | except as required for reasonable and customary use in describing the 258 | origin of the Work and reproducing the content of the NOTICE file. 259 | 260 | 7. Disclaimer of Warranty. Unless required by applicable law or 261 | agreed to in writing, Licensor provides the Work (and each 262 | Contributor provides its Contributions) on an "AS IS" BASIS, 263 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 264 | implied, including, without limitation, any warranties or conditions 265 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 266 | PARTICULAR PURPOSE. You are solely responsible for determining the 267 | appropriateness of using or redistributing the Work and assume any 268 | risks associated with Your exercise of permissions under this License. 269 | 270 | 8. Limitation of Liability. In no event and under no legal theory, 271 | whether in tort (including negligence), contract, or otherwise, 272 | unless required by applicable law (such as deliberate and grossly 273 | negligent acts) or agreed to in writing, shall any Contributor be 274 | liable to You for damages, including any direct, indirect, special, 275 | incidental, or consequential damages of any character arising as a 276 | result of this License or out of the use or inability to use the 277 | Work (including but not limited to damages for loss of goodwill, 278 | work stoppage, computer failure or malfunction, or any and all 279 | other commercial damages or losses), even if such Contributor 280 | has been advised of the possibility of such damages. 281 | 282 | 9. Accepting Warranty or Additional Liability. While redistributing 283 | the Work or Derivative Works thereof, You may choose to offer, 284 | and charge a fee for, acceptance of support, warranty, indemnity, 285 | or other liability obligations and/or rights consistent with this 286 | License. However, in accepting such obligations, You may act only 287 | on Your own behalf and on Your sole responsibility, not on behalf 288 | of any other Contributor, and only if You agree to indemnify, 289 | defend, and hold each Contributor harmless for any liability 290 | incurred by, or claims asserted against, such Contributor by reason 291 | of your accepting any such warranty or additional liability. 292 | 293 | END OF TERMS AND CONDITIONS 294 | 295 | 296 | ``` 297 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | var q = require("q"); 18 | var os = require("os"); 19 | 20 | module.exports = { 21 | 22 | 23 | ls: function(callback) { 24 | 25 | var d = q.defer(); 26 | 27 | var exec = require('child_process').exec; 28 | exec('docker-machine ls', function (error, stdout, stderr) { 29 | 30 | if(error) { 31 | d.reject(stderr); 32 | return; 33 | } 34 | 35 | 36 | //NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS 37 | //default - virtualbox Running tcp://192.168.99.100:2376 v1.10.3 38 | 39 | //remove all end of line 40 | var lines = stdout.split(/\r?\n/); 41 | 42 | 43 | 44 | //getting the start and end positions for the subsequent substr operation 45 | var letterboundaries = []; 46 | letterboundaries.push(0); 47 | 48 | var headerline = lines[0]; 49 | 50 | for(var i=0;i", 18 | "license": "Apache-2.0", 19 | "dependencies": { 20 | "q": "~1.2.0" 21 | }, 22 | "devDependencies": { 23 | "mocha": "~2.2.5", 24 | "chai": "~2.3.0" 25 | }, 26 | "repository" : { 27 | "type":"git", 28 | "url":"https://github.com/zekizeki/nodeDockerMachine.git" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var should = require('chai').should() 2 | var expect = require('chai').expect; 3 | machine = require('../index'); 4 | 5 | var softlayerUser = process.env.SL_USER; 6 | var softlayerAPI = process.env.SL_API_KEY; 7 | 8 | /* 9 | var options = { 10 | "driver" : "softlayer", 11 | "softlayer-api-key" : softlayerAPI, 12 | "softlayer-user" : softlayerUser, 13 | "softlayer-domain" : "testdomain.com", 14 | "softlayer-region" : "ams01", 15 | "softlayer-hostname" : "mochatest" 16 | 17 | } 18 | */ 19 | 20 | // test locally and for free using virtualbox 21 | var options = { 22 | "driver" : "virtualbox" 23 | } 24 | 25 | 26 | 27 | var machineName = "mochatest"; 28 | 29 | 30 | describe('#create',function() { 31 | 32 | it('create a machine', function(done) { 33 | 34 | // no timeout, creating the machine could take a while 35 | this.timeout(0); 36 | 37 | machine.create(machineName,options).then( 38 | function (output) { 39 | console.log(output); 40 | output.should.have.property('Driver'); 41 | done(); 42 | } 43 | ).fail(function(err){ 44 | 45 | done(err); 46 | }) 47 | 48 | }); 49 | }); 50 | 51 | describe('#ls',function() { 52 | it('lists out some machines', function(done) { 53 | machine.ls().then( 54 | function (output) { 55 | console.log(output); 56 | output.should.be.instanceof(Array); 57 | expect(output).to.have.length.above(0); 58 | done(); 59 | } 60 | ).fail(function(err){ 61 | 62 | done(err); 63 | }) 64 | 65 | }); 66 | 67 | it('lists out some machines using a callback', function(done) { 68 | machine.ls(function (err,result) { 69 | 70 | if(err) { 71 | err.should.not.exist; 72 | done(); 73 | } 74 | 75 | result.should.be.instanceof(Array); 76 | expect(result).to.have.length.above(0); 77 | done(); 78 | }) 79 | 80 | }); 81 | 82 | }); 83 | 84 | describe('#active',function() { 85 | 86 | 87 | it('gets the active machine', function(done) { 88 | 89 | // no timeout, creating the machine could take a while 90 | this.timeout(0); 91 | 92 | machine.active().then( 93 | function (output) { 94 | console.log(output); 95 | output.should.be.a('string'); 96 | done(); 97 | } 98 | ).fail(function(err){ 99 | err.should.have.string('No active host found'); 100 | done(); 101 | }) 102 | 103 | }); 104 | 105 | 106 | }); 107 | 108 | 109 | 110 | 111 | describe('#inspect',function() { 112 | 113 | 114 | it('inspect a machine', function(done) { 115 | 116 | // no timeout, creating the machine could take a while 117 | this.timeout(0); 118 | 119 | machine.inspect(machineName).then( 120 | function (output) { 121 | 122 | output.should.have.property('Driver'); 123 | done(); 124 | } 125 | ).fail(function(err){ 126 | 127 | done(err); 128 | }) 129 | 130 | }); 131 | 132 | it('inspect a non existent machine', function(done) { 133 | 134 | // no timeout, creating the machine could take a while 135 | this.timeout(0); 136 | 137 | machine.inspect("notarealmachine").then( 138 | function (output) { 139 | done(output); 140 | } 141 | ).fail(function(err){ 142 | 143 | err.should.have.string('Host does not exist'); 144 | done(); 145 | }) 146 | 147 | }); 148 | }); 149 | 150 | 151 | 152 | describe('#kill',function() { 153 | 154 | 155 | it('kill a machine ', function(done) { 156 | 157 | // no timeout, creating the machine could take a while 158 | this.timeout(0); 159 | 160 | machine.kill(machineName).then( 161 | function (output) { 162 | console.log(output); 163 | output.should.be.a('string'); 164 | done(); 165 | } 166 | ).fail(function(err){ 167 | 168 | done(err); 169 | }) 170 | 171 | }); 172 | 173 | 174 | }); 175 | 176 | 177 | describe('#rm',function() { 178 | 179 | 180 | it('remove a machine', function(done) { 181 | 182 | // no timeout, deleting the machine could take a while 183 | this.timeout(0); 184 | 185 | machine.rm(machineName).then( 186 | function (output) { 187 | console.log(output); 188 | output.should.be.a('string'); 189 | done(); 190 | } 191 | ).fail(function(err){ 192 | 193 | done(err); 194 | }) 195 | 196 | }); 197 | 198 | 199 | }); 200 | --------------------------------------------------------------------------------