Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const hasbin = require('hasbin'); | ||
|
||
const providers = Object.keys(require('./providers')); | ||
|
||
const { error } = require('./logger'); | ||
|
||
const depMap = { | ||
'build': [ | ||
() => mustBin('cpio'), | ||
() => mustBin('docker'), | ||
() => mustBin('gzip'), | ||
() => mustBin('mkisofs'), | ||
], | ||
'delete': [], | ||
'images': [], | ||
'run': [], | ||
'vms': [] | ||
} | ||
|
||
const mustBin = bin => { | ||
if (!hasbin.sync(bin)) throw `You must have ${bin} installed to build a microkernel`; | ||
} | ||
|
||
exports.check = argv => { | ||
let cmd = argv._[0]; | ||
|
||
try { | ||
if (providers.length === 0) { | ||
throw 'You don\'t have any providers installed! Please see the docs for a list of supported providers'; | ||
} | ||
|
||
let { provider } = argv; | ||
if (provider && providers.indexOf(provider) === -1) { | ||
throw `Provider ${provider} is not installed! Please see the docs for a list of supported providers`; | ||
} | ||
|
||
depMap[cmd].forEach(d => d(argv)); | ||
} catch (e) { | ||
error(e); | ||
process.exit(1); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
const hasbin = require('hasbin'); | ||
|
||
// TODO add hyperkit | ||
const kvm = require('./providers/kvm'); | ||
const vbox = require('./providers/virtualbox'); | ||
|
||
const providers = {}; | ||
|
||
if (hasbin.sync('virsh')) providers['kvm'] = kvm; | ||
if (hasbin.sync('vboxmanage')) providers['virtualbox'] = vbox; | ||
if (hasbin.sync('virsh')) providers['kvm'] = require('./providers/kvm'); | ||
if (hasbin.sync('vboxmanage')) providers['virtualbox'] = require('./providers/virtualbox'); | ||
|
||
module.exports = providers; |