Skip to content

Commit

Permalink
[email protected]: Fix: before GCS bucket creating check for its…
Browse files Browse the repository at this point in the history
… existence and skip if one exists, it partly helps in cases when multi-regional regions aren't available for users (they have to manually create a bucket in a supported location beforehand)

Change-Id: I24b2dc411c73fd8c3301ba56a27ee744237b3676
  • Loading branch information
evil-shrike committed Sep 25, 2024
1 parent 3ab2769 commit e941489
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
15 changes: 9 additions & 6 deletions gcp/create-gaarf-wf/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gcp/create-gaarf-wf/build/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gcp/create-gaarf-wf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gcp/create-gaarf-wf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-gaarf-wf",
"version": "1.11.3",
"version": "1.11.4",
"description": "Interactive generator for Gaarf (Google Ads API Report Fetcher) Workflow",
"type": "module",
"bin": {
Expand Down
32 changes: 20 additions & 12 deletions gcp/create-gaarf-wf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,21 +916,29 @@ async function init() {

const gcp_region = await ask_for_gcp_region(answers);

// create a bucket
const res = await exec_cmd(
`gsutil mb -l ${getMultiRegion(gcp_region)} -b on gs://${gcs_bucket}`,
new clui.Spinner(`Creating a GCS bucket ${gcs_bucket}`),
// create a bucket if it doesn't exist
let res = await exec_cmd(
`gsutil ls gs://${gcs_bucket}`,
new clui.Spinner(`Checking if GCS bucket ${gcs_bucket} exists`),
{silent: true}
);
if (
res.code !== 0 &&
!res.stderr.includes(
`ServiceException: 409 A Cloud Storage bucket named '${gcs_bucket}' already exists`
)
) {
console.log(chalk.red(`Could not create a bucket ${gcs_bucket}`));
console.log(res.stderr || res.stdout);
if (res.code !== 0) {
// bucket doesn't exist
res = await exec_cmd(
`gsutil mb -l ${getMultiRegion(gcp_region)} -b on gs://${gcs_bucket}`,
new clui.Spinner(`Creating a GCS bucket ${gcs_bucket}`),
{silent: true}
);
if (res.code !== 0) {
console.log(
chalk.red(
`Could not create a bucket ${gcs_bucket}. Most likely the installation will fail`
)
);
console.log(res.stderr || res.stdout);
}
}

const gcs_base_path = `gs://${gcs_bucket}/${name}`;

// Create deploy-queries.sh
Expand Down
2 changes: 1 addition & 1 deletion js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Node.js version of Google Ads API Report Fetcher tool a.k.a. `gaarf`.
Please see the full documentation in the root [README](https://github.com/google/ads-api-report-fetcher/README.md).

Supports [Ads API v16](https://developers.google.com/google-ads/api/docs/release-notes#v16).
Supports [Ads API v17.1](https://developers.google.com/google-ads/api/docs/release-notes#v17).

<p align="center">
<a href="https://developers.google.com/google-ads/api/docs/release-notes">
Expand Down

0 comments on commit e941489

Please sign in to comment.