Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update balena-multibuild to 5.1.0 #2358

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { flags } from '@oclif/command';
import type { ImageDescriptor } from 'resin-compose-parse';
import type { ImageDescriptor } from '@balena/compose-parse';

import Command from '../command';
import { ExpectedError } from '../errors';
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { dockerignoreHelp, registrySecretsHelp } from '../utils/messages';
import type { BalenaSDK } from 'balena-sdk';
import { ExpectedError, instanceOf } from '../errors';
import { isV13 } from '../utils/version';
import { RegistrySecrets } from 'resin-multibuild';
import { RegistrySecrets } from '@balena/multibuild';
import { lowercaseIfSlug } from '../utils/normalization';
import {
applyReleaseTagKeysAndValues,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/compose-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import type { Composition, ImageDescriptor } from 'resin-compose-parse';
import type { Composition, ImageDescriptor } from '@balena/compose-parse';
import type { Pack } from 'tar-stream';

interface Image {
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function createProject(
imageTag = '',
) {
const yml = require('js-yaml');
const compose = require('resin-compose-parse');
const compose = require('@balena/compose-parse');

// both methods below may throw.
const rawComposition = yml.load(composeStr);
Expand Down Expand Up @@ -116,7 +116,7 @@ export async function originalTarDirectory(dir, param) {
const streamToPromise = require('stream-to-promise');
const { printGitignoreWarn } = require('./compose_ts');
const { FileIgnorer, IgnoreFileType } = require('./ignore');
const { toPosixPath } = require('resin-multibuild').PathUtils;
const { toPosixPath } = require('@balena/multibuild').PathUtils;
let readFile;
if (process.platform === 'win32') {
const { readFileWithEolConversion } = require('./eol-conversion');
Expand Down Expand Up @@ -180,7 +180,7 @@ export async function originalTarDirectory(dir, param) {
* @param {string} auth
* @param {number} userId
* @param {number} appId
* @param {import('resin-compose-parse').Composition} composition
* @param {import('@balena/compose-parse').Composition} composition
* @param {boolean} draft
* @param {string|undefined} semver
* @param {string|undefined} contract
Expand Down Expand Up @@ -301,7 +301,7 @@ export const getPreviousRepos = (sdk, logger, appID) =>
// grab all images from the latest release, return all image locations in the registry
if (release.length > 0) {
const images = release[0].contains__image;
const { getRegistryAndName } = require('resin-multibuild');
const { getRegistryAndName } = require('@balena/multibuild');
return Promise.all(
images.map(function (d) {
const imageName = d.image[0].is_stored_at__image_location || '';
Expand Down
30 changes: 15 additions & 15 deletions lib/utils/compose_ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import type {
BuildConfig,
Composition,
ImageDescriptor,
} from 'resin-compose-parse';
import type * as MultiBuild from 'resin-multibuild';
} from '@balena/compose-parse';
import type * as MultiBuild from '@balena/multibuild';
import type { Duplex, Readable } from 'stream';
import type { Pack } from 'tar-stream';

Expand Down Expand Up @@ -120,7 +120,7 @@ export async function loadProject(
image?: string,
imageTag?: string,
): Promise<ComposeProject> {
const compose = await import('resin-compose-parse');
const compose = await import('@balena/compose-parse');
const { createProject } = await import('./compose');
let composeName: string;
let composeStr: string;
Expand Down Expand Up @@ -265,7 +265,7 @@ export async function buildProject(
opts: BuildProjectOpts,
): Promise<BuiltImage[]> {
await checkBuildSecretsRequirements(opts.docker, opts.projectPath);
const compose = await import('resin-compose-parse');
const compose = await import('@balena/compose-parse');
const imageDescriptors = compose.parse(opts.composition);
const renderer = await startRenderer({ imageDescriptors, ...opts });
let buildSummaryByService: Dictionary<string> | undefined;
Expand Down Expand Up @@ -336,7 +336,7 @@ async function $buildProject(
logger.logDebug('Prepared tasks; building...');

const { BALENA_ENGINE_TMP_PATH } = await import('../config');
const builder = await import('resin-multibuild');
const builder = await import('@balena/multibuild');

const builtImages = await builder.performBuilds(
tasks,
Expand Down Expand Up @@ -485,7 +485,7 @@ async function qemuTransposeBuildStream({
}

const transpose = await import('docker-qemu-transpose');
const { toPosixPath } = (await import('resin-multibuild')).PathUtils;
const { toPosixPath } = (await import('@balena/multibuild')).PathUtils;

const transposeOptions: TransposeOptions = {
hostQemuPath: toPosixPath(binPath),
Expand Down Expand Up @@ -727,16 +727,16 @@ export async function getServiceDirsFromComposition(
*
* The `image` argument may therefore refer to either a `build` or `image` property
* of a service in a docker-compose.yml file, which is a bit confusing but it matches
* the `ImageDescriptor.image` property as defined by `resin-compose-parse`.
* the `ImageDescriptor.image` property as defined by `@balena/compose-parse`.
*
* Note that `resin-compose-parse` "normalizes" the docker-compose.yml file such
* Note that `@balena/compose-parse` "normalizes" the docker-compose.yml file such
* that, if `services.service.build` is a string, it is converted to a BuildConfig
* object with the string value assigned to `services.service.build.context`:
* https://github.com/balena-io-modules/resin-compose-parse/blob/v2.1.3/src/compose.ts#L166-L167
* https://github.com/balena-io-modules/balena-compose-parse/blob/v3.0.0/src/compose.ts#L314-L315
* This is why this implementation works when `services.service.build` is defined
* as a string in the docker-compose.yml file.
*
* @param image The `ImageDescriptor.image` attribute parsed with `resin-compose-parse`
* @param image The `ImageDescriptor.image` attribute parsed with `@balena/compose-parse`
*/
export function isBuildConfig(
image: string | BuildConfig,
Expand Down Expand Up @@ -786,7 +786,7 @@ async function newTarDirectory(
require('assert').strict.equal(nogitignore, true);
}
const { filterFilesWithDockerignore } = await import('./ignore');
const { toPosixPath } = (await import('resin-multibuild')).PathUtils;
const { toPosixPath } = (await import('@balena/multibuild')).PathUtils;

let readFile: (file: string) => Promise<Buffer>;
if (process.platform === 'win32') {
Expand Down Expand Up @@ -1010,7 +1010,7 @@ async function parseRegistrySecrets(
throw new ExpectedError('Filename must end with .json, .yml or .yaml');
}
const raw = (await fs.readFile(secretsFilename)).toString();
const multiBuild = await import('resin-multibuild');
const multiBuild = await import('@balena/multibuild');
const registrySecrets =
new multiBuild.RegistrySecretValidator().validateRegistrySecrets(
isYaml ? require('js-yaml').load(raw) : JSON.parse(raw),
Expand Down Expand Up @@ -1039,7 +1039,7 @@ export async function makeBuildTasks(
releaseHash: string = 'unavailable',
preprocessHook?: (dockerfile: string) => string,
): Promise<MultiBuild.BuildTask[]> {
const multiBuild = await import('resin-multibuild');
const multiBuild = await import('@balena/multibuild');
const buildTasks = await multiBuild.splitBuildStream(composition, tarStream);

logger.logDebug('Found build tasks:');
Expand Down Expand Up @@ -1085,7 +1085,7 @@ async function performResolution(
releaseHash: string,
preprocessHook?: (dockerfile: string) => string,
): Promise<MultiBuild.BuildTask[]> {
const multiBuild = await import('resin-multibuild');
const multiBuild = await import('@balena/multibuild');
const resolveListeners: MultiBuild.ResolveListeners = {};
const resolvePromise = new Promise<never>((_resolve, reject) => {
resolveListeners.error = [reject];
Expand Down Expand Up @@ -1150,7 +1150,7 @@ async function validateSpecifiedDockerfile(
dockerfilePath: string,
): Promise<string> {
const { contains, toNativePath, toPosixPath } = (
await import('resin-multibuild')
await import('@balena/multibuild')
).PathUtils;

const nativeProjectPath = path.normalize(projectPath);
Expand Down
29 changes: 16 additions & 13 deletions lib/utils/device/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import * as semver from 'balena-semver';
import * as Docker from 'dockerode';
import * as _ from 'lodash';
import { Composition } from 'resin-compose-parse';
import { Composition } from '@balena/compose-parse';
import {
BuildTask,
getAuthConfigObj,
LocalImage,
RegistrySecrets,
} from 'resin-multibuild';
} from '@balena/multibuild';
import type { Readable } from 'stream';

import { BALENA_ENGINE_TMP_PATH } from '../../config';
Expand Down Expand Up @@ -324,7 +324,7 @@ async function performBuilds(
opts: DeviceDeployOptions,
buildLogs?: Dictionary<string>,
): Promise<BuildTask[]> {
const multibuild = await import('resin-multibuild');
const multibuild = await import('@balena/multibuild');

const buildTasks = await makeBuildTasks(
composition,
Expand Down Expand Up @@ -373,7 +373,7 @@ async function performBuilds(
const imagesToRemove: string[] = [];

// Now tag any external images with the correct name that they should be,
// as this won't be done by resin-multibuild
// as this won't be done by @balena/multibuild
await Promise.all(
localImages.map(async (localImage) => {
if (localImage.external) {
Expand Down Expand Up @@ -417,7 +417,7 @@ export async function rebuildSingleTask(
// this should provide the following callback
containerIdCb?: (id: string) => void,
): Promise<string> {
const multibuild = await import('resin-multibuild');
const multibuild = await import('@balena/multibuild');
// First we run the build task, to get the new image id
let buildLogs = '';
const logHandler = (_s: string, line: string) => {
Expand Down Expand Up @@ -537,15 +537,18 @@ async function assignDockerBuildOpts(
await Promise.all(
buildTasks.map(async (task: BuildTask) => {
task.dockerOpts = {
cachefrom: images,
labels: {
'io.resin.local.image': '1',
'io.resin.local.service': task.serviceName,
...(task.dockerOpts || {}),
...{
cachefrom: images,
labels: {
'io.resin.local.image': '1',
'io.resin.local.service': task.serviceName,
},
t: getImageNameFromTask(task),
nocache: opts.nocache,
forcerm: true,
pull: opts.pull,
},
t: getImageNameFromTask(task),
nocache: opts.nocache,
forcerm: true,
pull: opts.pull,
};
if (task.external) {
task.dockerOpts.authconfig = await getAuthConfigObj(
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/device/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import * as fs from 'fs';
import Livepush, { ContainerNotRunningError } from 'livepush';
import * as _ from 'lodash';
import * as path from 'path';
import type { Composition } from 'resin-compose-parse';
import type { BuildTask } from 'resin-multibuild';
import type { Composition } from '@balena/compose-parse';
import type { BuildTask } from '@balena/multibuild';

import { instanceOf } from '../../errors';
import Logger = require('../logger');
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export interface BuildOpts {
cachefrom?: string[];
nocache?: boolean;
pull?: boolean;
registryconfig?: import('resin-multibuild').RegistrySecrets;
registryconfig?: import('@balena/multibuild').RegistrySecrets;
squash?: boolean;
t?: string; // only the tag portion of the image name, e.g. 'abc' in 'myimg:abc'
}
Expand All @@ -132,7 +132,7 @@ export function generateBuildOpts(options: {
'cache-from'?: string;
nocache: boolean;
pull?: boolean;
'registry-secrets'?: import('resin-multibuild').RegistrySecrets;
'registry-secrets'?: import('@balena/multibuild').RegistrySecrets;
squash: boolean;
tag?: string;
}): BuildOpts {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as _ from 'lodash';
import { promises as fs, Stats } from 'fs';
import * as path from 'path';
import * as MultiBuild from 'resin-multibuild';
import * as MultiBuild from '@balena/multibuild';

import dockerIgnore = require('@zeit/dockerignore');
import ignore from 'ignore';
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/remote-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { BalenaSDK } from 'balena-sdk';
import * as JSONStream from 'JSONStream';
import * as readline from 'readline';
import * as request from 'request';
import { RegistrySecrets } from 'resin-multibuild';
import { RegistrySecrets } from '@balena/multibuild';
import type * as Stream from 'stream';
import streamToPromise = require('stream-to-promise');
import type { Pack } from 'tar-stream';
Expand Down
Loading