From 626d32819471f0793fdca69cccb008547ffdded0 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Tue, 2 Jun 2020 16:42:51 +0100 Subject: [PATCH] v12 preparations: Add feature switch for build/deploy `--logs` option Connects-to: #1770 Change-type: patch --- lib/utils/compose.js | 16 ++++++++++++++-- tests/commands/build.spec.ts | 24 +++++++++++++++++++----- tests/commands/deploy.spec.ts | 5 ++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/utils/compose.js b/lib/utils/compose.js index 64f499f7..da19943d 100644 --- a/lib/utils/compose.js +++ b/lib/utils/compose.js @@ -50,9 +50,21 @@ export function appendOptions(opts) { }, { signature: 'logs', - description: 'Display full log output', + description: isV12() + ? 'No-op and deprecated since balena CLI v12.0.0. Build logs are now shown by default.' + : 'Display full log output', boolean: true, }, + ...(isV12() + ? [ + { + signature: 'nologs', + description: + 'Hide the image build log output (produce less verbose output)', + boolean: true, + }, + ] + : []), { signature: 'nogitignore', description: isV12() @@ -98,7 +110,7 @@ export function generateOpts(options) { return fs.realpath(options.source || '.').then(projectPath => ({ projectName: options.projectName, projectPath, - inlineLogs: !!options.logs, + inlineLogs: !options.nologs && (!!options.logs || isV12()), dockerfilePath: options.dockerfile, nogitignore: !!options.nogitignore || isV12(), noParentCheck: options['noparent-check'], diff --git a/tests/commands/build.spec.ts b/tests/commands/build.spec.ts index bfcc5700..a460782d 100644 --- a/tests/commands/build.spec.ts +++ b/tests/commands/build.spec.ts @@ -24,6 +24,7 @@ import mock = require('mock-require'); import { fs } from 'mz'; import * as path from 'path'; +import { isV12 } from '../../build/utils/version'; import { BalenaAPIMock } from '../balena-api-mock'; import { expectStreamNoCRLF, testDockerBuildStream } from '../docker-build'; import { DockerMock, dockerResponsePath } from '../docker-mock'; @@ -98,7 +99,9 @@ describe('balena build', function() { ...commonResponseLines[responseFilename], `[Info] No "docker-compose.yml" file found at "${projectPath}"`, `[Info] Creating default composition with source: "${projectPath}"`, - '[Build] main Image size: 1.14 MB', + isV12() + ? '[Build] main Step 1/4 : FROM busybox' + : '[Build] main Image size: 1.14 MB', ]; if (isWindows) { expectedResponseLines.push( @@ -153,7 +156,9 @@ describe('balena build', function() { `[Info] Creating default composition with source: "${projectPath}"`, '[Info] Building for rpi/raspberry-pi', '[Info] Emulation is enabled', - '[Build] main Image size: 1.14 MB', + isV12() + ? '[Build] main Step 1/4 : FROM busybox' + : '[Build] main Image size: 1.14 MB', '[Success] Build succeeded!', ]; if (isWindows) { @@ -223,7 +228,9 @@ describe('balena build', function() { ...commonResponseLines[responseFilename], `[Info] No "docker-compose.yml" file found at "${projectPath}"`, `[Info] Creating default composition with source: "${projectPath}"`, - '[Build] main Image size: 1.14 MB', + isV12() + ? '[Build] main Step 1/4 : FROM busybox' + : '[Build] main Image size: 1.14 MB', ]; if (isWindows) { expectedResponseLines.push( @@ -293,8 +300,15 @@ describe('balena build', function() { }; const expectedResponseLines: string[] = [ ...commonResponseLines[responseFilename], - `[Build] service1 Image size: 1.14 MB`, - `[Build] service2 Image size: 1.14 MB`, + ...(isV12() + ? [ + '[Build] service1 Step 1/4 : FROM busybox', + '[Build] service2 Step 1/4 : FROM busybox', + ] + : [ + `[Build] service1 Image size: 1.14 MB`, + `[Build] service2 Image size: 1.14 MB`, + ]), ]; if (isWindows) { expectedResponseLines.push( diff --git a/tests/commands/deploy.spec.ts b/tests/commands/deploy.spec.ts index 60985a0b..e2fadbec 100644 --- a/tests/commands/deploy.spec.ts +++ b/tests/commands/deploy.spec.ts @@ -23,6 +23,7 @@ import { fs } from 'mz'; import * as path from 'path'; import * as sinon from 'sinon'; +import { isV12 } from '../../build/utils/version'; import { BalenaAPIMock } from '../balena-api-mock'; import { testDockerBuildStream } from '../docker-build'; import { DockerMock, dockerResponsePath } from '../docker-mock'; @@ -38,7 +39,9 @@ const commonResponseLines = { '[Info] Docker Desktop detected (daemon architecture: "x86_64")', '[Info] Docker itself will determine and enable architecture emulation if required,', '[Info] without balena-cli intervention and regardless of the --emulated option.', - '[Build] main Image size: 1.14 MB', + isV12() + ? '[Build] main Step 1/4 : FROM busybox' + : '[Build] main Image size: 1.14 MB', '[Info] Creating release...', '[Info] Pushing images to registry...', '[Info] Saving release...',