Skip to content

Commit

Permalink
refactor: remove fake google credentials (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide authored Jan 11, 2025
1 parent d4eb8b0 commit bf33078
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,5 @@ jobs:
with:
node-version: 20
cache: pnpm
# Setup gcloud application default credentials. While the credentials are not actually
# used because Google api services are stubbed, instantiating any of the Google node
# clients requires the credentials file to exist and be valid.
- uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"
- run: pnpm install --frozen-lockfile
- run: pnpm run e2e
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"exponential-backoff": "3.1.1",
"extract-zip": "^2.0.1",
"gcp-metadata": "^6.0.0",
"google-auth-library": "^9.15.0",
"nodemailer": "^6.7.8",
"reflect-metadata": "^0.2.2",
"rxjs": "7.8.1",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

9 changes: 9 additions & 0 deletions src/infrastructure/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
import { Injectable } from "@nestjs/common";
import gcpMetadata from "gcp-metadata";
import type { JSONClient } from "google-auth-library/build/src/auth/googleauth";

@Injectable()
export class SecretsClient {
Expand All @@ -15,6 +16,14 @@ export class SecretsClient {
fallback: "rest",
protocol: "http",
port: Number(process.env.SECRET_MANAGER_PORT),
// Create a fake auth client to bypass checking for default credentials
authClient: {
getRequestHeaders(
url?: string
): Promise<{ [index: string]: string }> {
return Promise.resolve({});
},
} as JSONClient,
});
} else {
this.googleSecretsClient = new SecretManagerServiceClient();
Expand Down

0 comments on commit bf33078

Please sign in to comment.