chore: fixes after review

This commit is contained in:
Stéphane Lesimple 2020-12-17 13:39:23 +00:00
parent 4a45df4432
commit 3c5dddc06e
No known key found for this signature in database
GPG key ID: 4B4A3289E9D35658
2 changed files with 13 additions and 28 deletions

View file

@ -17,13 +17,7 @@ sub dumpdoc {
elsif (defined $h{param} && defined $h{default} && defined $h{desc} && defined $h{type}) {
die "attempting to dump data but section=$section" if !$section;
push @{$sections{$section}}, $h{param};
push @out, ".. _bastion_conf_$h{param}:\n";
push @out, "\n";
push @out, "$h{param}\n";
my $len = length($h{param});
push @out, "*" x $len . "\n\n";
push @out, ":Type: ``$h{type}``\n\n";
push @out, ":Default: ``$h{default}``\n\n";
push @out, ".. _bastion_conf_$h{param}:\n\n", "$h{param}\n", "*" x length($h{param}), "\n\n", ":Type: ``$h{type}``\n\n", ":Default: ``$h{default}``\n\n";
push @out, ":Example: ``$h{example}``\n\n" if $h{example};
push @out, "$h{desc}\n\n";
}
@ -35,7 +29,7 @@ sub dumpdoc {
}
my $state = '';
while (<>) {
while (<STDIN>) {
print STDERR $_;
next if /^\s*$/;
if (m{^# ([a-zA-Z0-9_]+) \((.+)\)}) {
@ -67,8 +61,7 @@ while (<>) {
$section = $1;
$state = 'section';
push @orderedsections, $section;
push @out, "$1\n";
push @out, "-" x (length($1)) . "\n\n";
push @out, $section, "\n", "-" x (length($section)), "\n\n";
}
elsif (m{^# >> (.+)$} and $state eq 'section' and $section) {
$sectiondesc{$section} = $1;
@ -79,7 +72,7 @@ while (<>) {
}
dumpdoc();
print <<'EOF'
print <<'EOF';
======================
bastion.conf reference
======================
@ -95,23 +88,15 @@ Option List
===========
EOF
;
foreach my $section (@orderedsections) {
die "no description for section $section" if !$sectiondesc{$section};
print "\n$section\n";
print "-" x (length($section)) . "\n\n";
print $sectiondesc{$section} . "\n\n";
foreach (@{$sections{$section}}) {
print "- :ref:`bastion_conf_$_`\n";
}
print "\n", $section, "\n", "-" x length($section), "\n\n", $sectiondesc{$section}, "\n\n";
print "- :ref:`bastion_conf_$_`\n" for @{$sections{$section}};
}
print <<'EOF'
print <<'EOF', join('', @out);
Option Reference
================
EOF
;
print join("", @out);

View file

@ -48,12 +48,12 @@ OVH::Bastion::load_configuration(
# all options below are bool, we'll test for their normalization
enableSyslog => 1,
enableGlobalAccessLog => JSON->new->allow_nonref->decode("true"),
enableGlobalAccessLog => JSON::true,
enableAccountAccessLog => "yes",
enableGlobalSqlLog => 0,
enableAccountSqlLog => JSON->new->allow_nonref->decode("false"),
enableAccountSqlLog => JSON::false,
displayLastLogin => "",
debug => JSON->new->allow_nonref->decode("null"),
debug => JSON::null,
passwordAllowed => "no",
telnetAllowed => "false",
}
@ -117,7 +117,7 @@ is(
OVH::Bastion::plugin_config(
plugin => "help",
key => "disabled",
mock_data => {disabled => JSON->new->allow_nonref->decode("true")}
mock_data => {disabled => JSON::true}
)->value ? 1 : 0,
1,
"is_plugin_disabled(disabled=true)"
@ -126,7 +126,7 @@ is(
OVH::Bastion::plugin_config(
plugin => "help",
key => "disabled",
mock_data => {disabled => JSON->new->allow_nonref->decode("false")}
mock_data => {disabled => JSON::false}
)->value ? 1 : 0,
0,
"is_plugin_disabled(disabled=false)"
@ -135,7 +135,7 @@ is(
OVH::Bastion::plugin_config(
plugin => "help",
key => "disabled",
mock_data => {disabled => JSON->new->allow_nonref->decode("null")}
mock_data => {disabled => JSON::null}
)->value ? 1 : 0,
0,
"is_plugin_disabled(disabled=null)"