feat: adopt vault api signature calls based on proposal

Signed-off-by: Ilya Katlinski <ilya.katlinsky@gmail.com>
This commit is contained in:
Ilya Katlinski
2023-09-10 07:20:10 +02:00
parent 03947ee72a
commit 1bdcf6bb7a
8 changed files with 34 additions and 19 deletions
+2 -2
View File
@@ -115,7 +115,7 @@ In case you need to support different secret engines for entities of the catalog
# ...
annotations:
vault.io/secrets-path: path/to/secrets
+ vault.io/secrets-engine: customSecretEngine # Optional. By default it uses 'secertEngine' value from configuration.
+ vault.io/secrets-engine: customSecretEngine # Optional. By default it uses the 'secretEngine' value from your app-config.
```
That will overwrite the default secret engine from the configuration.
@@ -152,7 +152,7 @@ export default async function createPlugin(
## Features
- List the secrets present in a certain path
- Use different secret engines for different components
- Use different secret engines for different entities
- Open a link to view the secret
- Open a link to edit the secret
- Renew the token automatically with a defined periodicity
@@ -149,7 +149,9 @@ export class VaultBuilder {
throw new InputError(`Invalid engine: ${engine}`);
}
const secrets = await vaultApi.listSecrets(path, engine);
const secrets = await vaultApi.listSecrets(path, {
secretEngine: engine,
});
res.json({ items: secrets });
});
@@ -98,7 +98,9 @@ describe('VaultApi', () => {
});
it('should return secrets for custom engine', async () => {
const secrets = await api.listSecrets('test/success', 'kv');
const secrets = await api.listSecrets('test/success', {
secretEngine: 'kv',
});
expect(secrets).toEqual(mockSecretsResult('kv'));
});
+11 -5
View File
@@ -63,11 +63,13 @@ export interface VaultApi {
/**
* Returns a list of secrets used to show in a table.
* @param secretPath - The path where the secrets are stored in Vault
* @param secretMount - The mount point of the secrets engine, optional, overrides default secret engine
* @param options - Additional options to be passed to the Vault API, allows to override vault default settings in app config file
*/
listSecrets(
secretPath: string,
secretMount?: string | undefined,
options?: {
secretEngine?: string;
},
): Promise<VaultSecret[]>;
/**
@@ -123,9 +125,11 @@ export class VaultClient implements VaultApi {
async listSecrets(
secretPath: string,
secretEngine?: string | undefined,
options?: {
secretEngine?: string;
},
): Promise<VaultSecret[]> {
const mount = secretEngine || this.vaultConfig.secretEngine;
const mount = options?.secretEngine || this.vaultConfig.secretEngine;
const listUrl =
this.vaultConfig.kvVersion === 2
@@ -142,7 +146,9 @@ export class VaultClient implements VaultApi {
if (secret.endsWith('/')) {
secrets.push(
...(await this.limit(() =>
this.listSecrets(`${secretPath}/${secret.slice(0, -1)}`, mount),
this.listSecrets(`${secretPath}/${secret.slice(0, -1)}`, {
secretEngine: mount,
}),
)),
);
} else {