Code review adjustments

This commit is contained in:
Marek Calus
2020-11-20 14:30:49 +01:00
parent cb27aac515
commit bd613dd850
4 changed files with 13 additions and 7 deletions
@@ -22,13 +22,13 @@ import {
LocationAnalyzer,
} from './types';
export class LocationAnalyzerClient implements LocationAnalyzer {
export class RepoLocationAnalyzer implements LocationAnalyzer {
private readonly logger: Logger;
constructor(logger: Logger) {
this.logger = logger;
}
async generateConfig(
async analyzeLocation(
request: AnalyzeLocationRequest,
): Promise<AnalyzeLocationResponse> {
const { owner, name, source } = parseGitUri(request.location.target);
@@ -40,7 +40,7 @@ export class LocationAnalyzerClient implements LocationAnalyzer {
// Probably won't handle properly self-hosted git providers with custom url
annotations: { [`${source}/project-slug`]: `${owner}/${name}` },
},
spec: { type: 'other', owner: owner, lifecycle: 'unknown' },
spec: { type: 'other', lifecycle: 'unknown' },
};
this.logger.debug(`entity created for ${request.location.target}`);
@@ -75,7 +75,13 @@ export type ReadLocationError = {
//
export type LocationAnalyzer = {
generateConfig(
/**
* Generates an entity configuration for given git repository. It's used for
* importing new component to the backstage app.
*
* @param location Git repository to analyze and generate config for.
*/
analyzeLocation(
location: AnalyzeLocationRequest,
): Promise<AnalyzeLocationResponse>;
};
@@ -52,7 +52,7 @@ import {
UrlReaderProcessor,
} from '../ingestion';
import { CatalogRulesEnforcer } from '../ingestion/CatalogRules';
import { LocationAnalyzerClient } from '../ingestion/LocationAnalyzer';
import { RepoLocationAnalyzer } from '../ingestion/LocationAnalyzer';
import { BuiltinKindsEntityProcessor } from '../ingestion/processors/BuiltinKindsEntityProcessor';
import { LdapOrgReaderProcessor } from '../ingestion/processors/LdapOrgReaderProcessor';
import {
@@ -232,7 +232,7 @@ export class CatalogBuilder {
locationReader,
logger,
);
const locationAnalyzer = new LocationAnalyzerClient(logger);
const locationAnalyzer = new RepoLocationAnalyzer(logger);
return {
entitiesCatalog,
@@ -139,7 +139,7 @@ export async function createRouter(
if (locationAnalyzer) {
router.post('/analyze-location', async (req, res) => {
const input = await validateRequestBody(req, analyzeLocationSchema);
const output = await locationAnalyzer.generateConfig(input);
const output = await locationAnalyzer.analyzeLocation(input);
res.status(200).send(output);
});
}