Fix some typos and other requested changes

Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
ivgo
2022-05-12 12:18:43 +02:00
parent 477061a096
commit 296bfcb1fd
13 changed files with 2827 additions and 2322 deletions
@@ -32,14 +32,14 @@ describe('GetVaultConfig', () => {
it('loads default params', () => {
const config = new ConfigReader({
vault: {
sourceUrl: 'http://www.example.com',
baseUrl: 'http://www.example.com',
token: '123',
},
});
const vaultConfig = getVaultConfig(config);
expect(vaultConfig).toStrictEqual({
sourceUrl: 'http://www.example.com',
baseUrl: 'http://www.example.com',
token: '123',
kvVersion: 2,
secretEngine: 'secrets',
@@ -49,7 +49,7 @@ describe('GetVaultConfig', () => {
it('loads custom params', () => {
const config = new ConfigReader({
vault: {
sourceUrl: 'http://www.example.com',
baseUrl: 'http://www.example.com',
token: '123',
kvVersion: 1,
secretEngine: 'test',
@@ -58,7 +58,7 @@ describe('GetVaultConfig', () => {
const vaultConfig = getVaultConfig(config);
expect(vaultConfig).toStrictEqual({
sourceUrl: 'http://www.example.com',
baseUrl: 'http://www.example.com',
token: '123',
kvVersion: 1,
secretEngine: 'test',
+3 -3
View File
@@ -23,9 +23,9 @@ import { Config } from '@backstage/config';
*/
export interface VaultConfig {
/**
* The sourceUrl for your Vault instance.
* The baseUrl for your Vault instance.
*/
sourceUrl: string;
baseUrl: string;
/**
* The token used by Backstage to access Vault.
@@ -52,7 +52,7 @@ export interface VaultConfig {
*/
export function getVaultConfig(config: Config): VaultConfig {
return {
sourceUrl: config.getString('vault.sourceUrl'),
baseUrl: config.getString('vault.baseUrl'),
token: config.getString('vault.token'),
kvVersion: config.getOptionalNumber('vault.kvVersion') ?? 2,
secretEngine: config.getOptionalString('vault.secretEngine') ?? 'secrets',
@@ -97,7 +97,6 @@ export class VaultBuilder {
router.use(express.json());
router.get('/health', (_, response) => {
this.env.logger.info('PONG!');
response.send({ status: 'ok' });
});
@@ -29,7 +29,7 @@ describe('createRouter', () => {
logger: getVoidLogger(),
config: new ConfigReader({
vault: {
sourceUrl: 'https://www.example.com',
baseUrl: 'https://www.example.com',
token: '1234567890',
},
}),
@@ -27,7 +27,7 @@ describe('VaultApi', () => {
const mockBaseUrl = 'https://api-vault.com';
const config = new ConfigReader({
vault: {
sourceUrl: mockBaseUrl,
baseUrl: mockBaseUrl,
token: '1234567890',
},
});
@@ -55,7 +55,7 @@ export class VaultClient implements VaultApi {
method: string = 'GET',
): Promise<T | undefined> {
const response = await fetch(
`${this.vaultConfig.sourceUrl}/${path}?${new URLSearchParams(
`${this.vaultConfig.baseUrl}/${path}?${new URLSearchParams(
query,
).toString()}`,
{
@@ -78,7 +78,7 @@ export class VaultClient implements VaultApi {
}
getFrontendSecretsUrl(): string {
return `${this.vaultConfig.sourceUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}`;
return `${this.vaultConfig.baseUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}`;
}
async listSecrets(secretPath: string): Promise<Secret[]> {
@@ -101,8 +101,8 @@ export class VaultClient implements VaultApi {
} else {
secrets.push({
name: secret,
editUrl: `${this.vaultConfig.sourceUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/edit/${secretPath}/${secret}`,
showUrl: `${this.vaultConfig.sourceUrl}/ui/vault/secrets/${this.vaultConfig.secretEngine}/show/${secretPath}/${secret}`,
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}`,
});
}
}),