Skip to content

Commit

Permalink
add all template variables
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Mar 6, 2024
1 parent 03037b5 commit d6e39ce
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 47 deletions.
81 changes: 48 additions & 33 deletions common/src/components/ConfigTransform.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
import React from 'react'
import Admonition from '@theme/Admonition'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import Link from '@docusaurus/Link'

export function ConfigTransform({ children, to, anchor }) {
// Define table rows as an array of TableRow objects
export function ConfigTransform() {
const { siteConfig } = useDocusaurusContext()
const tableRows = [
{
field: 'gotemplate',
description: 'Specify Go template for use in script',
description: 'Go template to transform the scraped config item',
scheme: 'string',
required: ''
},
{
field: 'javascript',
description: 'Specify javascript syntax for script',
description: 'Javascript to transform the scraped config item',
scheme: 'string',
required: ''
},
{
field: 'jsonpath',
description: 'Specify JSONPath',
scheme: 'string',
scheme: 'jsonpath',
schemaLink: siteConfig.customFields.links['jsonpath'],
required: ''
},
{
field: 'expr',
description: 'Specify Cel expression',
scheme: 'string',
scheme: 'cel-expression',
schemaLink: siteConfig.customFields.links['cel'],
required: ''
},
{
Expand Down Expand Up @@ -62,33 +65,45 @@ export function ConfigTransform({ children, to, anchor }) {
]

return (
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
<th>Scheme</th>
<th>Required</th>
</tr>
</thead>
<tbody>
{tableRows.map((row, index) => (
<tr key={index}>
<td>{row.field}</td>
<td>{row.description}</td>
<td>
{row.schemaLink ? (
<Link to={row.schemaLink}>
<code>{row.scheme}</code>
</Link>
) : (
<code>{row.scheme}</code>
)}
</td>
<td>{row.required}</td>
<>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
<th>Scheme</th>
<th>Required</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{tableRows.map((row, index) => (
<tr key={index}>
<td>
<code>{row.field}</code>
</td>
<td>{row.description}</td>
<td>
{row.schemaLink ? (
<Link to={row.schemaLink}>
<code>{row.scheme}</code>
</Link>
) : (
<code>{row.scheme}</code>
)}
</td>
<td>{row.required}</td>
</tr>
))}
</tbody>
</table>

<Admonition type="info">
<p>
Both the go template and javascript receive{' '}
<a href="/config-db/references/scrape-result">ScrapeResult</a> as the
template variable.
</p>
</Admonition>
</>
)
}
24 changes: 10 additions & 14 deletions mission-control/docs/config-db/concepts/masking.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ Masking allows replacing sensitive fields with hash of that field or with a stat
The field to mask is specified by the `jsonPath` config and `value` field defines the hash function or the static value.
[See example](../examples/masking-fields).

| Field | Description | Scheme | Required |
| ---------- | ------------------------------------------------------------- | ------------------------------------------- | -------- |
| `selector` | Selector helps in choosing which configs should use the mask. | [`MaskSelector`](#maskselector) | `true` |
| `jsonpath` | Specify JSONPath expression for the fields | `string` | `true` |
| `value` | Value can be a name of a hash function or just a string. | [`hashFunction`](#supported-hash-functions) | `true` |

### MaskSelector

| Field | Description | Scheme | Required |
| ------ | ----------------------------------------- | -------- | -------- |
| `type` | Type is the config type to apply the mask | `string` | `true` |

Config DB allows selectively applying masks to certain types of configs. Therefore, you can apply a mask to all the `Config` types and another mask to all the `Secret` types.
| Field | Description | Scheme | Required |
| ---------- | ------------------------------------------------------------- | ------------------------------------------------- | -------- |
| `selector` | Selector helps in choosing which configs should use the mask. | <CommonLink to="jsonpath">`jsonpath`</CommonLink> | `true` |
| `jsonpath` | Specify JSONPath expression for the fields | `string` | `true` |
| `value` | Value can be a name of a hash function or just a string. | [`hashFunction`](#supported-hash-functions) | `true` |

:::info
Masks are applied in the order they are specified in the configuration file.
:::

### Supported hash functions
## Template Variable

The `selector` cel expression receives the [`ScrapeResult`](../references/scrape-result) as its template variable.

## Supported hash functions

- `md5sum`
4 changes: 4 additions & 0 deletions mission-control/docs/config-db/concepts/relationship.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ RelationshipLookup offers different ways to specify a lookup value
| `expr` | Use an expression to get the value | `string` | |
| `value` | Specify a static value | `string` | |
| `label` | Get the value from a label | `string` | |

### Template Variables

Both the `filter` and `expr` in the relationship config & the `expr` in relationship lookup receive the [`ScrapeResult`](../references/scrape-result) as its template variable.

0 comments on commit d6e39ce

Please sign in to comment.