push: Add detached flag to avoid streaming logs after local push

Change-type: minor
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-04-24 14:31:30 +01:00
parent 375464eb1a
commit 97c15208b5
3 changed files with 24 additions and 3 deletions

View File

@ -1464,13 +1464,17 @@ Path to a local YAML or JSON file containing Docker registry passwords used to p
Note this feature is in beta.
Start a live session with the containers pushed to a local-mode device.
Start a live session with the containers pushed to a local mode device.
The project source folder is watched for filesystem events, and changes
to files and folders are automatically synchronized to the running
containers. The synchronisation is only in one direction, from this machine to
the device, and changes made on the device itself may be overwritten.
This feature requires a device running supervisor version v9.7.0 or greater.
#### --detached, -d
Don't tail application logs when pushing to a local mode device
# Settings
## settings

View File

@ -107,6 +107,7 @@ export const push: CommandDefinition<
nocache: boolean;
'registry-secrets': string;
live: boolean;
detached: boolean;
}
> = {
signature: 'push <applicationOrDevice>',
@ -184,13 +185,19 @@ export const push: CommandDefinition<
description: stripIndent`
Note this feature is in beta.
Start a live session with the containers pushed to a local-mode device.
Start a live session with the containers pushed to a local mode device.
The project source folder is watched for filesystem events, and changes
to files and folders are automatically synchronized to the running
containers. The synchronisation is only in one direction, from this machine to
the device, and changes made on the device itself may be overwritten.
This feature requires a device running supervisor version v9.7.0 or greater.`,
},
{
signature: 'detached',
alias: 'd',
description: `Don't tail application logs when pushing to a local mode device`,
boolean: true,
},
],
async action(params, options, done) {
const sdk = (await import('balena-sdk')).fromSharedOptions();
@ -230,7 +237,12 @@ export const push: CommandDefinition<
// Ensure that the live argument has not been passed to a cloud build
if (options.live) {
exitWithExpectedError(
'The --live flag is only valid when pushing to a local device.',
'The --live flag is only valid when pushing to a local mode device',
);
}
if (options.detached) {
exitWithExpectedError(
`The --detached flag is only valid when pushing to a local mode device.`,
);
}
@ -272,6 +284,7 @@ export const push: CommandDefinition<
registrySecrets,
nocache: options.nocache || false,
live: options.live || false,
detached: options.detached || false,
}),
)
.catch(BuildError, e => {

View File

@ -47,6 +47,7 @@ export interface DeviceDeployOptions {
registrySecrets: RegistrySecrets;
nocache: boolean;
live: boolean;
detached: boolean;
}
async function checkSource(source: string): Promise<boolean> {
@ -146,6 +147,9 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
await api.setTargetState(targetState);
if (opts.detached) {
return;
}
// Print an empty newline to separate the build output
// from the device output
console.log();