Skip to content

Commit e1ecad3

Browse files
feat(website): add docs::warnings macro support and warn about no auth (#24866)
* feat(api): add docs::warnings macro support and warn about no auth on api endpoint * Fix macro order * Fix conflict in generated file * Update src/config/api.rs Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com> * Regenerate docs --------- Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
1 parent 1cc1c25 commit e1ecad3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

scripts/generate-component-docs.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,16 @@ def resolve_schema(root_schema, schema)
781781
resolved['required'] = is_required_field
782782
end
783783

784+
# Resolve any warnings attached to this option.
785+
#
786+
# Warnings can be specified in Rust via `#[configurable(metadata(docs::warnings = "..."))]`.
787+
# Multiple warnings can be specified by repeating the attribute, and they will be emitted as an
788+
# array in the CUE output.
789+
warnings = get_schema_metadata(schema, 'docs::warnings')
790+
if !warnings.nil?
791+
resolved['warnings'] = warnings.is_a?(Array) ? warnings : [warnings]
792+
end
793+
784794
# Reconcile the resolve schema, which essentially gives us a chance to, once the schema is
785795
# entirely resolved, check it for logical inconsistencies, fix up anything that we reasonably can,
786796
# and so on.

src/config/api.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ use vector_lib::configurable::configurable_component;
55

66
/// API options.
77
#[configurable_component]
8+
#[configurable(metadata(
9+
docs::warnings = "The API currently does not support authentication. Only enable it in isolated environments or for debugging. It must not be exposed to untrusted clients."
10+
))]
811
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
912
#[serde(default, deny_unknown_fields)]
1013
pub struct Options {

website/cue/reference/generated/configuration.cue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ generated: configuration: {
4646
}
4747
}
4848
description: "API options."
49-
group: "api"
49+
warnings: ["The API currently does not support authentication. Only enable it in isolated environments or for debugging. It must not be exposed to untrusted clients."]
50+
group: "api"
5051
}
5152
enrichment_tables: {
5253
type: object: options: "*": {

0 commit comments

Comments
 (0)