feat(techdocs-common): add core awsS3

This commit is contained in:
Remi
2020-12-19 23:42:38 +01:00
parent 2d0ab25779
commit 772c7fca4b
5 changed files with 90 additions and 1 deletions
@@ -21,6 +21,7 @@ import { ConfigReader } from '@backstage/config';
import { Publisher } from './publish';
import { LocalPublish } from './local';
import { GoogleGCSPublish } from './googleStorage';
import { AwsS3Publish } from './awsS3';
const logger = getVoidLogger();
const discovery: jest.Mocked<PluginEndpointDiscovery> = {
@@ -81,4 +82,22 @@ describe('Publisher', () => {
});
expect(publisher).toBeInstanceOf(GoogleGCSPublish);
});
it('should create AWS S3 publisher from config', () => {
const mockConfig = new ConfigReader({
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'awsS3',
awsS3: {
credentials: '{}',
bucketName: 'bucketName',
},
},
},
});
const publisher = Publisher.fromConfig(mockConfig, logger, testDiscovery);
expect(publisher).toBeInstanceOf(AwsS3Publish);
});
});
@@ -20,6 +20,7 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { PublisherType, PublisherBase } from './types';
import { LocalPublish } from './local';
import { GoogleGCSPublish } from './googleStorage';
import { AwsS3Publish } from './awsS3';
type factoryOptions = {
logger: Logger;
@@ -43,6 +44,9 @@ export class Publisher {
case 'googleGcs':
logger.info('Creating Google Storage Bucket publisher for TechDocs');
return GoogleGCSPublish.fromConfig(config, logger);
case 'awsS3':
logger.info('Creating AWS S3 Bucket publisher for TechDocs');
return AwsS3Publish.fromConfig(config, logger);
case 'local':
logger.info('Creating Local publisher for TechDocs');
return new LocalPublish(config, logger, discovery);
@@ -19,7 +19,7 @@ import express from 'express';
/**
* Key for all the different types of TechDocs publishers that are supported.
*/
export type PublisherType = 'local' | 'googleGcs';
export type PublisherType = 'local' | 'googleGcs' | 'awsS3';
export type PublishRequest = {
entity: Entity;