mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-15 03:29:55 +00:00
docs: Document environment variables for config options
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,10 @@ # This maps to the `base_url` field of the `[global.antispam.draupnir]` section
|
||||
# Alternatively, you can pass a (quoted) struct to define an entire section
|
||||
# This maps to the [global.well_known] section
|
||||
CONTINUWUITY_WELL_KNOWN="{ client=https://example.com,server=example.com:443 }"
|
||||
|
||||
# Options that take a list are written as a (quoted) array
|
||||
CONTINUWUITY_TRUSTED_SERVERS='["matrix.org"]'
|
||||
CONTINUWUITY_PORT='[8008, 8448]'
|
||||
```
|
||||
|
||||
### Alternative prefixes
|
||||
|
||||
@@ -79,7 +79,7 @@ # Continuwuity for Kubernetes
|
||||
value: "https://matrix.example.com"
|
||||
- name: CONTINUWUITY_ALLOW_REGISTRATION
|
||||
value: "false"
|
||||
- name: RUST_LOG
|
||||
- name: CONTINUWUITY_LOG
|
||||
value: info
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
|
||||
@@ -89,6 +89,8 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result<To
|
||||
}
|
||||
}
|
||||
|
||||
let env_prefix = env_prefix(section);
|
||||
|
||||
let mut summary: Vec<TokenStream2> = Vec::new();
|
||||
let mut nested_displays: Vec<TokenStream2> = Vec::new();
|
||||
|
||||
@@ -144,6 +146,12 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result<To
|
||||
file.write_fmt(format_args!("\n{doc}"))
|
||||
.expect("written to config file");
|
||||
|
||||
file.write_fmt(format_args!(
|
||||
"# env: {env_prefix}{}\n",
|
||||
ident.to_string().to_uppercase()
|
||||
))
|
||||
.expect("written to config file");
|
||||
|
||||
file.write_fmt(format_args!("#{ident} ={default}\n"))
|
||||
.expect("written to config file");
|
||||
}
|
||||
@@ -213,6 +221,19 @@ fn fmt(&self, out: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
Ok(display)
|
||||
}
|
||||
|
||||
fn env_prefix(section: &str) -> String {
|
||||
let nested = section
|
||||
.strip_prefix("global")
|
||||
.unwrap_or(section)
|
||||
.trim_start_matches('.');
|
||||
|
||||
if nested.is_empty() {
|
||||
"CONTINUWUITY_".to_owned()
|
||||
} else {
|
||||
format!("CONTINUWUITY_{}__", nested.replace('.', "__").to_uppercase())
|
||||
}
|
||||
}
|
||||
|
||||
fn get_default(field: &Field) -> Option<String> {
|
||||
for attr in &field.attrs {
|
||||
let Meta::List(MetaList { path, tokens, .. }) = &attr.meta else {
|
||||
|
||||
Reference in New Issue
Block a user