feat: adopt vault api signature calls based on proposal
Signed-off-by: Ilya Katlinski <ilya.katlinsky@gmail.com>
This commit is contained in:
@@ -67,7 +67,7 @@ metadata:
|
||||
# ...
|
||||
annotations:
|
||||
vault.io/secrets-path: path/to/secrets
|
||||
vault.io/secret-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.
|
||||
```
|
||||
|
||||
The path is relative to your secrets engine folder. So if you want to get the secrets for backstage and you have the following directory structure:
|
||||
|
||||
@@ -87,9 +87,9 @@ describe('api', () => {
|
||||
});
|
||||
|
||||
it('should return secrets with custom engine', async () => {
|
||||
expect(await api.listSecrets('test/success', 'kv')).toEqual(
|
||||
mockSecretsResult.items,
|
||||
);
|
||||
expect(
|
||||
await api.listSecrets('test/success', { secretEngine: 'kv' }),
|
||||
).toEqual(mockSecretsResult.items);
|
||||
expect(fetchApiSpy).toHaveBeenCalledWith(
|
||||
`${mockBaseUrl}/v1/secrets/test%2Fsuccess?engine=kv`,
|
||||
expect.anything(),
|
||||
|
||||
@@ -46,11 +46,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[]>;
|
||||
}
|
||||
|
||||
@@ -96,11 +98,14 @@ export class VaultClient implements VaultApi {
|
||||
|
||||
async listSecrets(
|
||||
secretPath: string,
|
||||
secretMount?: string | undefined,
|
||||
options?: {
|
||||
secretEngine?: string;
|
||||
},
|
||||
): Promise<VaultSecret[]> {
|
||||
const query: { [key in string]: any } = {};
|
||||
if (secretMount) {
|
||||
query.engine = secretMount;
|
||||
const { secretEngine } = options || {};
|
||||
if (secretEngine) {
|
||||
query.engine = secretEngine;
|
||||
}
|
||||
|
||||
const result = await this.callApi<{ items: VaultSecret[] }>(
|
||||
|
||||
@@ -49,7 +49,7 @@ export const EntityVaultTable = ({ entity }: { entity: Entity }) => {
|
||||
const { value, loading, error } = useAsync(async (): Promise<
|
||||
VaultSecret[]
|
||||
> => {
|
||||
return vaultApi.listSecrets(secretPath, secretEngine);
|
||||
return vaultApi.listSecrets(secretPath, { secretEngine });
|
||||
}, []);
|
||||
|
||||
const columns: TableColumn[] = [
|
||||
|
||||
Reference in New Issue
Block a user