@mia-platform/backstage-plugin-backend
is a plugin for the Backstage backend app. It updates and inserts on the catalog of your Backstage application all the entities that can be found on your Mia-Platform console such as components, resources, systems etc. It also displays all these information on a dedicated page of the plugin.
This plugin requires @mia-platform/backstage-plugin-frontend
to display all the information retrieved by the backend plugin on a dedicated page.
- Install the plugin to your Backstage app:
yarn workspace backend add @mia-platform/backstage-plugin-backend
- In
packages/backend/src/index.ts
import the plugin and add it to the backend:
import miaPlatformModule from '@mia-platform/backstage-plugin-backend';
// ...
backend.add(import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'));
backend.add(import('@backstage/plugin-catalog-backend/alpha'));
// ...
backend.add(miaPlatformModule());
- Add to your
app-config.yaml
file the section for the configuration of support button and the Mia-Platform console
Under app
add the configuration for the support button
support:
url: https://github.com/mia-platform/backstage-plugin/blob/main/README.md
items:
- title: Documentation
icon: docs
links:
- url: https://github.com/mia-platform/backstage-plugin/blob/main/README.md
title: Repository
And then the configuration for the Mia-Platform console:
miaPlatform:
baseUrl: ...
gitBaseUrl: ...
authorizations:
- authMode: 'BASIC'
clientId: ...
clientSecret: ...
companyId: ...
- authMode: 'JWT'
clientId: ...
kid: ...
privateKeyPath: ...
expirationTime: ...
companyId: ...
baseUrl
: Mia Platform console urlauthorizations
: array of service accounts to use to retrieve projects information
- Install the plugin to your Backstage app:
yarn workspace backend add @mia-platform/backstage-plugin-backend
- Create a new file
packages/backend/src/plugins/mia-platform.ts
with content:
import { MiaPlatformEntityProvider, createRouter } from '@mia-platform/backstage-plugin-backend/legacy';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
import { CatalogBuilder, CatalogEnvironment } from '@backstage/plugin-catalog-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
export default async function createPlugin(
env: PluginEnvironment,
catalogEnv: CatalogEnvironment
): Promise<Router> {
const builder = await CatalogBuilder.create(catalogEnv);
builder.addProcessor(new ScaffolderEntitiesProcessor());
const miaPlatformProvider = MiaPlatformEntityProvider.create(env.config, env.logger);
builder.addEntityProvider(miaPlatformProvider);
const { processingEngine } = await builder.build();
await processingEngine.start();
return await createRouter({
logger: env.logger,
miaPlatformEntityProvider: miaPlatformProvider,
});
}
- In
packages/backend/src/index.ts
import the plugin and add the route to the plugin:
import miaPlatform from './plugins/mia-platform'
// ...
const miaPlatformEnv = useHotMemoize(module, () => createEnv('mia-platform'));
// ...
apiRouter.use('/mia-platform', await miaPlatform(miaPlatformEnv, catalogEnv));
- Add to your
app-config.yaml
file the section for the configuration of support button and the Mia-Platform console
Under app
add the configuration for the support button
support:
url: https://github.com/mia-platform/backstage-plugin/blob/main/README.md
items:
- title: Documentation
icon: docs
links:
- url: https://github.com/mia-platform/backstage-plugin/blob/main/README.md
title: Repository
And then the configuration for the Mia-Platform console:
miaPlatform:
baseUrl: ...
gitBaseUrl: ...
authorizations:
- authMode: 'BASIC'
clientId: ...
clientSecret: ...
companyId: ...
- authMode: 'JWT'
clientId: ...
kid: ...
privateKeyPath: ...
expirationTime: ...
companyId: ...
baseUrl
: Mia Platform console url
Warning
The base URL must not end with a /
authorizations
: array of service accounts to use to retrieve projects information
The authorization elements inside the array should match one of the following:
authMode
: 'BASIC'clientId
: clientId used by the service accountclientSecret
: clientSecret used by the service accountcompanyId
: companyId related to the service account
authMode
: 'JWT'clientId
: clientId used by the service accountkid
: kid related to the service account to useprivateKeyPath
: path to the file with the private keycompanyId
: companyId related to the service account