Skip to content

Commit f462b39

Browse files
prontmissedone
authored andcommitted
docs(config): deprecate boolean configuration shorthand (#26680)
1 parent 5cdfc0f commit f462b39

6 files changed

Lines changed: 62 additions & 4 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
what: "Boolean shorthand for object-valued configuration options"
3+
deprecated_since: "0.60.0"
4+
---
5+
6+
Boolean shorthand for object-valued configuration options is deprecated. Use the object form instead
7+
so that each setting has one consistent representation and the options being configured are explicit.
8+
9+
Existing boolean values continue to work. Removal is not yet scheduled. We will give users at least
10+
one month to migrate before removing this shorthand.
11+
12+
This applies to `healthcheck` on sinks, global and sink `acknowledgements`, `jetstream` on the NATS sink,
13+
and `acknowledgements` on the Splunk HEC source.
14+
Ordinary boolean options, such as `healthcheck.enabled`, are unaffected.
15+
16+
Please also see the [dedicated note for `use_otlp_decoding`](/deprecations/#opentelemetry-use_otlp_decoding).
17+
18+
### Settings with an `enabled` field
19+
20+
For `healthcheck`, global and sink `acknowledgements`, NATS sink `jetstream`, and Splunk HEC source
21+
`acknowledgements`, replace the boolean with an object containing the same value in `enabled`.
22+
For example, within a sink configuration, replace:
23+
24+
```yaml
25+
healthcheck: false
26+
acknowledgements: true
27+
```
28+
29+
with:
30+
31+
```yaml
32+
healthcheck:
33+
enabled: false
34+
acknowledgements:
35+
enabled: true
36+
```
37+
38+
Other options in these objects retain their defaults. Use the same transformation for either `true`
39+
or `false`.

‎lib/vector-config/src/schema/helpers.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,9 @@ pub fn generate_bool_or_struct_schema(
798798
.definitions_mut()
799799
.insert(name.clone(), Schema::Bool(false));
800800
let object = get_or_generate_schema(config, generator, None)?;
801-
let mut schema = generate_one_of_schema(&[generate_bool_schema(), object]);
801+
let mut boolean = generate_bool_schema();
802+
boolean.metadata().deprecated = true;
803+
let mut schema = generate_one_of_schema(&[boolean, object]);
802804
let mut metadata = config.make_metadata();
803805
metadata.add_custom_attribute(CustomAttribute::kv(
804806
constants::DOCS_META_ENUM_TAGGING,

‎lib/vector-config/tests/integration/bool_or_struct.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ fn shared_schema_preserves_defaults_descriptions_and_deprecation() {
136136
.unwrap();
137137
assert_eq!(shared["deprecated"], true);
138138
assert_eq!(shared["_metadata"]["docs::enum_tagging"], "untagged");
139+
assert_eq!(shared["oneOf"][0]["deprecated"], true);
139140
}
140141

141142
#[test]

‎lib/vector-core/src/serde.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ pub fn is_default<E: Default + PartialEq>(e: &E) -> bool {
2525
/// Returns the error from deserializing the underlying struct.
2626
pub fn bool_or_struct<'de, T, D>(deserializer: D) -> Result<T, D::Error>
2727
where
28-
T: Deserialize<'de> + From<bool>,
28+
T: Deserialize<'de> + From<bool> + Configurable,
2929
D: Deserializer<'de>,
3030
{
3131
struct BoolOrStruct<T>(PhantomData<fn() -> T>);
3232

3333
impl<'de, T> de::Visitor<'de> for BoolOrStruct<T>
3434
where
35-
T: Deserialize<'de> + From<bool>,
35+
T: Deserialize<'de> + From<bool> + Configurable,
3636
{
3737
type Value = T;
3838

@@ -44,6 +44,12 @@ where
4444
where
4545
E: de::Error,
4646
{
47+
// Already-deprecated types retain their existing migration guidance.
48+
if !T::metadata().deprecated() {
49+
tracing::warn!(
50+
"DEPRECATED: Boolean shorthand for an object-valued configuration option. Use the object form instead. See https://vector.dev/deprecations/ for migration instructions."
51+
);
52+
}
4753
Ok(value.into())
4854
}
4955

‎website/cue/reference/components/sinks.cue‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ components: sinks: [Name=string]: {
99
inputs: generated.components.sinks.configuration.inputs
1010
buffer: generated.components.sinks.configuration.buffer
1111
healthcheck: {
12-
description: generated.components.sinks.configuration.healthcheck.description
12+
description: """
13+
\(generated.components.sinks.configuration.healthcheck.description)
14+
15+
A boolean value sets `enabled`; other healthcheck options retain their defaults.
16+
"""
1317
required: generated.components.sinks.configuration.healthcheck.required
18+
type: bool: generated.components.sinks.configuration.healthcheck.type.bool
1419
type: object: options: {
1520
enabled: generated.components.sinks.configuration.healthcheck.type.object.options.enabled
1621

‎website/data/deprecations.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"deprecated_since": "0.59.0",
66
"description": "The `aggregate` transform now also emits the failed-updates counter with the `_total` suffix, matching Vector's counter naming convention:\n\n- `aggregate_failed_updates_total`\n\nThe previous name without the `_total` suffix is deprecated and will be removed in a future release. Migrate any dashboards or alerts that reference:\n\n- `aggregate_failed_updates`"
77
},
8+
{
9+
"what": "Boolean shorthand for object-valued configuration options",
10+
"deprecated_since": "0.60.0",
11+
"description": "Boolean shorthand for object-valued configuration options is deprecated. Use the object form instead\nso that each setting has one consistent representation and the options being configured are explicit.\n\nExisting boolean values continue to work. Removal is not yet scheduled. We will give users at least\none month to migrate before removing this shorthand.\n\nThis applies to `healthcheck` on sinks, global and sink `acknowledgements`, `jetstream` on the NATS sink,\nand `acknowledgements` on the Splunk HEC source.\nOrdinary boolean options, such as `healthcheck.enabled`, are unaffected.\n\nPlease also see the [dedicated note for `use_otlp_decoding`](/deprecations/#opentelemetry-use_otlp_decoding).\n\n### Settings with an `enabled` field\n\nFor `healthcheck`, global and sink `acknowledgements`, NATS sink `jetstream`, and Splunk HEC source\n`acknowledgements`, replace the boolean with an object containing the same value in `enabled`.\nFor example, within a sink configuration, replace:\n\n```yaml\nhealthcheck: false\nacknowledgements: true\n```\n\nwith:\n\n```yaml\nhealthcheck:\n enabled: false\nacknowledgements:\n enabled: true\n```\n\nOther options in these objects retain their defaults. Use the same transformation for either `true`\nor `false`."
12+
},
813
{
914
"what": "omitting the `version` field on `influxdb_logs` and `influxdb_metrics` sinks",
1015
"deprecated_since": "0.58.0",

0 commit comments

Comments
 (0)