techdocs: Use googleGcs for publisher type instead of google_gcs

This commit is contained in:
Himanshu Mishra
2020-12-09 18:58:12 +01:00
parent 9d08ef8f46
commit 24bcdd0829
11 changed files with 61 additions and 49 deletions
@@ -49,8 +49,8 @@ beforeEach(() => {
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'google_gcs',
google: {
type: 'googleGcs',
googleGcs: {
pathToKey: '/path/to/google-application-credentials.json',
projectId: 'gcp-project-id',
bucketName: 'bucketName',
@@ -29,13 +29,13 @@ export class GoogleGCSPublish implements PublisherBase {
let projectId = '';
let bucketName = '';
try {
pathToKey = config.getString('techdocs.publisher.google.pathToKey');
projectId = config.getString('techdocs.publisher.google.projectId');
bucketName = config.getString('techdocs.publisher.google.bucketName');
pathToKey = config.getString('techdocs.publisher.googleGcs.pathToKey');
projectId = config.getString('techdocs.publisher.googleGcs.projectId');
bucketName = config.getString('techdocs.publisher.googleGcs.bucketName');
} catch (error) {
throw new Error(
"Since techdocs.publisher.type is set to 'google_gcs' in your app config, " +
'pathToKey, projectId and bucketName are required in techdocs.publisher.google ' +
"Since techdocs.publisher.type is set to 'googleGcs' in your app config, " +
'pathToKey, projectId and bucketName are required in techdocs.publisher.googleGcs ' +
'required to authenticate with Google Cloud Storage.',
);
}
@@ -59,7 +59,7 @@ export class GoogleGCSPublish implements PublisherBase {
logger.error(
`Could not retrieve metadata about the GCS bucket ${bucketName} in the GCP project ${projectId}. ` +
'Make sure the GCP project and the bucket exists and the access key located at the path ' +
"techdocs.publisher.google.pathToKey defined in app config has the role 'Storage Object Creator'. " +
"techdocs.publisher.googleGcs.pathToKey defined in app config has the role 'Storage Object Creator'. " +
'Refer to https://backstage.io/docs/features/techdocs/using-cloud-storage',
);
throw new Error(`from GCS client library: ${reason.message}`);
@@ -77,8 +77,8 @@ describe('Publisher', () => {
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'google_gcs',
google: {
type: 'googleGcs',
googleGcs: {
pathToKey: '/path/to/google-application-credentials.json',
projectId: 'gcp-project-id',
bucketName: 'bucketName',
@@ -36,7 +36,7 @@ export class Publisher {
) ?? 'local') as PublisherType;
switch (publisherType) {
case 'google_gcs':
case 'googleGcs':
logger.info('Creating Google Storage Bucket publisher for TechDocs');
return GoogleGCSPublish.fromConfig(config, logger);
case 'local':
@@ -19,7 +19,7 @@ import express from 'express';
/**
* Key for all the different types of TechDocs publishers that are supported.
*/
export type PublisherType = 'local' | 'google_gcs';
export type PublisherType = 'local' | 'googleGcs';
export type PublishRequest = {
entity: Entity;