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:
Cameron Diver 2018-06-21 14:29:25 +01:00
parent 5beeb78220
commit e7c68c1a5c
No known key found for this signature in database
GPG Key ID: 69264F9C923F55C1
3 changed files with 46 additions and 2 deletions

View File

@ -1274,6 +1274,14 @@ Examples:
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

View File

@ -79,6 +79,8 @@ export const push: CommandDefinition<
},
{
source: string;
emulated: boolean;
nocache: boolean;
}
> = {
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)',
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) {
const sdk = (await import('resin-sdk')).fromSharedOptions();
@ -126,6 +140,10 @@ export const push: CommandDefinition<
sdk.settings.get('resinUrl'),
getAppOwner(sdk, app),
(token, baseUrl, owner) => {
const opts = {
emulated: options.emulated,
nocache: options.nocache,
};
const args = {
app,
owner,
@ -133,6 +151,7 @@ export const push: CommandDefinition<
auth: token,
baseUrl,
sdk,
opts,
};
return remote.startRemoteBuild(args);

View File

@ -26,12 +26,18 @@ const DEBUG_MODE = !!process.env.DEBUG;
const CURSOR_METADATA_REGEX = /([a-z]+)([0-9]+)?/;
const TRIM_REGEX = /\n+$/;
export interface BuildOpts {
emulated: boolean;
nocache: boolean;
}
export interface RemoteBuild {
app: string;
owner: string;
source: string;
auth: string;
baseUrl: string;
opts: BuildOpts;
sdk: ResinSDK;
@ -52,9 +58,15 @@ async function getBuilderEndpoint(
baseUrl: string,
owner: string,
app: string,
opts: BuildOpts,
): Promise<string> {
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}`;
}
@ -196,7 +208,12 @@ async function getRequestStream(build: RemoteBuild): Promise<Stream.Duplex> {
console.log('[debug] Opening builder connection');
}
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: {
bearer: build.auth,
},