From 6714506fe22cc6194f9358fcf44bc276461d8834 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Thu, 22 May 2025 23:06:37 +0800 Subject: [PATCH 1/2] fix: support auth_handler --- src/deploy-actions.js | 8 ++------ src/print-action-logs.js | 8 ++------ src/undeploy-actions.js | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/deploy-actions.js b/src/deploy-actions.js index 0ccc368c..8138eb6f 100644 --- a/src/deploy-actions.js +++ b/src/deploy-actions.js @@ -174,12 +174,8 @@ async function deployWsk (scriptConfig, manifestContent, logFunc, filterEntities apihost: scriptConfig.ow.apihost, apiversion: scriptConfig.ow.apiversion, api_key: scriptConfig.ow.auth, - namespace: scriptConfig.ow.namespace - } - - // TODO: remove this once the feature flag is removed - if ('auth_handler' in scriptConfig.ow && scriptConfig.ow.auth_handler) { - owOptions.auth_handler = scriptConfig.ow.auth_handler + namespace: scriptConfig.ow.namespace, + auth_handler: scriptConfig.ow.auth_handler } const lastDeployedActionsPath = path.join(scriptConfig.root, 'dist', 'last-deployed-actions.json') diff --git a/src/print-action-logs.js b/src/print-action-logs.js index a071f069..470501cf 100644 --- a/src/print-action-logs.js +++ b/src/print-action-logs.js @@ -39,12 +39,8 @@ async function printActionLogs (config, logger, limit, filterActions, strip, tai apihost: config.ow.apihost, apiversion: config.ow.apiversion, api_key: config.ow.auth, - namespace: config.ow.namespace - } - - // TODO: remove this once the feature flag is removed - if ('auth_handler' in config.ow && config.ow.auth_handler) { - runtimeOptions.auth_handler = config.ow.auth_handler + namespace: config.ow.namespace, + auth_handler: config.ow.auth_handler } const runtime = await new IOruntime().init(runtimeOptions) diff --git a/src/undeploy-actions.js b/src/undeploy-actions.js index 1324e1fd..bf72eebb 100644 --- a/src/undeploy-actions.js +++ b/src/undeploy-actions.js @@ -31,12 +31,8 @@ async function undeployActions (config, logFunc) { apihost: config.ow.apihost, apiversion: config.ow.apiversion, api_key: config.ow.auth, - namespace: config.ow.namespace - } - - // TODO: remove this once the feature flag is removed - if ('auth_handler' in config.ow && config.ow.auth_handler) { - owOptions.auth_handler = config.ow.auth_handler + namespace: config.ow.namespace, + auth_handler: config.ow.auth_handler } // replace package name From 66a58edaf52a7f52ed4e04514251918b7a3842b3 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Fri, 23 May 2025 11:10:29 +0800 Subject: [PATCH 2/2] fix: don't initialize an archive stream if the input file does not exist --- src/utils.js | 15 +++++++-------- test/utils.test.js | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils.js b/src/utils.js index 0d20a807..ceb5ee4e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -437,22 +437,21 @@ function getActionEntryFile (pkgJsonPath) { */ function zip (filePath, out, pathInZip = false) { aioLogger.debug(`Creating zip of file/folder ${filePath}`) - const stream = fs.createWriteStream(out) - const archive = archiver('zip', { zlib: { level: 9 } }) return new Promise((resolve, reject) => { - stream.on('close', () => resolve()) - archive.pipe(stream) - archive.on('error', err => reject(err)) - let stats try { stats = fs.lstatSync(filePath) // throws if ENOENT } catch (e) { - archive.destroy() - reject(e) + return reject(e) } + const stream = fs.createWriteStream(out) + const archive = archiver('zip', { zlib: { level: 9 } }) + stream.on('close', () => resolve()) + archive.pipe(stream) + archive.on('error', err => reject(err)) + if (stats.isDirectory()) { archive.directory(filePath, pathInZip) } else { diff --git a/test/utils.test.js b/test/utils.test.js index 5943d936..ba30cf76 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -2232,6 +2232,7 @@ describe('zip', () => { await expect(utils.zip('/notexist.js', '/out.zip')).rejects.toEqual(expect.objectContaining({ message: expect.stringContaining('ENOENT') })) + expect(archiver.mockFile).toHaveBeenCalledTimes(0) expect(archiver.mockDirectory).toHaveBeenCalledTimes(0) expect(fs.existsSync('/out.zip')).toEqual(false)