When using GCS for the techdocs storage and not setting the GOOGLE_APPLICATION_CREDENTIALS environment variable, authentication and accessing the bucket fails due to the project ID not being found.

Relevant log output

```
techdocs error from GCS client library: Unable to detect a Project Id in the current environment.
```

By adding the projectID when initializing the Storage client, this should fix the issue. This current approach expects the project_id to be in the json credentials, which it usually is.

Another option would be to re-add the app-config projectID value back and allow users to specify the projectID that way as well.

Signed-off-by: Jeremy Guarini <jguarini@paloaltonetworks.com>
This commit is contained in:
Jeremy Guarini
2022-02-25 13:48:07 -08:00
parent d0ea59bee8
commit ac25a0f577
@@ -82,7 +82,7 @@ export class GoogleGCSPublish implements PublisherBase {
const credentials = config.getOptionalString(
'techdocs.publisher.googleGcs.credentials',
);
let credentialsJson = {};
let credentialsJson: any = {};
if (credentials) {
try {
credentialsJson = JSON.parse(credentials);
@@ -95,6 +95,7 @@ export class GoogleGCSPublish implements PublisherBase {
const storageClient = new Storage({
...(credentials && {
projectId: credentialsJson.project_id,
credentials: credentialsJson,
}),
});