mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 06:07:55 +00:00
Merge pull request #424 from resin-io/ssh-handle-undefined-uuid
resin ssh: handle undefined uuid parameter
This commit is contained in:
commit
5ebdf4a8ac
@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.12.2
|
||||
// Generated by CoffeeScript 1.12.4
|
||||
|
||||
/*
|
||||
Copyright 2016 Resin.io
|
||||
@ -65,8 +65,13 @@ limitations under the License.
|
||||
options.port = 22;
|
||||
}
|
||||
verbose = options.verbose ? '-vvv' : '';
|
||||
return resin.models.device.has(params.uuid).then(function(isValidUUID) {
|
||||
if (isValidUUID) {
|
||||
return Promise["try"](function() {
|
||||
if (!params.uuid) {
|
||||
return false;
|
||||
}
|
||||
return resin.models.device.has(params.uuid);
|
||||
}).then(function(uuidExists) {
|
||||
if (uuidExists) {
|
||||
return params.uuid;
|
||||
}
|
||||
return patterns.inferOrSelectDevice();
|
||||
@ -88,10 +93,10 @@ limitations under the License.
|
||||
throw new Error('Did not find running application container');
|
||||
}
|
||||
return Promise["try"](function() {
|
||||
var command, spawn, subShellCommand;
|
||||
var command, subShellCommand;
|
||||
command = "ssh " + verbose + " -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no -p " + options.port + " " + username + "@ssh." + (settings.get('proxyUrl')) + " enter " + uuid + " " + containerId;
|
||||
subShellCommand = getSubShellCommand(command);
|
||||
return spawn = child_process.spawn(subShellCommand.program, subShellCommand.args, {
|
||||
return child_process.spawn(subShellCommand.program, subShellCommand.args, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
});
|
||||
|
@ -78,10 +78,11 @@ module.exports =
|
||||
|
||||
verbose = if options.verbose then '-vvv' else ''
|
||||
|
||||
resin.models.device.has(params.uuid).then (isValidUUID) ->
|
||||
if isValidUUID
|
||||
return params.uuid
|
||||
|
||||
Promise.try ->
|
||||
return false if not params.uuid
|
||||
return resin.models.device.has(params.uuid)
|
||||
.then (uuidExists) ->
|
||||
return params.uuid if uuidExists
|
||||
return patterns.inferOrSelectDevice()
|
||||
.then (uuid) ->
|
||||
console.info("Connecting with: #{uuid}")
|
||||
@ -104,6 +105,6 @@ module.exports =
|
||||
-p #{options.port} #{username}@ssh.#{settings.get('proxyUrl')} enter #{uuid} #{containerId}"
|
||||
|
||||
subShellCommand = getSubShellCommand(command)
|
||||
spawn = child_process.spawn subShellCommand.program, subShellCommand.args,
|
||||
child_process.spawn subShellCommand.program, subShellCommand.args,
|
||||
stdio: 'inherit'
|
||||
.nodeify(done)
|
||||
|
Loading…
Reference in New Issue
Block a user