fix(vault-plugin): display full secret name relative to the secret path
Only secret name was displayed in the table. It could be a problem when secret path has multiple subpath containing secrets with the same name. Displaying the relative path from secret path configured in the entity annotation allows to differentiate the secrets in this case. Signed-off-by: denis.fortin <denis.fortin@adevinta.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-vault': minor
|
||||
'@backstage/plugin-vault-backend': minor
|
||||
---
|
||||
|
||||
Added a path notion in addition to secret name to allow to differentiate secrets in subpaths
|
||||
@@ -46,11 +46,13 @@ describe('VaultApi', () => {
|
||||
const mockSecretsResult: VaultSecret[] = [
|
||||
{
|
||||
name: 'secret::one',
|
||||
path: 'test/success',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::one`,
|
||||
showUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/show/test/success/secret::one`,
|
||||
},
|
||||
{
|
||||
name: 'secret::two',
|
||||
path: 'test/success',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::two`,
|
||||
showUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/show/test/success/secret::two`,
|
||||
},
|
||||
|
||||
@@ -34,6 +34,7 @@ export type VaultSecretList = {
|
||||
*/
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
path: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
@@ -131,6 +132,7 @@ export class VaultClient implements VaultApi {
|
||||
} else {
|
||||
secrets.push({
|
||||
name: secret,
|
||||
path: secretPath,
|
||||
editUrl: `${this.vaultConfig.baseUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/edit/${secretPath}/${secret}`,
|
||||
showUrl: `${this.vaultConfig.baseUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/show/${secretPath}/${secret}`,
|
||||
});
|
||||
|
||||
@@ -45,11 +45,13 @@ const mockedApi: VaultApi = {
|
||||
return [
|
||||
{
|
||||
name: 'a::b',
|
||||
path: '',
|
||||
editUrl: 'https://example.com',
|
||||
showUrl: 'https://example.com',
|
||||
},
|
||||
{
|
||||
name: 'c::d',
|
||||
path: '',
|
||||
editUrl: 'https://example.com',
|
||||
showUrl: 'https://example.com',
|
||||
},
|
||||
|
||||
@@ -30,11 +30,13 @@ describe('api', () => {
|
||||
const mockSecretsResult: VaultSecret[] = [
|
||||
{
|
||||
name: 'secret::one',
|
||||
path: 'test/success',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::one`,
|
||||
showUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/show/test/success/secret::one`,
|
||||
},
|
||||
{
|
||||
name: 'secret::two',
|
||||
path: 'test/success',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::two`,
|
||||
showUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/show/test/success/secret::two`,
|
||||
},
|
||||
|
||||
@@ -21,6 +21,7 @@ export const vaultApiRef = createApiRef<VaultApi>({
|
||||
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
path: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
|
||||
@@ -71,11 +71,13 @@ describe('EntityVaultTable', () => {
|
||||
const mockSecretsResult: VaultSecret[] = [
|
||||
{
|
||||
name: 'secret::one',
|
||||
path: 'test/success',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::one`,
|
||||
showUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/show/test/success/secret::one`,
|
||||
},
|
||||
{
|
||||
name: 'secret::two',
|
||||
path: 'test/success',
|
||||
editUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/edit/test/success/secret::two`,
|
||||
showUrl: `${mockBaseUrl}/ui/vault/secrets/secrets/show/test/success/secret::two`,
|
||||
},
|
||||
|
||||
@@ -49,7 +49,7 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => {
|
||||
|
||||
const data = (value || []).map(secret => {
|
||||
return {
|
||||
secret: secret.name,
|
||||
secret: `${secret.path.replace(secretPath + "/", "")}/${secret.name}`,
|
||||
view: (
|
||||
<a
|
||||
aria-label="View"
|
||||
|
||||
Reference in New Issue
Block a user