From d6e39ceca21f75ff0dcbf2ee9412ce5b9d6de71d Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Wed, 6 Mar 2024 15:23:31 +0545 Subject: [PATCH] add all template variables --- common/src/components/ConfigTransform.jsx | 81 +++++++++++-------- .../docs/config-db/concepts/masking.md | 24 +++--- .../docs/config-db/concepts/relationship.md | 4 + 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/common/src/components/ConfigTransform.jsx b/common/src/components/ConfigTransform.jsx index da2a6c89..cc6307df 100644 --- a/common/src/components/ConfigTransform.jsx +++ b/common/src/components/ConfigTransform.jsx @@ -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: '' }, { @@ -62,33 +65,45 @@ export function ConfigTransform({ children, to, anchor }) { ] return ( - - - - - - - - - - - {tableRows.map((row, index) => ( - - - - - + <> +
FieldDescriptionSchemeRequired
{row.field}{row.description} - {row.schemaLink ? ( - - {row.scheme} - - ) : ( - {row.scheme} - )} - {row.required}
+ + + + + + - ))} - -
FieldDescriptionSchemeRequired
+ + + {tableRows.map((row, index) => ( + + + {row.field} + + {row.description} + + {row.schemaLink ? ( + + {row.scheme} + + ) : ( + {row.scheme} + )} + + {row.required} + + ))} + + + + +

+ Both the go template and javascript receive{' '} + ScrapeResult as the + template variable. +

+
+ ) } diff --git a/mission-control/docs/config-db/concepts/masking.md b/mission-control/docs/config-db/concepts/masking.md index 3a2ba28a..ffb9a324 100644 --- a/mission-control/docs/config-db/concepts/masking.md +++ b/mission-control/docs/config-db/concepts/masking.md @@ -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. | `jsonpath` | `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` diff --git a/mission-control/docs/config-db/concepts/relationship.md b/mission-control/docs/config-db/concepts/relationship.md index 4fece411..5a0323ce 100644 --- a/mission-control/docs/config-db/concepts/relationship.md +++ b/mission-control/docs/config-db/concepts/relationship.md @@ -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.