Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new backend system support for existing backend plugins that have not been migrated over yet #1132

Merged
merged 26 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6a8e24d
feat(3scale-backend): add new backend system support for 3scale-backend
Jan 29, 2024
23adba5
feat(aap-backend): add new backend system support for aap-backend plugin
Jan 29, 2024
574d48e
chore(keycloak-backend): add TODO note to add extension points in future
Jan 29, 2024
ab127ac
feat(kiali-backend): add new backend system support for kiali-backend…
Jan 29, 2024
41e769d
feat(matomo-backend): add new backend system support for the matomo-b…
Jan 29, 2024
23b6603
feat(notifications-backend): add new backend system support for the n…
Jan 29, 2024
3dfa5cc
docs(3scale-backend): update README with new backend installation pro…
Jan 29, 2024
5f7dadf
docs(aap-backend): update README with new backend installation procedure
Jan 29, 2024
81bc59c
docs(keycloak-backend): update README with new backend installation p…
Jan 29, 2024
7090c10
docs(notifications-backend): update README with new backend installat…
Jan 29, 2024
2087530
docs(matomo-backend): update README for new backend installation proc…
Jan 29, 2024
ffd249d
feat(feedback-backend): add new backend system support
Jan 29, 2024
e2e33ac
docs(feedback-backend): update README with new backend installation p…
Jan 29, 2024
5624097
feat(quay-action): add support for the new backend system
Jan 29, 2024
3cb394d
feat(kubernetes-action): add support for the new backend system
Jan 29, 2024
6a31327
feat(regex-actions): add new backend system support
Jan 29, 2024
17c8bee
feat(servicenow-actions): add new backend system support
Jan 29, 2024
cfc4818
feat(sonarqube-actions): add new backend system support
Jan 29, 2024
e8b0358
Merge branch 'main' of https://github.com/janus-idp/backstage-plugins…
Jan 30, 2024
f019c27
feat(ocm-backend): add new backend system support
Jan 30, 2024
cd3d824
feat(orchestrator-backend): add support for new backend system
Jan 30, 2024
34663b0
chore: remove unnecessary dynamic alpha.ts files
Jan 30, 2024
642806e
feat(cli): update plugin templates to support new backend
Jan 30, 2024
75bd025
Merge branch 'main' of https://github.com/janus-idp/backstage-plugins…
Jan 30, 2024
c71e7f0
chore(cli): update scaffolder module name
Jan 30, 2024
f6a18f6
chore(cli): remove unused imports from the backend plugin template
Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/lib/new/factories/backendModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ describe('backendModule factory', () => {
'templating package.json.hbs',
'templating tsconfig.json.hbs',
'templating turbo.json.hbs',
'templating alpha.ts.hbs',
'templating index.ts.hbs',
'templating module.ts.hbs',
'templating alpha.ts.hbs',
'templating index.ts.hbs',
'Installing:',
`moving plugins${sep}test-backend-module-tester-two`,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/lib/new/factories/backendPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ describe('backendPlugin factory', () => {
'templating package.json.hbs',
'templating tsconfig.json.hbs',
'templating turbo.json.hbs',
'templating alpha.ts.hbs',
'templating index.ts.hbs',
'templating plugin.ts.hbs',
'templating run.ts.hbs',
'copying setupTests.ts',
'templating alpha.ts.hbs',
'templating index.ts.hbs',
'copying router.test.ts',
'templating router.ts.hbs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ describe('scaffolderModule factory', () => {
'templating package.json.hbs',
'templating tsconfig.json.hbs',
'templating turbo.json.hbs',
'templating index.ts.hbs',
'templating alpha.ts.hbs',
'templating index.ts.hbs',
'templating module.ts.hbs',
'templating index.ts.hbs',
'copying index.ts',
'copying example.test.ts',
'copying example.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { {{moduleVar}} as default } from './module';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { coreServices, createBackendModule } from '@backstage/backend-plugin-api';

/**
* The {{moduleId}} backend module for the {{pluginId}} plugin.
*
* @alpha
*/
export const {{moduleVar}} = createBackendModule({
pluginId: '{{pluginId}}',
moduleId: '{{moduleId}}',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { {{id}}Plugin as default } from './plugin';
davidfestal marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

25 changes: 25 additions & 0 deletions packages/cli/templates/default-backend-plugin/src/plugin.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { loggerToWinstonLogger } from '@backstage/backend-common';
import { coreServices, createBackendPlugin } from '@backstage/backend-plugin-api';

import { createRouter } from './service/router';

/**
* The {{id}} backend plugin.
*
* @alpha
*/
export const {{id}}Plugin = createBackendPlugin({
pluginId: '{{id}}',
register(env) {
env.registerInit({
deps: {
logger: coreServices.logger,
config: coreServices.rootConfig,
http: coreServices.httpRouter,
},
async init({ config, logger, http }) {
http.use(() => createRouter({...config, logger: loggerToWinstonLogger(logger)}));
},
});
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,4 @@ export async function createRouter(
router.use(errorHandler());
return router;
}
export const {{id}}Plugin = createBackendPlugin({
pluginId: '{{id}}',
register(env) {
env.registerInit({
deps: {
logger: coreServices.logger,
config: coreServices.rootConfig,
http: coreServices.httpRouter,
},
async init({ config, logger, http }) {
http.use(() => createRouter({...config, logger: loggerToWinstonLogger(logger)}));
},
});
},
});

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { scaffolderModule{{id}}Action as default } from './module';
Zaperex marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import {
coreServices,
createBackendModule,
} from '@backstage/backend-plugin-api';
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager';
import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
import { createAcmeExampleAction } from './actions';

import { createAcmeExampleAction } from '../actions';

export const dynamicPluginInstaller: BackendDynamicPluginInstaller = {
kind: 'new',
install: createBackendModule({
/***/
/**
* The {{id}} module for @backstage/plugin-scaffolder-backend.
*
* @alpha
*/
export const scaffolderModule{{id}}Action = createBackendModule({
moduleId: 'scaffolder-backend-{{id}}',
pluginId: 'scaffolder',
register(env) {
Expand All @@ -23,5 +25,4 @@ export const dynamicPluginInstaller: BackendDynamicPluginInstaller = {
},
});
},
}),
};
})
26 changes: 20 additions & 6 deletions plugins/3scale-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ yarn workspace backend add @janus-idp/backstage-plugin-3scale-backend

3scale Backstage provider allows configuration of one or multiple providers using the `app-config.yaml` configuration file of Backstage.

### Procedure
#### Legacy Backend Procedure

1. Use a `threeScaleApiEntity` marker to start configuring the `app-config.yaml` file of Backstage:

Expand All @@ -29,12 +29,12 @@ yarn workspace backend add @janus-idp/backstage-plugin-3scale-backend
accessToken: <ACCESS_TOKEN>
schedule: # optional; same options as in TaskScheduleDefinition
# supports cron, ISO duration, "human duration" as used in code
frequency: { minutes: 1 }
frequency: { minutes: 30 }
# supports ISO duration, "human duration" as used in code
timeout: { minutes: 1 }
timeout: { minutes: 3 }
```

2. Configure the scheduler for the entity provider using one of the following methods:
2. If installing into the _legacy_ backend, configure the scheduler for the entity provider using one of the following methods:

- **Method 1**: If the scheduler is configured inside the `app-config.yaml` using the schedule config key mentioned previously, add the following code to `packages/backend/src/plugins/catalog.ts` file:

Expand Down Expand Up @@ -88,8 +88,8 @@ yarn workspace backend add @janus-idp/backstage-plugin-3scale-backend
ThreeScaleApiEntityProvider.fromConfig(env.config, {
logger: env.logger,
schedule: env.scheduler.createScheduledTaskRunner({
frequency: { minutes: 1 },
timeout: { minutes: 1 },
frequency: { minutes: 30 },
timeout: { minutes: 3 },
}),
}),
);
Expand All @@ -109,6 +109,20 @@ yarn workspace backend add @janus-idp/backstage-plugin-3scale-backend

***

#### New Backend Procedure

1. If installing into the new backend system, make the same configurations to the `app=config.yaml` as in the [Legacy Backend Installation Procedure](#legacy-backend-installation-procedure). Make sure to configure the schedule inside the `app-config.yaml` file. The default schedule is a frequency of 30 minutes and a timeout of 3 minutes.
2. Add the following code to the `packages/backend/src/index.ts` file:

```ts title="packages/backend/src/index.ts"
const backend = createBackend();

/* highlight-add-next-line */
backend.add(import('@janus-idp/backstage-plugin-3scale-backend/alpha'));

backend.start();
```

### Troubleshooting

When you start your Backstage application, you can see some log lines as follows:
Expand Down
14 changes: 13 additions & 1 deletion plugins/3scale-backend/dist-dynamic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"backstage": {
"role": "backend-plugin"
},
"exports": {
".": {
"require": "./dist/index.cjs.js",
"default": "./dist/index.cjs.js"
},
"./alpha": {
"require": "./dist/alpha.cjs.js",
"default": "./dist/alpha.cjs.js"
},
"./package.json": "./package.json"
},
"scripts": {
"build": "backstage-cli package build",
"clean": "backstage-cli package clean",
Expand All @@ -31,7 +42,8 @@
"files": [
"dist",
"config.d.ts",
"app-config.janus-idp.yaml"
"app-config.janus-idp.yaml",
"alpha"
],
"configSchema": "config.d.ts",
"repository": "github:janus-idp/backstage-plugins",
Expand Down
15 changes: 15 additions & 0 deletions plugins/3scale-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
"backstage": {
"role": "backend-plugin"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
],
"package.json": [
"package.json"
]
}
},
"scripts": {
"build": "backstage-cli package build",
"clean": "backstage-cli package clean",
Expand Down
22 changes: 22 additions & 0 deletions plugins/3scale-backend/src/alpha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 The Janus IDP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* The 3Scale backend plugin integrates 3Scale into Backstage
*
* @packageDocumentation
*/
export { catalogModule3ScaleEntityProvider as default } from './module';
40 changes: 0 additions & 40 deletions plugins/3scale-backend/src/dynamic/alpha.ts

This file was deleted.

15 changes: 15 additions & 0 deletions plugins/3scale-backend/src/dynamic/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 The Janus IDP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager';

import { ThreeScaleApiEntityProvider } from '../providers';
Expand Down
50 changes: 50 additions & 0 deletions plugins/3scale-backend/src/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2024 The Janus IDP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { loggerToWinstonLogger } from '@backstage/backend-common';
import {
coreServices,
createBackendModule,
} from '@backstage/backend-plugin-api';
import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';

import { ThreeScaleApiEntityProvider } from './providers';

export const catalogModule3ScaleEntityProvider = createBackendModule({
moduleId: 'catalog-backend-module-3scale',
pluginId: 'catalog',
register(env) {
env.registerInit({
deps: {
catalog: catalogProcessingExtensionPoint,
config: coreServices.rootConfig,
logger: coreServices.logger,
scheduler: coreServices.scheduler,
},
async init({ catalog, config, logger, scheduler }) {
catalog.addEntityProvider(
ThreeScaleApiEntityProvider.fromConfig(config, {
logger: loggerToWinstonLogger(logger),
scheduler: scheduler,
schedule: scheduler.createScheduledTaskRunner({
frequency: { minutes: 30 },
timeout: { minutes: 3 },
}),
}),
);
},
});
},
});
Loading
Loading