Add message regarding deprecation of --buildArg option in build/deploy commands

Change-type: patch
Signed-off-by: Scott Lowe <scott@balena.io>
This commit is contained in:
Scott Lowe 2021-04-21 07:26:57 +02:00
parent ba1ea54d69
commit fa26004648
5 changed files with 34 additions and 7 deletions

View File

@ -2987,7 +2987,7 @@ The alias to the generated image
#### -B, --buildArg BUILDARG
Set a build-time variable (eg. "-B 'ARG=value'"). Can be specified multiple times.
[Deprecated] Set a build-time variable (eg. "-B 'ARG=value'"). Can be specified multiple times.
#### --cache-from CACHE-FROM
@ -3217,7 +3217,7 @@ The alias to the generated image
#### -B, --buildArg BUILDARG
Set a build-time variable (eg. "-B 'ARG=value'"). Can be specified multiple times.
[Deprecated] Set a build-time variable (eg. "-B 'ARG=value'"). Can be specified multiple times.
#### --cache-from CACHE-FROM

View File

@ -20,7 +20,11 @@ import Command from '../command';
import { getBalenaSdk } from '../utils/lazy';
import * as compose from '../utils/compose';
import type { Application, ApplicationType, BalenaSDK } from 'balena-sdk';
import { dockerignoreHelp, registrySecretsHelp } from '../utils/messages';
import {
buildArgDeprecation,
dockerignoreHelp,
registrySecretsHelp,
} from '../utils/messages';
import type { ComposeCliFlags, ComposeOpts } from '../utils/compose-types';
import { buildProject, composeCliFlags } from '../utils/compose_ts';
import type { BuildOpts, DockerCliFlags } from '../utils/docker';
@ -122,6 +126,11 @@ ${dockerignoreHelp}
await this.validateOptions(options, sdk);
// Build args are under consideration for removal - warn user
if (options.buildArg) {
console.log(buildArgDeprecation);
}
const app = await this.getAppAndResolveArch(options);
const { docker, buildOpts, composeOpts } = await this.prepareBuild(options);

View File

@ -21,7 +21,11 @@ import type { ImageDescriptor } from 'resin-compose-parse';
import Command from '../command';
import { ExpectedError } from '../errors';
import { getBalenaSdk, getChalk, stripIndent } from '../utils/lazy';
import { dockerignoreHelp, registrySecretsHelp } from '../utils/messages';
import {
dockerignoreHelp,
registrySecretsHelp,
buildArgDeprecation,
} from '../utils/messages';
import * as compose from '../utils/compose';
import type {
BuiltImage,
@ -158,6 +162,11 @@ ${dockerignoreHelp}
const { appName, image } = params;
// Build args are under consideration for removal - warn user
if (options.buildArg) {
console.log(buildArgDeprecation);
}
if (image != null && options.build) {
throw new ExpectedError(
'Build option is not applicable when specifying an image',

View File

@ -79,7 +79,7 @@ export const dockerCliFlags: flags.Input<DockerCliFlags> = {
}),
buildArg: flags.string({
description:
'Set a build-time variable (eg. "-B \'ARG=value\'"). Can be specified multiple times.',
'[Deprecated] Set a build-time variable (eg. "-B \'ARG=value\'"). Can be specified multiple times.',
char: 'B',
multiple: true,
}),

View File

@ -134,3 +134,12 @@ because field names are less likely to change in JSON format and because it
better represents data types like arrays, empty strings and null values.
The 'jq' utility may be helpful for querying JSON fields in shell scripts
(https://stedolan.github.io/jq/manual/).`;
export const buildArgDeprecation = `\
WARNING: You have specified a '--buildArg' option, which is now deprecated, and
may be removed in the future. The recommended alternative is build-time secrets:
https://www.balena.io/docs/learn/deploy/deployment/#build-time-secrets-and-variables
If you have a particular use for buildArg, which is not satisfied by build-time
secrets, please contact us via support or the forums: https://forums.balena.io/
\n`;