Fix some typos and other requested changes
Signed-off-by: ivgo <ivgo@spreadgroup.com>
This commit is contained in:
@@ -362,9 +362,9 @@ metadata:
|
||||
vault.io/secrets-path: test/backstage
|
||||
```
|
||||
|
||||
The value of this annotation contains the vault that vault curator is using to fetch
|
||||
all the relative secrets for a component. If not present when the Vault plugin is in use,
|
||||
a message will be shown instead, letting the user know what is missing in the `catalog-info.yaml`.
|
||||
The value of this annotation contains the path to the secrets of the entity in
|
||||
Vault. If not present when the Vault plugin is in use, a message will be shown
|
||||
instead, letting the user know what is missing in the `catalog-info.yaml`.
|
||||
|
||||
## Deprecated Annotations
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ To get started, first you need a running instance of Vault. You can follow [this
|
||||
|
||||
```yaml
|
||||
vault:
|
||||
sourceUrl: http://your-vault-url
|
||||
baseUrl: http://your-vault-url
|
||||
token: <VAULT_TOKEN>
|
||||
secretEngine: 'customSecretEngine' # Optional. By default it uses 'secrets'
|
||||
kvVersion: <kv-version> # Optional. The K/V version that your instance is using. The available options are '1' or '2'
|
||||
|
||||
Vendored
+3
-3
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** Configuration for the Jira plugin */
|
||||
/** Configuration for the Vault plugin */
|
||||
export interface Config {
|
||||
vault?: {
|
||||
/**
|
||||
* The sourceUrl for your Vault instance.
|
||||
* The baseUrl for your Vault instance.
|
||||
*/
|
||||
sourceUrl: string;
|
||||
baseUrl: string;
|
||||
|
||||
/**
|
||||
* The token used by Backstage to access Vault.
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
});
|
||||
|
||||
+4
-4
@@ -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}`,
|
||||
});
|
||||
}
|
||||
}),
|
||||
@@ -40,7 +40,7 @@ To get started, first you need a running instance of Vault. You can follow [this
|
||||
|
||||
```yaml
|
||||
vault:
|
||||
sourceUrl: http://your-vault-url
|
||||
baseUrl: http://your-vault-url
|
||||
token: <VAULT_TOKEN>
|
||||
secretEngine: 'customSecretEngine' # Optional. By default it uses 'secrets'
|
||||
kvVersion: <kv-version> # Optional. The K/V version that your instance is using. The available options are '1' or '2'
|
||||
|
||||
@@ -22,7 +22,7 @@ import { render } from '@testing-library/react';
|
||||
import { EntityVaultCard } from './EntityVaultCard';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
|
||||
describe('EntityVautCard', () => {
|
||||
describe('EntityVaultCard', () => {
|
||||
const server = setupServer();
|
||||
setupRequestMockHandlers(server);
|
||||
const entityAnnotationMissing: ComponentEntity = {
|
||||
|
||||
@@ -16,61 +16,18 @@
|
||||
|
||||
import React from 'react';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { makeStyles, Typography } from '@material-ui/core';
|
||||
import { isVaultAvailable } from '../../conditions';
|
||||
import { CodeSnippet, InfoCard, Button } from '@backstage/core-components';
|
||||
import { BackstageTheme } from '@backstage/theme';
|
||||
import { VAULT_SECRET_PATH_ANNOTATION } from '../../constants';
|
||||
import { EntityVaultTable } from '../EntityVaultTable';
|
||||
|
||||
const COMPONENT_YAML = `metadata:
|
||||
name: example
|
||||
annotations:
|
||||
${VAULT_SECRET_PATH_ANNOTATION}: value`;
|
||||
|
||||
const useStyles = makeStyles<BackstageTheme>(
|
||||
theme => ({
|
||||
code: {
|
||||
borderRadius: 6,
|
||||
margin: `${theme.spacing(2)}px 0px`,
|
||||
background: theme.palette.type === 'dark' ? '#444' : '#fff',
|
||||
},
|
||||
}),
|
||||
{ name: 'BackstageMissingVaultAnnotation' },
|
||||
);
|
||||
import { MissingAnnotationEmptyState } from '@backstage/core-components';
|
||||
|
||||
export const EntityVaultCard = () => {
|
||||
const { entity } = useEntity();
|
||||
const classes = useStyles();
|
||||
|
||||
if (isVaultAvailable(entity)) {
|
||||
return <EntityVaultTable entity={entity} />;
|
||||
}
|
||||
return (
|
||||
<InfoCard title="Vault">
|
||||
<>
|
||||
<Typography variant="body1">
|
||||
Add the annotation to your component YAML as shown in the highlighted
|
||||
example below:
|
||||
</Typography>
|
||||
<div className={classes.code}>
|
||||
<CodeSnippet
|
||||
text={COMPONENT_YAML}
|
||||
language="yaml"
|
||||
showLineNumbers
|
||||
highlightedNumbers={[3, 4]}
|
||||
customStyle={{ background: 'inherit', fontSize: '115%' }}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
style={{ textDecoration: 'none' }}
|
||||
to="https://backstage.io/docs/features/software-catalog/well-known-annotations"
|
||||
>
|
||||
Read more
|
||||
</Button>
|
||||
</>
|
||||
</InfoCard>
|
||||
<MissingAnnotationEmptyState annotation={VAULT_SECRET_PATH_ANNOTATION} />
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user