Skip to content

Commit

Permalink
Use Application Default Credentials (#2918)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffposnick committed Aug 25, 2021
1 parent 5da8924 commit 094d081
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions gulp-tasks/utils/cdn-helper.js
Expand Up @@ -6,8 +6,6 @@
https://opensource.org/licenses/MIT.
*/

const {oneLine} = require('common-tags');
const fs = require('fs-extra');
const glob = require('glob');
const path = require('path');
const {Storage} = require('@google-cloud/storage');
Expand All @@ -16,8 +14,6 @@ const cdnDetails = require('../../cdn-details.json');
const logHelper = require('../../infra/utils/log-helper');

const PROJECT_ID = 'workbox-bab1f';
const SERVICE_ACCOUNT_PATH = path.join(__dirname, '..', '..',
`workbox-9d39634504ad.json`);

class CDNHelper {
constructor() {
Expand All @@ -30,23 +26,10 @@ class CDNHelper {

async getGCS() {
if (!this._gcs) {
try {
await fs.access(SERVICE_ACCOUNT_PATH);
} catch (err) {
const errorMessage = oneLine`
Unable to find the service account file that is required to upload
to the CDN.
Please get the service account file and put it at the root of the
workbox repo.
File Path Tested: '${SERVICE_ACCOUNT_PATH}'.
`;
throw new Error(errorMessage);
}

// Run `gcloud auth application-default login` if needed.
// See https://stackoverflow.com/a/42059661/385997
this._gcs = new Storage({
projectId: PROJECT_ID,
keyFilename: SERVICE_ACCOUNT_PATH,
});
}

Expand Down

0 comments on commit 094d081

Please sign in to comment.