From b5170119fcc0d40f2e1089e522b9062f120e2a56 Mon Sep 17 00:00:00 2001 From: "denis.fortin" Date: Tue, 28 Jun 2022 11:04:41 +0200 Subject: [PATCH] fix(vault-plugin): code factorization Signed-off-by: denis.fortin --- .changeset/moody-crabs-march.md | 4 ++-- .../EntityVaultTable/EntityVaultTable.tsx | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.changeset/moody-crabs-march.md b/.changeset/moody-crabs-march.md index 3d7bc2d290..f3ae24629a 100644 --- a/.changeset/moody-crabs-march.md +++ b/.changeset/moody-crabs-march.md @@ -1,6 +1,6 @@ --- -'@backstage/plugin-vault': minor -'@backstage/plugin-vault-backend': minor +'@backstage/plugin-vault': patch +'@backstage/plugin-vault-backend': patch --- Added a path notion in addition to secret name to allow to differentiate secrets in subpaths diff --git a/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx b/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx index 85035c04d9..5923a4db6b 100644 --- a/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx +++ b/plugins/vault/src/components/EntityVaultTable/EntityVaultTable.tsx @@ -32,6 +32,13 @@ export const vaultSecretPath = (entity: Entity) => { return { secretPath }; }; +function getSecretRelativeName( + secretPath: string, + secret: VaultSecret, +): string { + return `${secret.path.replace(`${secretPath}/`, '')}/${secret.name}`; +} + export const EntityVaultTable = ({ entity }: { entity: Entity }) => { const vaultApi = useApi(vaultApiRef); const { secretPath } = vaultSecretPath(entity); @@ -54,11 +61,11 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => { const data = (value || []).map(secret => { return { - secret: `${secret.path.replace(secretPath + "/", "")}/${secret.name}`, + secret: getSecretRelativeName(secretPath, secret), view: ( @@ -67,7 +74,7 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => { edit: (