mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-25 00:11:04 +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
|
Copyright 2016 Resin.io
|
||||||
@ -65,8 +65,13 @@ limitations under the License.
|
|||||||
options.port = 22;
|
options.port = 22;
|
||||||
}
|
}
|
||||||
verbose = options.verbose ? '-vvv' : '';
|
verbose = options.verbose ? '-vvv' : '';
|
||||||
return resin.models.device.has(params.uuid).then(function(isValidUUID) {
|
return Promise["try"](function() {
|
||||||
if (isValidUUID) {
|
if (!params.uuid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return resin.models.device.has(params.uuid);
|
||||||
|
}).then(function(uuidExists) {
|
||||||
|
if (uuidExists) {
|
||||||
return params.uuid;
|
return params.uuid;
|
||||||
}
|
}
|
||||||
return patterns.inferOrSelectDevice();
|
return patterns.inferOrSelectDevice();
|
||||||
@ -88,10 +93,10 @@ limitations under the License.
|
|||||||
throw new Error('Did not find running application container');
|
throw new Error('Did not find running application container');
|
||||||
}
|
}
|
||||||
return Promise["try"](function() {
|
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;
|
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);
|
subShellCommand = getSubShellCommand(command);
|
||||||
return spawn = child_process.spawn(subShellCommand.program, subShellCommand.args, {
|
return child_process.spawn(subShellCommand.program, subShellCommand.args, {
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -78,10 +78,11 @@ module.exports =
|
|||||||
|
|
||||||
verbose = if options.verbose then '-vvv' else ''
|
verbose = if options.verbose then '-vvv' else ''
|
||||||
|
|
||||||
resin.models.device.has(params.uuid).then (isValidUUID) ->
|
Promise.try ->
|
||||||
if isValidUUID
|
return false if not params.uuid
|
||||||
return params.uuid
|
return resin.models.device.has(params.uuid)
|
||||||
|
.then (uuidExists) ->
|
||||||
|
return params.uuid if uuidExists
|
||||||
return patterns.inferOrSelectDevice()
|
return patterns.inferOrSelectDevice()
|
||||||
.then (uuid) ->
|
.then (uuid) ->
|
||||||
console.info("Connecting with: #{uuid}")
|
console.info("Connecting with: #{uuid}")
|
||||||
@ -104,6 +105,6 @@ module.exports =
|
|||||||
-p #{options.port} #{username}@ssh.#{settings.get('proxyUrl')} enter #{uuid} #{containerId}"
|
-p #{options.port} #{username}@ssh.#{settings.get('proxyUrl')} enter #{uuid} #{containerId}"
|
||||||
|
|
||||||
subShellCommand = getSubShellCommand(command)
|
subShellCommand = getSubShellCommand(command)
|
||||||
spawn = child_process.spawn subShellCommand.program, subShellCommand.args,
|
child_process.spawn subShellCommand.program, subShellCommand.args,
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
Loading…
Reference in New Issue
Block a user