Merge pull request #2255 from balena-io/build-args-warning

Add message regarding deprecation of --buildArg option
This commit is contained in:
bulldozer-balena[bot] 2021-04-21 13:44:15 +00:00 committed by GitHub
commit f45ac42dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
@ -3157,7 +3157,7 @@ don't upload build logs to the dashboard with image (if building)
#### --release-tag RELEASE-TAG
Set release tags if the image deployment is successful. Multiple
Set release tags if the image deployment is successful. Multiple
arguments may be provided, alternating tag keys and values (see examples).
Hint: Empty values may be specified with "" (bash, cmd.exe) or '""' (PowerShell).
@ -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,
@ -127,7 +131,7 @@ ${dockerignoreHelp}
}),
'release-tag': flags.string({
description: stripIndent`
Set release tags if the image deployment is successful. Multiple
Set release tags if the image deployment is successful. Multiple
arguments may be provided, alternating tag keys and values (see examples).
Hint: Empty values may be specified with "" (bash, cmd.exe) or '""' (PowerShell).
`,
@ -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`;