mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-27 22:40:06 +00:00
Support emulated and nocache options for remote builds
Change-type: minor Closes: #901 Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
parent
5beeb78220
commit
e7c68c1a5c
@ -1274,6 +1274,14 @@ Examples:
|
|||||||
|
|
||||||
The source that should be sent to the resin builder to be built (defaults to the current directory)
|
The source that should be sent to the resin builder to be built (defaults to the current directory)
|
||||||
|
|
||||||
|
#### --emulated, -e
|
||||||
|
|
||||||
|
Force an emulated build to occur on the remote builder
|
||||||
|
|
||||||
|
#### --nocache, -c
|
||||||
|
|
||||||
|
Don't use cache when building this project
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
|
|
||||||
## settings
|
## settings
|
||||||
|
@ -79,6 +79,8 @@ export const push: CommandDefinition<
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: string;
|
source: string;
|
||||||
|
emulated: boolean;
|
||||||
|
nocache: boolean;
|
||||||
}
|
}
|
||||||
> = {
|
> = {
|
||||||
signature: 'push <application>',
|
signature: 'push <application>',
|
||||||
@ -104,6 +106,18 @@ export const push: CommandDefinition<
|
|||||||
'The source that should be sent to the resin builder to be built (defaults to the current directory)',
|
'The source that should be sent to the resin builder to be built (defaults to the current directory)',
|
||||||
parameter: 'source',
|
parameter: 'source',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
signature: 'emulated',
|
||||||
|
alias: 'e',
|
||||||
|
description: 'Force an emulated build to occur on the remote builder',
|
||||||
|
boolean: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
signature: 'nocache',
|
||||||
|
alias: 'c',
|
||||||
|
description: "Don't use cache when building this project",
|
||||||
|
boolean: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
async action(params, options, done) {
|
async action(params, options, done) {
|
||||||
const sdk = (await import('resin-sdk')).fromSharedOptions();
|
const sdk = (await import('resin-sdk')).fromSharedOptions();
|
||||||
@ -126,6 +140,10 @@ export const push: CommandDefinition<
|
|||||||
sdk.settings.get('resinUrl'),
|
sdk.settings.get('resinUrl'),
|
||||||
getAppOwner(sdk, app),
|
getAppOwner(sdk, app),
|
||||||
(token, baseUrl, owner) => {
|
(token, baseUrl, owner) => {
|
||||||
|
const opts = {
|
||||||
|
emulated: options.emulated,
|
||||||
|
nocache: options.nocache,
|
||||||
|
};
|
||||||
const args = {
|
const args = {
|
||||||
app,
|
app,
|
||||||
owner,
|
owner,
|
||||||
@ -133,6 +151,7 @@ export const push: CommandDefinition<
|
|||||||
auth: token,
|
auth: token,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
sdk,
|
sdk,
|
||||||
|
opts,
|
||||||
};
|
};
|
||||||
|
|
||||||
return remote.startRemoteBuild(args);
|
return remote.startRemoteBuild(args);
|
||||||
|
@ -26,12 +26,18 @@ const DEBUG_MODE = !!process.env.DEBUG;
|
|||||||
const CURSOR_METADATA_REGEX = /([a-z]+)([0-9]+)?/;
|
const CURSOR_METADATA_REGEX = /([a-z]+)([0-9]+)?/;
|
||||||
const TRIM_REGEX = /\n+$/;
|
const TRIM_REGEX = /\n+$/;
|
||||||
|
|
||||||
|
export interface BuildOpts {
|
||||||
|
emulated: boolean;
|
||||||
|
nocache: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface RemoteBuild {
|
export interface RemoteBuild {
|
||||||
app: string;
|
app: string;
|
||||||
owner: string;
|
owner: string;
|
||||||
source: string;
|
source: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
opts: BuildOpts;
|
||||||
|
|
||||||
sdk: ResinSDK;
|
sdk: ResinSDK;
|
||||||
|
|
||||||
@ -52,9 +58,15 @@ async function getBuilderEndpoint(
|
|||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
owner: string,
|
owner: string,
|
||||||
app: string,
|
app: string,
|
||||||
|
opts: BuildOpts,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const querystring = await import('querystring');
|
const querystring = await import('querystring');
|
||||||
const args = querystring.stringify({ owner, app });
|
const args = querystring.stringify({
|
||||||
|
owner,
|
||||||
|
app,
|
||||||
|
emulated: opts.emulated,
|
||||||
|
nocache: opts.nocache,
|
||||||
|
});
|
||||||
return `https://builder.${baseUrl}/v3/build?${args}`;
|
return `https://builder.${baseUrl}/v3/build?${args}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +208,12 @@ async function getRequestStream(build: RemoteBuild): Promise<Stream.Duplex> {
|
|||||||
console.log('[debug] Opening builder connection');
|
console.log('[debug] Opening builder connection');
|
||||||
}
|
}
|
||||||
const post = request.post({
|
const post = request.post({
|
||||||
url: await getBuilderEndpoint(build.baseUrl, build.owner, build.app),
|
url: await getBuilderEndpoint(
|
||||||
|
build.baseUrl,
|
||||||
|
build.owner,
|
||||||
|
build.app,
|
||||||
|
build.opts,
|
||||||
|
),
|
||||||
auth: {
|
auth: {
|
||||||
bearer: build.auth,
|
bearer: build.auth,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user