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:
@@ -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,
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user