backstage
63 строки · 1.9 Кб
1/*
2* Copyright 2023 The Backstage Authors
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16import { OCTOPUS_DEPLOY_PROJECT_ID_ANNOTATION } from './constants';
17import { octopusDeployEntityContentRouteRef } from './routes';
18
19import { OctopusDeployClient, octopusDeployApiRef } from './api';
20
21import {
22createApiFactory,
23createPlugin,
24createRoutableExtension,
25discoveryApiRef,
26fetchApiRef,
27configApiRef,
28} from '@backstage/core-plugin-api';
29
30import { Entity } from '@backstage/catalog-model';
31
32/** @public */
33export const isOctopusDeployAvailable = (entity: Entity) =>
34Boolean(entity.metadata.annotations?.[OCTOPUS_DEPLOY_PROJECT_ID_ANNOTATION]);
35
36/** @public */
37export const octopusDeployPlugin = createPlugin({
38id: 'octopus-deploy',
39apis: [
40createApiFactory({
41api: octopusDeployApiRef,
42deps: {
43discoveryApi: discoveryApiRef,
44fetchApi: fetchApiRef,
45configApi: configApiRef,
46},
47factory: ({ discoveryApi, fetchApi, configApi }) =>
48new OctopusDeployClient({ discoveryApi, fetchApi, configApi }),
49}),
50],
51});
52
53/** @public */
54export const EntityOctopusDeployContent = octopusDeployPlugin.provide(
55createRoutableExtension({
56name: 'EntityOctopusDeployContent',
57component: () =>
58import('./components/EntityPageOctopusDeploy').then(
59m => m.EntityPageOctopusDeploy,
60),
61mountPoint: octopusDeployEntityContentRouteRef,
62}),
63);
64