From 099d755900ff9e3d994b517225da872025c3f445 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Wed, 21 Oct 2020 14:18:31 +0100 Subject: [PATCH] Fix typing (don't assume that 'docker-toolbelt' uses Bluebird promises) Change-type: patch --- lib/utils/compose.js | 3 +-- lib/utils/deploy-legacy.js | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/utils/compose.js b/lib/utils/compose.js index 50868f22..a11b867e 100644 --- a/lib/utils/compose.js +++ b/lib/utils/compose.js @@ -365,8 +365,7 @@ export const pushAndUpdateServiceImages = function ( Promise.all( images.map(({ serviceImage, localImage, props, logs }, index) => Promise.all([ - // @ts-ignore - localImage.inspect().get('Size'), + localImage.inspect().then((img) => img.Size), retry( // @ts-ignore () => progress.push(localImage.name, reporters[index], opts), diff --git a/lib/utils/deploy-legacy.js b/lib/utils/deploy-legacy.js index 1034a3c1..f04e6e03 100644 --- a/lib/utils/deploy-legacy.js +++ b/lib/utils/deploy-legacy.js @@ -30,13 +30,18 @@ const getBuilderLogPushEndpoint = function (baseUrl, buildId, owner, app) { return `https://builder.${baseUrl}/v1/pushLogs?${args}`; }; +/** + * @param {import('docker-toolbelt')} docker + * @param {string} imageId + * @param {string} bufferFile + */ const bufferImage = function (docker, imageId, bufferFile) { const streamUtils = require('./streams'); const image = docker.getImage(imageId); - const imageMetadata = image.inspect(); + const sizePromise = image.inspect().then((img) => img.Size); - return Promise.all([image.get(), imageMetadata.get('Size')]).then( + return Promise.all([image.get(), sizePromise]).then( ([imageStream, imageSize]) => streamUtils.buffer(imageStream, bufferFile).then((bufferedStream) => { // @ts-ignore adding an extra property @@ -150,14 +155,17 @@ const uploadLogs = function (logs, token, url, buildId, username, appName) { }); }; -/* -opts must be a hash with the following keys: - -- appName: the name of the app to deploy to -- imageName: the name of the image to deploy -- buildLogs: a string with build output -- shouldUploadLogs -*/ +/** + * @param {import('docker-toolbelt')} docker + * @param {import('./logger')} logger + * @param {string} token + * @param {string} username + * @param {string} url + * @param {{appName: string; imageName: string; buildLogs: string; shouldUploadLogs: boolean}} opts + * - appName: the name of the app to deploy to + * - imageName: the name of the image to deploy + * - buildLogs: a string with build output + */ export const deployLegacy = async function ( docker, logger,