Skip to content

Commit

Permalink
balena build
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
myarmolinsky committed Nov 5, 2024
1 parent 735af9f commit e33cd3f
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/commands/api-key/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class APIKeyListCmd extends Command {
char: 'u',
description: 'show API keys for your user',
}),
fleet: cf.fleet,
fleet: cf.fleet(),
};

public static authenticated = true;
Expand Down
16 changes: 4 additions & 12 deletions src/commands/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ ${dockerignoreHelp}
arch: Flags.string({
description: 'the architecture to build for',
char: 'A',
exclusive: ['fleet'],
dependsOn: ['deviceType'],
}),
deviceType: Flags.string({
description: 'the type of device this build is for',
char: 'd',
exclusive: ['fleet'],
}),
fleet: cf.fleet,
fleet: cf.fleet({ exclusive: ['deviceType', 'arch'] }),
...composeCliFlags,
...dockerCliFlags,
};
Expand Down Expand Up @@ -148,17 +151,6 @@ ${dockerignoreHelp}
}

protected async validateOptions(opts: FlagsDef, sdk: BalenaSDK) {
// Validate option combinations
if (
(opts.fleet == null && (opts.arch == null || opts.deviceType == null)) ||
(opts.fleet != null && (opts.arch != null || opts.deviceType != null))
) {
const { ExpectedError } = await import('../../errors');
throw new ExpectedError(
'You must specify either a fleet (-f), or the device type (-d) and optionally the architecture (-A)',
);
}

// Validate project directory
const { validateProjectDirectory } = await import('../../utils/compose_ts');
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class ConfigGenerateCmd extends Command {
description: 'a balenaOS version',
required: true,
}),
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: { ...cf.fleet(), exclusive: ['device'] },
dev: cf.dev,
secureBoot: cf.secureBoot,
device: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/device/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class DeviceInitCmd extends Command {
];

public static flags = {
fleet: cf.fleet,
fleet: cf.fleet(),
yes: cf.yes,
advanced: Flags.boolean({
char: 'v',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/device/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class DeviceListCmd extends Command {
];

public static flags = {
fleet: cf.fleet,
fleet: cf.fleet(),
json: cf.json,
};

Expand Down
2 changes: 1 addition & 1 deletion src/commands/device/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class DeviceMoveCmd extends Command {
};

public static flags = {
fleet: cf.fleet,
fleet: cf.fleet(),
};

public static authenticated = true;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/env/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class EnvListCmd extends Command {
];

public static flags = {
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: { ...cf.fleet(), exclusive: ['device'] },
config: Flags.boolean({
default: false,
char: 'c',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/env/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class EnvSetCmd extends Command {
public static strict = false;

public static flags = {
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: { ...cf.fleet(), exclusive: ['device'] },
device: { ...cf.device, exclusive: ['fleet'] },
quiet: cf.quiet,
service: cf.service,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/join/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class JoinCmd extends Command {
};

public static flags = {
fleet: cf.fleet,
fleet: cf.fleet(),
pollInterval: Flags.integer({
description: 'the interval in minutes to check for updates',
char: 'i',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/os/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class OsConfigureCmd extends Command {
description:
'ask advanced configuration questions (when in interactive mode)',
}),
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: { ...cf.fleet(), exclusive: ['device'] },
config: Flags.string({
description:
'path to a pre-generated config.json file to be injected in the OS image',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class PreloadCmd extends Command {
};

public static flags = {
fleet: cf.fleet,
fleet: cf.fleet(),
commit: Flags.string({
description: `\
The commit hash of the release to preload. Use "current" to specify the current
Expand Down
2 changes: 1 addition & 1 deletion src/commands/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class SupportCmd extends Command {
char: 'd',
}),
fleet: {
...cf.fleet,
...cf.fleet(),
description:
'comma-separated list (no spaces) of fleet names or slugs (preferred)',
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tag/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class TagListCmd extends Command {

public static flags = {
fleet: {
...cf.fleet,
...cf.fleet(),
exclusive: ['device', 'release'],
},
device: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tag/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class TagRmCmd extends Command {

public static flags = {
fleet: {
...cf.fleet,
...cf.fleet(),
exclusive: ['device', 'release'],
},
device: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tag/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class TagSetCmd extends Command {

public static flags = {
fleet: {
...cf.fleet,
...cf.fleet(),
exclusive: ['device', 'release'],
},
device: {
Expand Down
13 changes: 8 additions & 5 deletions src/utils/common-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
import { Flags } from '@oclif/core';
import { stripIndent } from './lazy';
import { lowercaseIfSlug } from './normalization';
import type { FlagProps } from '@oclif/core/lib/interfaces/parser';

export const fleet = Flags.string({
char: 'f',
description: 'fleet name or slug (preferred)',
parse: lowercaseIfSlug,
});
export const fleet = (extraOpts?: Partial<FlagProps>) =>
Flags.string({
char: 'f',
description: 'fleet name or slug (preferred)',
parse: lowercaseIfSlug,
...extraOpts,
});

export const device = Flags.string({
char: 'd',
Expand Down

0 comments on commit e33cd3f

Please sign in to comment.