refactor: migrate from deprecated database manager

Changes:
- Swaps out `SingleConnectionDatabaseManager` to `DatabaseManager`
  across the repo.
- Updates `backend-test-utils` to generate test plugin names prefixed
  with db to satisfy plugin naming constraint, e.g. 0 becomes db0.

Signed-off-by: Minn Soe <contributions@minn.io>
This commit is contained in:
Minn Soe
2021-05-25 18:28:05 +01:00
parent 2976f3bae3
commit 5a3ce34072
12 changed files with 168 additions and 120 deletions
@@ -14,17 +14,14 @@
* limitations under the License.
*/
import {
getVoidLogger,
SingleConnectionDatabaseManager,
} from '@backstage/backend-common';
import { getVoidLogger, DatabaseManager } from '@backstage/backend-common';
import { ConfigReader } from '@backstage/config';
import { DatabaseTaskStore } from './DatabaseTaskStore';
import { StorageTaskBroker, TaskAgent } from './StorageTaskBroker';
import { TaskSecrets, TaskSpec, DbTaskEventRow } from './types';
async function createStore(): Promise<DatabaseTaskStore> {
const manager = SingleConnectionDatabaseManager.fromConfig(
const manager = DatabaseManager.fromConfig(
new ConfigReader({
backend: {
database: {
@@ -14,12 +14,9 @@
* limitations under the License.
*/
import {
getVoidLogger,
SingleConnectionDatabaseManager,
} from '@backstage/backend-common';
import { ConfigReader, JsonObject } from '@backstage/config';
import os from 'os';
import { getVoidLogger, DatabaseManager } from '@backstage/backend-common';
import { ConfigReader, JsonObject } from '@backstage/config';
import { createTemplateAction, TemplateActionRegistry } from '../actions';
import { RepoSpec } from '../actions/builtin/publish/util';
import { DatabaseTaskStore } from './DatabaseTaskStore';
@@ -27,7 +24,7 @@ import { StorageTaskBroker } from './StorageTaskBroker';
import { TaskWorker } from './TaskWorker';
async function createStore(): Promise<DatabaseTaskStore> {
const manager = SingleConnectionDatabaseManager.fromConfig(
const manager = DatabaseManager.fromConfig(
new ConfigReader({
backend: {
database: {
@@ -31,7 +31,7 @@ jest.doMock('fs-extra', () => ({
import {
getVoidLogger,
PluginDatabaseManager,
SingleConnectionDatabaseManager,
DatabaseManager,
UrlReaders,
} from '@backstage/backend-common';
import { CatalogApi } from '@backstage/catalog-client';
@@ -47,7 +47,7 @@ const createCatalogClient = (templates: any[] = []) =>
} as CatalogApi);
function createDatabase(): PluginDatabaseManager {
return SingleConnectionDatabaseManager.fromConfig(
return DatabaseManager.fromConfig(
new ConfigReader({
backend: {
database: {