Merge pull request #12244 from leboncoin/vault-display-full-secret-name
fix(vault-plugin): display full secret name relative to the secret path
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-vault': patch
|
||||
'@backstage/plugin-vault-backend': patch
|
||||
---
|
||||
|
||||
Added a path notion in addition to secret name to allow to differentiate secrets in sub-paths
|
||||
@@ -70,6 +70,7 @@ export interface VaultEnvironment {
|
||||
// @public
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
path: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
|
||||
@@ -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`,
|
||||
},
|
||||
|
||||
@@ -36,6 +36,7 @@ export type VaultSecretList = {
|
||||
*/
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
path: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
@@ -134,6 +135,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}`,
|
||||
});
|
||||
|
||||
@@ -32,6 +32,7 @@ export const vaultPlugin: BackstagePlugin<{}, {}>;
|
||||
// @public
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
path: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
|
||||
@@ -31,11 +31,13 @@ describe('api', () => {
|
||||
items: [
|
||||
{
|
||||
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`,
|
||||
},
|
||||
|
||||
@@ -29,6 +29,7 @@ export const vaultApiRef = createApiRef<VaultApi>({
|
||||
*/
|
||||
export type VaultSecret = {
|
||||
name: string;
|
||||
path: string;
|
||||
showUrl: string;
|
||||
editUrl: string;
|
||||
};
|
||||
|
||||
@@ -72,11 +72,13 @@ describe('EntityVaultTable', () => {
|
||||
items: [
|
||||
{
|
||||
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`,
|
||||
},
|
||||
|
||||
@@ -53,12 +53,16 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => {
|
||||
];
|
||||
|
||||
const data = (value || []).map(secret => {
|
||||
const secretName = `${secret.path.replace(`${secretPath}/`, '')}/${
|
||||
secret.name
|
||||
}`;
|
||||
|
||||
return {
|
||||
secret: secret.name,
|
||||
secret: secretName,
|
||||
view: (
|
||||
<Link
|
||||
aria-label="View"
|
||||
title={`View ${secret.name}`}
|
||||
title={`View ${secretName}`}
|
||||
to={secret.showUrl}
|
||||
>
|
||||
<Visibility style={{ fontSize: 16 }} />
|
||||
@@ -67,7 +71,7 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => {
|
||||
edit: (
|
||||
<Link
|
||||
aria-label="Edit"
|
||||
title={`Edit ${secret.name}`}
|
||||
title={`Edit ${secretName}`}
|
||||
to={secret.editUrl}
|
||||
>
|
||||
<Edit style={{ fontSize: 16 }} />
|
||||
|
||||
Reference in New Issue
Block a user