From 5464a135f3b9c7500029cc7bbb1645808b39e1e6 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Mon, 6 Mar 2023 21:00:33 +0100 Subject: [PATCH 1/2] Add support for setting gcp endpoint for easier testing --- lib/cli/cli.js | 4 ++++ lib/plugins/gcs/index.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/cli/cli.js b/lib/cli/cli.js index 1df338b2be..a0327b726a 100644 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -1624,6 +1624,10 @@ export async function parseCommandLine() { describe: 'Name of the Google Cloud storage bucket', group: 'GoogleCloudStorage' }) + .option('gcs.apiEndpoint', { + describe: 'The URL to the API endpoint, good for using fake-gcs-server', + group: 'GoogleCloudStorage' + }) .option('gcs.public', { describe: 'Make uploaded results to Google Cloud storage publicly readable.', diff --git a/lib/plugins/gcs/index.js b/lib/plugins/gcs/index.js index 11be195285..97ab6fa757 100644 --- a/lib/plugins/gcs/index.js +++ b/lib/plugins/gcs/index.js @@ -15,10 +15,18 @@ function ignoreDirectories(file, stats) { } async function uploadLatestFiles(dir, gcsOptions, prefix) { - const storage = new Storage({ + + const config = { projectId: gcsOptions.projectId, keyFilename: gcsOptions.key - }); + } + + if (gcsOptions.apiEndpoint) { + config.apiEndpoint = gcsOptions.apiEndpoint; + } + + + const storage = new Storage(config); const bucket = storage.bucket(gcsOptions.bucketname); const files = await readdir(dir, [ignoreDirectories]); From 5f2e3e292e596ef8a7eea955a4d9e45d9348f8ae Mon Sep 17 00:00:00 2001 From: soulgalore Date: Fri, 27 Dec 2024 08:53:15 +0100 Subject: [PATCH 2/2] lint --- lib/plugins/gcs/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/plugins/gcs/index.js b/lib/plugins/gcs/index.js index 7106bb0a9e..4348aa2f19 100644 --- a/lib/plugins/gcs/index.js +++ b/lib/plugins/gcs/index.js @@ -15,17 +15,15 @@ function ignoreDirectories(file, stats) { } async function uploadLatestFiles(dir, gcsOptions, prefix) { - const config = { projectId: gcsOptions.projectId, keyFilename: gcsOptions.key - } + }; if (gcsOptions.apiEndpoint) { config.apiEndpoint = gcsOptions.apiEndpoint; } - const storage = new Storage(config); const bucket = storage.bucket(gcsOptions.bucketname);