Description
Is your refactoring request related to a problem? Please describe.
In #2716, I'm adding two new configuration values, one feature flag and one general configuration relating to the gated feature. I want the feature flag to remain undocumented so customers do not stumble across the feature until it is ready, as well as giving us the opportunity to change the scope of the feature flag (which may want to affect all clouds at once, and not specifically Cumulocity like it does currently), and would therefore lead to the flag requiring renaming. The other configuration value is not particularly likely to change, however if used at without the feature flag enabled, it won't have any effect.
Currently define_tedge_config!
somewhat accidentally supports hidden configuration values via the #[doku(skip)]
attribute, which just gets passed through to doku to extract documentation metadata from the generated config structs. This hides the configurations in tedge config list --doc
, but doesn't do anything to hide them in tedge config list
, where it would be useful to hide the value if it is set to the default value (or ideally if the value has been explicitly configured, even if that value matches the default).
Describe the solution you'd like
#[tedge_config(hidden)]
could be added to behave like #[doku(skip)]
but with support for tedge config list
too. The operation tedge config list
performs when reading a value could return a three valued enum which represents the possible states for a configuration of Present
(a normal configured value)/Hidden
(an undocumented configuration that isn't configured)/Absent
(a configuration that hasn't been set and doesn't have a default value). In this, we should also make sure to disallow the use of #[doku(skip)]
, like we do for #[serde(rename)]
to avoid confusion.
The new attribute could also take a value, e.g. #[tedge_config(hidden = "The bridge in mapper feature isn't yet stable, so breaking changes may occur")]
could be used to print a warning to a user if they configure the hidden value.
Describe alternatives you've considered
Currently I'm using #[doku(skip)]
and an additional method to decide if the configuration value is "printable" (for tedge config list
), although this additional method (ReadableKey::is_printable_value
) is not easy to spot if you're not looking for it, and duplicates the default values. It also means that the code for tedge config list
could easily be accidentally modified to print the hidden configurations.