read_recap: Scrub recap values without var declarations
This commit is contained in:
parent
70e2b51377
commit
f2c9ef6641
2 changed files with 7 additions and 6 deletions
|
@ -1635,8 +1635,14 @@ sub read_recap {
|
|||
%opt = %saved;
|
||||
$recap{$_} //= {} for keys(%config);
|
||||
for my $h (keys(%recap)) {
|
||||
next if !exists($config{$h});
|
||||
if (!exists($config{$h})) {
|
||||
delete($recap{$h});
|
||||
next;
|
||||
}
|
||||
my $vars = $protocols{opt('protocol', $h)}{variables};
|
||||
for my $v (keys(%{$recap{$h}})) {
|
||||
delete($recap{$h}{$v}) if !$vars->{$v} || !$vars->{$v}{recap};
|
||||
}
|
||||
# Only status variables are copied from `%recap` into `%config` because the recap should
|
||||
# not change the configuration. See the documenting comments for `%recap`.
|
||||
# TODO: Hard-coding this list impairs readability and maintainability. In particular,
|
||||
|
|
|
@ -50,13 +50,11 @@ my @test_cases = (
|
|||
desc => "unknown host",
|
||||
cachefile_lines => ["var_a=yes host_c"],
|
||||
want => {},
|
||||
want_TODO => "longstanding minor issue, doesn't affect functionality",
|
||||
},
|
||||
{
|
||||
desc => "unknown var",
|
||||
cachefile_lines => ["var_b=123 host_a"],
|
||||
want => {host_a => {host => 'host_a'}},
|
||||
want_TODO => "longstanding minor issue, doesn't affect functionality",
|
||||
},
|
||||
{
|
||||
desc => "invalid value",
|
||||
|
@ -142,21 +140,18 @@ my @test_cases = (
|
|||
desc => "non-recap vars are not loaded to %recap or copied to %config",
|
||||
cachefile_lines => ["mtime=1234567890 host_b"],
|
||||
want => {host_b => {host => 'host_b'}},
|
||||
want_TODO => "longstanding minor issue, doesn't affect functionality",
|
||||
},
|
||||
{
|
||||
desc => "non-recap vars are scrubbed from %recap",
|
||||
cachefile_lines => ["mtime=1234567890 host_b"],
|
||||
recap => {host_b => {host => 'host_b', mtime => 1234567891}},
|
||||
want => {host_b => {host => 'host_b'}},
|
||||
want_TODO => "longstanding minor issue, doesn't affect functionality",
|
||||
},
|
||||
{
|
||||
desc => "unknown hosts are scrubbed from %recap",
|
||||
cachefile_lines => ["host_a", "host_c"],
|
||||
recap => {host_a => {host => 'host_a'}, host_c => {host => 'host_c'}},
|
||||
want => {host_a => {host => 'host_a'}},
|
||||
want_TODO => "longstanding minor issue, doesn't affect functionality",
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue