Apply changes, update tests & change vault icon temporarilly
Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
@@ -7,14 +7,10 @@
|
||||
|
||||
import { BackstagePlugin } from '@backstage/core-plugin-api';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "EntityVaultCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export const EntityVaultCard: () => JSX.Element;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "vaultPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public
|
||||
export const vaultPlugin: BackstagePlugin<{}, {}>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@backstage/plugin-vault",
|
||||
"description": "A Backstage plugin that integrates towards Vault",
|
||||
"version": "0.1.0",
|
||||
"version": "0.0.0",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
@@ -34,11 +34,11 @@
|
||||
"postpack": "backstage-cli package postpack"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-test-utils": "^0.1.23",
|
||||
"@backstage/catalog-model": "^1.0.1",
|
||||
"@backstage/core-components": "^0.9.3",
|
||||
"@backstage/core-plugin-api": "^1.0.1",
|
||||
"@backstage/plugin-catalog-react": "^1.0.1",
|
||||
"@backstage/backend-test-utils": "^0.1.24",
|
||||
"@backstage/catalog-model": "^1.0.2",
|
||||
"@backstage/core-components": "^0.9.4",
|
||||
"@backstage/core-plugin-api": "^1.0.2",
|
||||
"@backstage/plugin-catalog-react": "^1.1.0",
|
||||
"@backstage/theme": "^0.2.15",
|
||||
"@material-ui/core": "^4.12.2",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
@@ -49,10 +49,10 @@
|
||||
"react": "^16.13.1 || ^17.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.17.0",
|
||||
"@backstage/core-app-api": "^1.0.1",
|
||||
"@backstage/dev-utils": "^1.0.1",
|
||||
"@backstage/test-utils": "^1.0.1",
|
||||
"@backstage/cli": "^0.17.1",
|
||||
"@backstage/core-app-api": "^1.0.2",
|
||||
"@backstage/dev-utils": "^1.0.2",
|
||||
"@backstage/test-utils": "^1.1.0",
|
||||
"@testing-library/jest-dom": "^5.10.1",
|
||||
"@testing-library/react": "^12.1.3",
|
||||
"@testing-library/user-event": "^14.0.0",
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { setupRequestMockHandlers } from '@backstage/backend-test-utils';
|
||||
import { setupRequestMockHandlers } from '@backstage/test-utils';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { Secret, VaultClient } from './api';
|
||||
import { VaultSecret, VaultClient } from './api';
|
||||
import { UrlPatternDiscovery } from '@backstage/core-app-api';
|
||||
|
||||
describe('api', () => {
|
||||
@@ -27,7 +27,7 @@ describe('api', () => {
|
||||
const mockBaseUrl = 'https://api-vault.com/api/vault';
|
||||
const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl);
|
||||
|
||||
const mockSecretsResult: Secret[] = [
|
||||
const mockSecretsResult: VaultSecret[] = [
|
||||
{
|
||||
name: 'secret::one',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::one`,
|
||||
|
||||
@@ -19,20 +19,14 @@ export const vaultApiRef = createApiRef<VaultApi>({
|
||||
id: 'plugin.vault.service',
|
||||
});
|
||||
|
||||
export type VaultSecretList = {
|
||||
data: {
|
||||
keys: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export type Secret = {
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
|
||||
export interface VaultApi {
|
||||
listSecrets(secretPath: string): Promise<Secret[]>;
|
||||
listSecrets(secretPath: string): Promise<VaultSecret[]>;
|
||||
}
|
||||
|
||||
export class VaultClient implements VaultApi {
|
||||
@@ -61,8 +55,8 @@ export class VaultClient implements VaultApi {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async listSecrets(secretPath: string): Promise<Secret[]> {
|
||||
const result = await this.callApi<Secret[]>('v1/secrets', {
|
||||
async listSecrets(secretPath: string): Promise<VaultSecret[]> {
|
||||
const result = await this.callApi<VaultSecret[]>('v1/secrets', {
|
||||
path: secretPath,
|
||||
});
|
||||
if (!result) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import { ComponentEntity } from '@backstage/catalog-model';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { EntityVaultTable } from './EntityVaultTable';
|
||||
import { ApiProvider, UrlPatternDiscovery } from '@backstage/core-app-api';
|
||||
import { Secret, vaultApiRef, VaultClient } from '../../api';
|
||||
import { VaultSecret, vaultApiRef, VaultClient } from '../../api';
|
||||
import { rest } from 'msw';
|
||||
|
||||
describe('EntityVautTable', () => {
|
||||
@@ -68,7 +68,7 @@ describe('EntityVautTable', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const mockSecretsResult: Secret[] = [
|
||||
const mockSecretsResult: VaultSecret[] = [
|
||||
{
|
||||
name: 'secret::one',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::one`,
|
||||
|
||||
@@ -22,7 +22,7 @@ import Edit from '@material-ui/icons/Edit';
|
||||
import Visibility from '@material-ui/icons/Visibility';
|
||||
import Alert from '@material-ui/lab/Alert';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import { Secret, vaultApiRef } from '../../api';
|
||||
import { VaultSecret, vaultApiRef } from '../../api';
|
||||
import { VAULT_SECRET_PATH_ANNOTATION } from '../../constants';
|
||||
|
||||
export const vaultSecretPath = (entity: Entity) => {
|
||||
@@ -35,7 +35,9 @@ export const vaultSecretPath = (entity: Entity) => {
|
||||
export const EntityVaultTable = ({ entity }: { entity: Entity }) => {
|
||||
const vaultApi = useApi(vaultApiRef);
|
||||
const { secretPath } = vaultSecretPath(entity);
|
||||
const { value, loading, error } = useAsync(async (): Promise<Secret[]> => {
|
||||
const { value, loading, error } = useAsync(async (): Promise<
|
||||
VaultSecret[]
|
||||
> => {
|
||||
return vaultApi.listSecrets(secretPath);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@ import {
|
||||
|
||||
import { VaultClient, vaultApiRef } from './api';
|
||||
|
||||
/**
|
||||
* The vault plugin.
|
||||
* @public
|
||||
*/
|
||||
export const vaultPlugin = createPlugin({
|
||||
id: 'vault',
|
||||
apis: [
|
||||
@@ -37,6 +41,10 @@ export const vaultPlugin = createPlugin({
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* Card used to show the list of Vault secrets.
|
||||
* @public
|
||||
*/
|
||||
export const EntityVaultCard = vaultPlugin.provide(
|
||||
createComponentExtension({
|
||||
name: 'EntityVaultCard',
|
||||
|
||||
Reference in New Issue
Block a user