@@ -3,18 +3,12 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { AzureFunctionsAllowedSubscriptionsConfig } from '@backstage/plugin-azure-functions-common';
|
||||
import { Config } from '@backstage/config';
|
||||
import express from 'express';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
// @public (undocumented)
|
||||
export interface AzureFunctionsAllowedSubscriptionsConfig {
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
name: string;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export class AzureFunctionsConfig {
|
||||
constructor(
|
||||
@@ -50,18 +44,6 @@ export class AzureWebManagementApi {
|
||||
// @public (undocumented)
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type FunctionsData = {
|
||||
href: string;
|
||||
logstreamHref: string;
|
||||
functionName: string;
|
||||
location: string;
|
||||
state: string;
|
||||
usageState: string;
|
||||
containerSize: number;
|
||||
lastModifiedDate: Date;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface RouterOptions {
|
||||
// (undocumented)
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
"backstage": {
|
||||
"role": "backend-plugin"
|
||||
},
|
||||
"homepage": "https://backstage.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "plugins/azure-functions-backend"
|
||||
},
|
||||
"keywords": [
|
||||
"backstage",
|
||||
"functions",
|
||||
"azure"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
"build": "backstage-cli package build",
|
||||
@@ -27,6 +38,7 @@
|
||||
"@azure/identity": "^2.1.0",
|
||||
"@backstage/backend-common": "^0.15.1-next.2",
|
||||
"@backstage/config": "^1.0.1",
|
||||
"@backstage/plugin-azure-functions-common": "workspace:^",
|
||||
"@types/express": "*",
|
||||
"express": "^4.17.1",
|
||||
"express-promise-router": "^4.1.0",
|
||||
|
||||
@@ -20,7 +20,7 @@ import { WebSiteManagementClient } from '@azure/arm-appservice';
|
||||
import {
|
||||
AzureFunctionsAllowedSubscriptionsConfig,
|
||||
FunctionsData,
|
||||
} from './types';
|
||||
} from '@backstage/plugin-azure-functions-common';
|
||||
|
||||
/** @public */
|
||||
export class AzureFunctionsConfig {
|
||||
|
||||
@@ -18,4 +18,3 @@ export {
|
||||
AzureWebManagementApi,
|
||||
AzureFunctionsConfig,
|
||||
} from './AzureWebManagementApi';
|
||||
export * from './types';
|
||||
|
||||
@@ -40,10 +40,11 @@ export async function createRouter(
|
||||
logger.info('PONG!');
|
||||
response.send({ status: 'ok' });
|
||||
});
|
||||
router.post('/list', async (request, response) => {
|
||||
router.get('/list/:functionName', async (request, response) => {
|
||||
const { functionName } = request.params;
|
||||
response.json(
|
||||
await azureWebManagementApi.list({
|
||||
functionName: request.body.functionName!.toString(),
|
||||
functionName: functionName,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
|
||||
@@ -0,0 +1,27 @@
|
||||
## API Report File for "@backstage/plugin-azure-functions-common"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
// @public (undocumented)
|
||||
export interface AzureFunctionsAllowedSubscriptionsConfig {
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
name: string;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type FunctionsData = {
|
||||
href: string;
|
||||
logstreamHref: string;
|
||||
functionName: string;
|
||||
location: string;
|
||||
state: string;
|
||||
usageState: string;
|
||||
containerSize: number;
|
||||
lastModifiedDate: Date;
|
||||
};
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@backstage/plugin-azure-functions-common",
|
||||
"description": "Common functionalities for the azure-functions plugin",
|
||||
"version": "0.0.1",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"types": "dist/index.d.ts"
|
||||
},
|
||||
"backstage": {
|
||||
"role": "common-library"
|
||||
},
|
||||
"homepage": "https://backstage.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "plugins/azure-functions-common"
|
||||
},
|
||||
"keywords": [
|
||||
"backstage"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "backstage-cli package build",
|
||||
"lint": "backstage-cli package lint",
|
||||
"test": "backstage-cli package test",
|
||||
"clean": "backstage-cli package clean",
|
||||
"prepack": "backstage-cli package prepack",
|
||||
"postpack": "backstage-cli package postpack"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.19.0-next.2"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
+1
-11
@@ -14,14 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @public */
|
||||
export type FunctionsData = {
|
||||
href: string;
|
||||
logstreamHref: string;
|
||||
functionName: string;
|
||||
location: string;
|
||||
state: string;
|
||||
usageState: string;
|
||||
containerSize: number;
|
||||
lastModifiedDate: Date;
|
||||
};
|
||||
export * from './types';
|
||||
@@ -68,7 +68,3 @@ const serviceEntityPage = (
|
||||
</EntityLayout>
|
||||
);
|
||||
```
|
||||
|
||||
## Roadmap
|
||||
|
||||
- [ ] Metrics
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ApiRef } from '@backstage/core-plugin-api';
|
||||
import { BackstagePlugin } from '@backstage/core-plugin-api';
|
||||
import { DiscoveryApi } from '@backstage/core-plugin-api';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
import { IdentityApi } from '@backstage/core-plugin-api';
|
||||
import { RouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
@@ -52,18 +53,6 @@ export const EntityAzureFunctionsOverviewCard: () => JSX.Element;
|
||||
// @public (undocumented)
|
||||
export const entityContentRouteRef: RouteRef<undefined>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type FunctionsData = {
|
||||
href: string;
|
||||
logstreamHref: string;
|
||||
functionName: string;
|
||||
location: string;
|
||||
state: string;
|
||||
usageState: string;
|
||||
containerSize: number;
|
||||
lastModifiedDate: Date;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const isAzureFunctionsAvailable: (entity: Entity) => string | undefined;
|
||||
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
"backstage": {
|
||||
"role": "frontend-plugin"
|
||||
},
|
||||
"homepage": "https://backstage.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "plugins/azure-functions"
|
||||
},
|
||||
"keywords": [
|
||||
"backstage",
|
||||
"functions",
|
||||
"azure"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
"build": "backstage-cli package build",
|
||||
@@ -26,6 +37,7 @@
|
||||
"@backstage/catalog-model": "^1.1.0",
|
||||
"@backstage/core-components": "^0.11.1-next.2",
|
||||
"@backstage/core-plugin-api": "^1.0.6-next.2",
|
||||
"@backstage/plugin-azure-functions-common": "workspace:^",
|
||||
"@backstage/plugin-catalog-react": "^1.1.4-next.1",
|
||||
"@backstage/theme": "^0.2.16",
|
||||
"@material-ui/core": "^4.9.13",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { createApiRef } from '@backstage/core-plugin-api';
|
||||
import { FunctionsData } from './types';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
|
||||
/** @public */
|
||||
export const azureFunctionsApiRef = createApiRef<AzureFunctionsApi>({
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { AzureFunctionsApi } from './AzureFunctionsApi';
|
||||
import { FunctionsData } from './types';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
|
||||
|
||||
/** @public */
|
||||
@@ -38,15 +38,14 @@ export class AzureFunctionsBackendClient implements AzureFunctionsApi {
|
||||
try {
|
||||
const url = `${await this.discoveryApi.getBaseUrl(
|
||||
'azure-functions',
|
||||
)}/list`;
|
||||
)}/list/${functionName}`;
|
||||
const { token: idToken } = await this.identityApi.getCredentials();
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(idToken && { Authorization: `Bearer ${idToken}` }),
|
||||
},
|
||||
body: JSON.stringify({ functionName: functionName }),
|
||||
});
|
||||
return await response.json();
|
||||
} catch (e: any) {
|
||||
|
||||
@@ -16,4 +16,3 @@
|
||||
|
||||
export * from './AzureFunctionsApi';
|
||||
export * from './AzureFunctionsBackendClient';
|
||||
export * from './types';
|
||||
|
||||
+17
-8
@@ -21,8 +21,11 @@ import {
|
||||
AZURE_FUNCTIONS_ANNOTATION,
|
||||
useServiceEntityAnnotations,
|
||||
} from '../../hooks/useServiceEntityAnnotations';
|
||||
import { MissingAnnotationEmptyState } from '@backstage/core-components';
|
||||
import ErrorBoundary from '../ErrorBoundary';
|
||||
import {
|
||||
ErrorBoundary,
|
||||
MissingAnnotationEmptyState,
|
||||
ResponseErrorPanel,
|
||||
} from '@backstage/core-components';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { OverviewTable } from '../OverviewTableComponent/OverviewTable';
|
||||
|
||||
@@ -37,13 +40,19 @@ const AzureFunctionsOverview = ({ entity }: { entity: Entity }) => {
|
||||
functionsName,
|
||||
});
|
||||
|
||||
if (functionsData.error) {
|
||||
return (
|
||||
<div>
|
||||
<ResponseErrorPanel error={functionsData.error} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<OverviewTable
|
||||
data={functionsData.data ?? []}
|
||||
loading={functionsData.loading}
|
||||
/>
|
||||
</>
|
||||
<OverviewTable
|
||||
data={functionsData.data ?? []}
|
||||
loading={functionsData.loading}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 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 React, { Component } from 'react';
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
|
||||
interface Props {}
|
||||
interface MyProps {}
|
||||
|
||||
interface MyState {
|
||||
hasError: boolean;
|
||||
}
|
||||
|
||||
export default class ErrorBoundary extends Component<MyProps, MyState> {
|
||||
static getDerivedStateFromError() {
|
||||
// Update state so the next render will show the fallback UI.
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { hasError: false };
|
||||
}
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
// You can render any custom fallback UI
|
||||
return (
|
||||
<Alert severity="error">
|
||||
Something went wrong. Please make sure that you installed:
|
||||
<strong>
|
||||
<a
|
||||
href="https://github.com/backstage/backstage/tree/master/plugins/azure-functions-backend"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
@backstage/plugin-azure-functions-backend
|
||||
</a>
|
||||
</strong>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -58,7 +58,7 @@ describe('AzureFunctionsOverviewWidget', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
worker.use(
|
||||
rest.post('/list', (_, res, ctx) => {
|
||||
rest.get('/list/func-mock', (_, res, ctx) => {
|
||||
res(ctx.json(functionResponseMock));
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import { Box, Card, Link, LinearProgress } from '@material-ui/core';
|
||||
import { FunctionsData } from '../../api/types';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
import { Table, TableColumn } from '@backstage/core-components';
|
||||
import FlashOnIcon from '@material-ui/icons/FlashOn';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import useAsyncRetry from 'react-use/lib/useAsyncRetry';
|
||||
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
|
||||
import { FunctionsData } from '../api/types';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
import { azureFunctionsApiRef } from '../api';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
|
||||
@@ -20,11 +20,8 @@ export const AZURE_FUNCTIONS_ANNOTATION = 'portal.azure.com/functions-name';
|
||||
export const useServiceEntityAnnotations = (entity: Entity) => {
|
||||
const functionsName =
|
||||
entity?.metadata.annotations?.[AZURE_FUNCTIONS_ANNOTATION] ?? '';
|
||||
const projectName =
|
||||
entity?.metadata.annotations?.['dev.azure.com/project-repo'] ?? '';
|
||||
|
||||
return {
|
||||
projectName,
|
||||
functionsName,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FunctionsData } from '../api';
|
||||
import { FunctionsData } from '@backstage/plugin-azure-functions-common';
|
||||
|
||||
export const entityMock = {
|
||||
metadata: {
|
||||
|
||||
@@ -4150,6 +4150,7 @@ __metadata:
|
||||
"@backstage/backend-common": ^0.15.1-next.2
|
||||
"@backstage/cli": ^0.19.0-next.2
|
||||
"@backstage/config": ^1.0.1
|
||||
"@backstage/plugin-azure-functions-common": "workspace:^"
|
||||
"@types/express": "*"
|
||||
"@types/supertest": ^2.0.8
|
||||
express: ^4.17.1
|
||||
@@ -4162,6 +4163,14 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-azure-functions-common@workspace:^, @backstage/plugin-azure-functions-common@workspace:plugins/azure-functions-common":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-azure-functions-common@workspace:plugins/azure-functions-common"
|
||||
dependencies:
|
||||
"@backstage/cli": ^0.19.0-next.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-azure-functions@^0.1.0, @backstage/plugin-azure-functions@workspace:plugins/azure-functions":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-azure-functions@workspace:plugins/azure-functions"
|
||||
@@ -4172,6 +4181,7 @@ __metadata:
|
||||
"@backstage/core-components": ^0.11.1-next.2
|
||||
"@backstage/core-plugin-api": ^1.0.6-next.2
|
||||
"@backstage/dev-utils": ^1.0.6-next.1
|
||||
"@backstage/plugin-azure-functions-common": "workspace:^"
|
||||
"@backstage/plugin-catalog-react": ^1.1.4-next.1
|
||||
"@backstage/test-utils": ^1.2.0-next.2
|
||||
"@backstage/theme": ^0.2.16
|
||||
|
||||
Reference in New Issue
Block a user