mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-28 23:24:16 +00:00
More cleanup
Change-type: patch Signed-off-by: Josh Bowling <josh@balena.io>
This commit is contained in:
parent
3d788fa0a9
commit
b242e15fdd
@ -41,7 +41,7 @@ import * as LocalPushErrors from './errors';
|
|||||||
import LivepushManager from './live';
|
import LivepushManager from './live';
|
||||||
import { displayBuildLog } from './logs';
|
import { displayBuildLog } from './logs';
|
||||||
import { getBalenaSdk, stripIndent } from '../lazy';
|
import { getBalenaSdk, stripIndent } from '../lazy';
|
||||||
import { validateIPAddress } from '../validation';
|
import { validateUuid } from '../validation';
|
||||||
import { openTunnel } from '../tunnel';
|
import { openTunnel } from '../tunnel';
|
||||||
|
|
||||||
const LOCAL_APPNAME = 'localapp';
|
const LOCAL_APPNAME = 'localapp';
|
||||||
@ -124,14 +124,8 @@ async function environmentFromInput(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
||||||
// Can only communicate with device using IP if local
|
// Set up tunnels for remote device
|
||||||
const isLocal =
|
if (validateUuid(opts.deviceHost)) {
|
||||||
opts.deviceHost.includes('.local') || validateIPAddress(opts.deviceHost)
|
|
||||||
? true
|
|
||||||
: false;
|
|
||||||
if (!isLocal) {
|
|
||||||
// 1. Open tunnel from remote device to localhost
|
|
||||||
// 2. Deploy to localhost
|
|
||||||
const logger = Logger.getLogger();
|
const logger = Logger.getLogger();
|
||||||
const sdk = getBalenaSdk();
|
const sdk = getBalenaSdk();
|
||||||
|
|
||||||
@ -139,11 +133,11 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
|||||||
const { getOnlineTargetDeviceUuid } = await import('../patterns');
|
const { getOnlineTargetDeviceUuid } = await import('../patterns');
|
||||||
const uuid = await getOnlineTargetDeviceUuid(sdk, opts.deviceHost);
|
const uuid = await getOnlineTargetDeviceUuid(sdk, opts.deviceHost);
|
||||||
const device = await sdk.models.device.get(uuid);
|
const device = await sdk.models.device.get(uuid);
|
||||||
logger.logInfo(`Opening a tunnel to ${device.uuid}...`);
|
logger.logInfo(`Opening tunnels to ${device.uuid}...`);
|
||||||
|
|
||||||
await openTunnel(logger, device, sdk, 48484, 'localhost', 48484);
|
await openTunnel(logger, device, sdk, 48484, 'localhost', 48484);
|
||||||
await openTunnel(logger, device, sdk, 2375, 'localhost', 2375);
|
await openTunnel(logger, device, sdk, 2375, 'localhost', 2375);
|
||||||
logger.logInfo('Opened tunnels to supervisor and docker...');
|
logger.logInfo(`Opened tunnels to ${device.uuid}...`);
|
||||||
|
|
||||||
opts.deviceHost = 'localhost';
|
opts.deviceHost = 'localhost';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user