fix upstream does not contain a target when init
This commit is contained in:
@@ -54,13 +54,13 @@ impl NginxConfigProvider for UpstreamInfo {
|
||||
.iter()
|
||||
.map(|target| target.to_nginx_config(Some(indent.unwrap_or(0) + INDENT_SIZE)))
|
||||
.collect();
|
||||
|
||||
format!(
|
||||
"upstream {} {{\n{}\n}}",
|
||||
self.name,
|
||||
targets_config.join("\n".indent(indent.unwrap_or(0) + INDENT_SIZE).as_str())
|
||||
)
|
||||
.indent(indent.unwrap_or(0))
|
||||
let targets_config_str = if targets_config.is_empty() {
|
||||
"server 127.0.0.1:65535 down; # placeholder target".to_string()
|
||||
} else {
|
||||
targets_config.join("\n")
|
||||
}
|
||||
.indent(indent.unwrap_or(0) + INDENT_SIZE);
|
||||
format!("upstream {} {{\n{}\n}}", self.name, targets_config_str).indent(indent.unwrap_or(0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user