Migrate nomad backend plugin to new backend system

Signed-off-by: Lavanya Sainik <lavanya.sainik@ericsson.com>
This commit is contained in:
Lavanya Sainik
2023-09-20 15:52:45 +01:00
parent c661cce04e
commit 6822918c50
10 changed files with 105 additions and 1 deletions
+1
View File
@@ -14,3 +14,4 @@
* limitations under the License.
*/
export * from './service/router';
export { nomadPlugin as default } from './plugin';
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright 2023 The Backstage 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 { nomadPlugin } from './plugin';
describe('nomad', () => {
it('should export the nomad plugin', () => {
expect(nomadPlugin).toBeDefined();
});
});
+52
View File
@@ -0,0 +1,52 @@
/*
* Copyright 2023 The Backstage 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 {
createBackendPlugin,
coreServices,
} from '@backstage/backend-plugin-api';
import { createRouter } from './service/router';
/**
* Nomad backend plugin
*
* @public
*/
export const nomadPlugin = createBackendPlugin({
pluginId: 'nomad',
register(env) {
env.registerInit({
deps: {
logger: coreServices.logger,
config: coreServices.rootConfig,
httpRouter: coreServices.httpRouter,
},
async init({ logger, config, httpRouter }) {
const winstonLogger = loggerToWinstonLogger(logger);
httpRouter.use(
await createRouter({
/**
* Logger for logging purposes
*/
logger: winstonLogger,
config,
}),
);
},
});
},
});