Backwards compatible scaffolder

This commit is contained in:
Erik Larsson
2021-01-24 01:55:36 +01:00
parent b3e9b08fd7
commit 3a3cdfb1ca
6 changed files with 10 additions and 11 deletions
-1
View File
@@ -28,7 +28,6 @@
},
"dependencies": {
"@backstage/backend-common": "^0.5.1",
"@backstage/catalog-client": "^0.3.5",
"@backstage/catalog-model": "^0.7.0",
"@backstage/config": "^0.1.2",
"@backstage/plugin-app-backend": "^0.3.5",
+1 -3
View File
@@ -24,7 +24,6 @@ import {
CatalogEntityClient,
} from '@backstage/plugin-scaffolder-backend';
import { SingleHostDiscovery } from '@backstage/backend-common';
import { CatalogClient } from '@backstage/catalog-client';
import type { PluginEnvironment } from '../types';
import Docker from 'dockerode';
@@ -45,8 +44,7 @@ export default async function createPlugin({
const dockerClient = new Docker();
const discovery = SingleHostDiscovery.fromConfig(config);
const catalogClient = new CatalogClient({ discoveryApi: discovery });
const entityClient = new CatalogEntityClient({ catalogClient });
const entityClient = new CatalogEntityClient({ discovery });
return await createRouter({
preparers,
@@ -19,7 +19,6 @@
"dependencies": {
"app": "0.0.0",
"@backstage/backend-common": "^{{version '@backstage/backend-common'}}",
"@backstage/catalog-client": "^{{version '@backstage/catalog-client'}}",
"@backstage/catalog-model": "^{{version '@backstage/catalog-model'}}",
"@backstage/config": "^{{version '@backstage/config'}}",
"@backstage/plugin-app-backend": "^{{version '@backstage/plugin-app-backend'}}",
@@ -8,7 +8,6 @@ import {
CatalogEntityClient,
} from '@backstage/plugin-scaffolder-backend';
import { SingleHostDiscovery } from '@backstage/backend-common';
import { CatalogClient } from '@backstage/catalog-client';
import type { PluginEnvironment } from '../types';
import Docker from 'dockerode';
@@ -29,8 +28,7 @@ export default async function createPlugin({
const dockerClient = new Docker();
const discovery = SingleHostDiscovery.fromConfig(config);
const catalogClient = new CatalogClient({ discoveryApi: discovery });
const entityClient = new CatalogEntityClient({ catalogClient });
const entityClient = new CatalogEntityClient({ discovery });
return await createRouter({
preparers,
@@ -58,7 +58,9 @@ describe('CatalogClientWrapper', () => {
expect.assertions(2);
await client.getEntities();
const getEntities = MockedCatalogClient.mock.instances[0].getEntities;
expect(getEntities).toHaveBeenCalledWith('fake-id-token', undefined);
expect(getEntities).toHaveBeenCalledWith(undefined, {
token: 'fake-id-token',
});
expect(getEntities).toHaveBeenCalledTimes(1);
});
});
@@ -16,6 +16,7 @@
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
import { CatalogClient } from '@backstage/catalog-client';
import { DiscoveryApi } from '@backstage/core';
import { ConflictError, NotFoundError } from '@backstage/backend-common';
/**
@@ -24,8 +25,10 @@ import { ConflictError, NotFoundError } from '@backstage/backend-common';
export class CatalogEntityClient {
private readonly catalogClient: CatalogClient;
constructor(options: { catalogClient: CatalogClient }) {
this.catalogClient = options.catalogClient;
constructor(options: { discovery: DiscoveryApi }) {
this.catalogClient = new CatalogClient({
discoveryApi: options.discovery,
});
}
/**