Skip to content

Commit 04aa59a

Browse files
authored
Merge pull request #3 from fstnetwork/develop
Release v0.0.3
2 parents ca19922 + 64fb750 commit 04aa59a

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "istinit"
3-
version = "0.0.2"
3+
version = "0.0.3"
44
authors = ["FST Network <[email protected]>"]
55
edition = "2018"
66
autobins = false

src/bin/command.rs

+22-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub struct Command {
1111
#[structopt(long = "enable-process-subreaper", short = "s", env = "ENABLE_PROCESS_SUBREAPER")]
1212
enable_process_subreaper: bool,
1313

14-
#[structopt(long = "with-istio", env = "WITH_ISTIO")]
15-
with_istio: bool,
14+
#[structopt(long = "with-istio", env = "WITH_ISTIO", parse(from_str = parse_bool_str))]
15+
with_istio: Option<bool>,
1616

1717
#[structopt(
1818
long = "pilot-agent-endpoint",
@@ -21,8 +21,8 @@ pub struct Command {
2121
)]
2222
pilot_agent_endpoint: String,
2323

24-
#[structopt(long = "kill-istio", env = "KILL_ISTIO")]
25-
kill_istio: bool,
24+
#[structopt(long = "kill-istio", env = "KILL_ISTIO", parse(from_str = parse_bool_str))]
25+
kill_istio: Option<bool>,
2626

2727
command: String,
2828

@@ -49,12 +49,28 @@ impl Into<Config> for Command {
4949

5050
let process = config::Process { command, args };
5151

52-
let istio = if with_istio {
53-
Some(config::Istio { pilot_agent_endpoint, kill_istio })
52+
let istio = if let Some(true) = with_istio {
53+
Some(config::Istio { pilot_agent_endpoint, kill_istio: kill_istio.unwrap_or(false) })
5454
} else {
5555
None
5656
};
5757

5858
Config { enable_process_subreaper, process, istio }
5959
}
6060
}
61+
62+
fn parse_bool_str(s: &str) -> bool { !matches!(s, "" | "false") }
63+
64+
#[cfg(test)]
65+
mod tests {
66+
67+
#[test]
68+
fn test_parse_bool_str() {
69+
use super::parse_bool_str;
70+
71+
assert_eq!(parse_bool_str(""), false);
72+
assert_eq!(parse_bool_str("false"), false);
73+
assert_eq!(parse_bool_str("true"), true);
74+
assert_eq!(parse_bool_str("any"), true);
75+
}
76+
}

0 commit comments

Comments
 (0)