From 96e28f3d45179ea48a4d3d94fd5634e264e5ea93 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Thu, 2 Apr 2020 19:44:27 +0100 Subject: [PATCH] Fix project directory validation for 'balena deploy' with pre-built image Change-type: patch --- lib/actions/deploy.coffee | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/actions/deploy.coffee b/lib/actions/deploy.coffee index f61bc772..d706163b 100644 --- a/lib/actions/deploy.coffee +++ b/lib/actions/deploy.coffee @@ -198,7 +198,7 @@ module.exports = require('events').defaultMaxListeners = 1000 sdk = getBalenaSdk() { ExpectedError } = require('../errors') - { validateProjectDirectory } = require('../utils/compose_ts') + { getRegistrySecrets, validateProjectDirectory } = require('../utils/compose_ts') helpers = require('../utils/helpers') Logger = require('../utils/logger') @@ -225,16 +225,21 @@ module.exports = if image? and options.build throw new ExpectedError('Build option is not applicable when specifying an image') .then -> - validateProjectDirectory(sdk, { - dockerfilePath: options.dockerfile, - noParentCheck: options['noparent-check'] || false, - projectPath: options.source || '.', - registrySecretsPath: options['registry-secrets'], - }) - .then ({ dockerfilePath, registrySecrets }) -> - options.dockerfile = dockerfilePath - options['registry-secrets'] = registrySecrets - + if image + getRegistrySecrets(sdk, options['registry-secrets']) + .then (registrySecrets) -> + options['registry-secrets'] = registrySecrets + else + validateProjectDirectory(sdk, { + dockerfilePath: options.dockerfile, + noParentCheck: options['noparent-check'] || false, + projectPath: options.source || '.', + registrySecretsPath: options['registry-secrets'], + }) + .then ({ dockerfilePath, registrySecrets }) -> + options.dockerfile = dockerfilePath + options['registry-secrets'] = registrySecrets + .then -> Promise.join( helpers.getApplication(appName) helpers.getArchAndDeviceType(appName)