Skip to content

Commit 0af724c

Browse files
do not require empty string for optional field
1 parent 731b566 commit 0af724c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

wicket/src/cli/rack_setup/config_template.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ allow = "any"
5757

5858
# TODO: docs on network config
5959
[rack_network_config]
60-
rack_subnet_address = ""
6160
infra_ip_first = ""
6261
infra_ip_last = ""
6362

wicket/src/cli/rack_setup/config_toml.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,15 @@ fn populate_network_table(
245245
};
246246

247247
if let Some(rack_subnet_address) = config.rack_subnet_address {
248-
*table
249-
.get_mut("rack_subnet_address")
250-
.unwrap()
251-
.as_value_mut()
252-
.unwrap() =
253-
Value::String(Formatted::new(rack_subnet_address.to_string()));
248+
let value = Value::String(Formatted::new(rack_subnet_address.to_string()));
249+
match table.entry("rack_subnet_address") {
250+
toml_edit::Entry::Occupied(mut entry) => {
251+
entry.insert( Item::Value(value));
252+
},
253+
toml_edit::Entry::Vacant(entry) => {
254+
entry.insert(Item::Value(value));
255+
},
256+
}
254257
}
255258

256259
for (property, value) in [

wicket/tests/output/example_non_empty.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ allow = "any"
6969

7070
# TODO: docs on network config
7171
[rack_network_config]
72-
rack_subnet_address = "fd00:1122:3344:100::"
7372
infra_ip_first = "172.30.0.1"
7473
infra_ip_last = "172.30.0.10"
74+
rack_subnet_address = "fd00:1122:3344:100::"
7575

7676
[rack_network_config.switch0.port0]
7777
routes = [{ nexthop = "172.30.0.10", destination = "0.0.0.0/0", vlan_id = 1 }]

0 commit comments

Comments
 (0)