Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove fake google credentials #202

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading