mirror of
https://github.com/ovh/the-bastion.git
synced 2025-09-10 06:54:17 +08:00
chore: fixes after review
This commit is contained in:
parent
4a45df4432
commit
3c5dddc06e
2 changed files with 13 additions and 28 deletions
|
@ -17,13 +17,7 @@ sub dumpdoc {
|
||||||
elsif (defined $h{param} && defined $h{default} && defined $h{desc} && defined $h{type}) {
|
elsif (defined $h{param} && defined $h{default} && defined $h{desc} && defined $h{type}) {
|
||||||
die "attempting to dump data but section=$section" if !$section;
|
die "attempting to dump data but section=$section" if !$section;
|
||||||
push @{$sections{$section}}, $h{param};
|
push @{$sections{$section}}, $h{param};
|
||||||
push @out, ".. _bastion_conf_$h{param}:\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, "\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, ":Example: ``$h{example}``\n\n" if $h{example};
|
push @out, ":Example: ``$h{example}``\n\n" if $h{example};
|
||||||
push @out, "$h{desc}\n\n";
|
push @out, "$h{desc}\n\n";
|
||||||
}
|
}
|
||||||
|
@ -35,7 +29,7 @@ sub dumpdoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $state = '';
|
my $state = '';
|
||||||
while (<>) {
|
while (<STDIN>) {
|
||||||
print STDERR $_;
|
print STDERR $_;
|
||||||
next if /^\s*$/;
|
next if /^\s*$/;
|
||||||
if (m{^# ([a-zA-Z0-9_]+) \((.+)\)}) {
|
if (m{^# ([a-zA-Z0-9_]+) \((.+)\)}) {
|
||||||
|
@ -67,8 +61,7 @@ while (<>) {
|
||||||
$section = $1;
|
$section = $1;
|
||||||
$state = 'section';
|
$state = 'section';
|
||||||
push @orderedsections, $section;
|
push @orderedsections, $section;
|
||||||
push @out, "$1\n";
|
push @out, $section, "\n", "-" x (length($section)), "\n\n";
|
||||||
push @out, "-" x (length($1)) . "\n\n";
|
|
||||||
}
|
}
|
||||||
elsif (m{^# >> (.+)$} and $state eq 'section' and $section) {
|
elsif (m{^# >> (.+)$} and $state eq 'section' and $section) {
|
||||||
$sectiondesc{$section} = $1;
|
$sectiondesc{$section} = $1;
|
||||||
|
@ -79,7 +72,7 @@ while (<>) {
|
||||||
}
|
}
|
||||||
dumpdoc();
|
dumpdoc();
|
||||||
|
|
||||||
print <<'EOF'
|
print <<'EOF';
|
||||||
======================
|
======================
|
||||||
bastion.conf reference
|
bastion.conf reference
|
||||||
======================
|
======================
|
||||||
|
@ -95,23 +88,15 @@ Option List
|
||||||
===========
|
===========
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
;
|
|
||||||
|
|
||||||
foreach my $section (@orderedsections) {
|
foreach my $section (@orderedsections) {
|
||||||
die "no description for section $section" if !$sectiondesc{$section};
|
die "no description for section $section" if !$sectiondesc{$section};
|
||||||
print "\n$section\n";
|
print "\n", $section, "\n", "-" x length($section), "\n\n", $sectiondesc{$section}, "\n\n";
|
||||||
print "-" x (length($section)) . "\n\n";
|
print "- :ref:`bastion_conf_$_`\n" for @{$sections{$section}};
|
||||||
print $sectiondesc{$section} . "\n\n";
|
|
||||||
foreach (@{$sections{$section}}) {
|
|
||||||
print "- :ref:`bastion_conf_$_`\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
print <<'EOF'
|
print <<'EOF', join('', @out);
|
||||||
|
|
||||||
Option Reference
|
Option Reference
|
||||||
================
|
================
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
;
|
|
||||||
|
|
||||||
print join("", @out);
|
|
||||||
|
|
|
@ -48,12 +48,12 @@ OVH::Bastion::load_configuration(
|
||||||
|
|
||||||
# all options below are bool, we'll test for their normalization
|
# all options below are bool, we'll test for their normalization
|
||||||
enableSyslog => 1,
|
enableSyslog => 1,
|
||||||
enableGlobalAccessLog => JSON->new->allow_nonref->decode("true"),
|
enableGlobalAccessLog => JSON::true,
|
||||||
enableAccountAccessLog => "yes",
|
enableAccountAccessLog => "yes",
|
||||||
enableGlobalSqlLog => 0,
|
enableGlobalSqlLog => 0,
|
||||||
enableAccountSqlLog => JSON->new->allow_nonref->decode("false"),
|
enableAccountSqlLog => JSON::false,
|
||||||
displayLastLogin => "",
|
displayLastLogin => "",
|
||||||
debug => JSON->new->allow_nonref->decode("null"),
|
debug => JSON::null,
|
||||||
passwordAllowed => "no",
|
passwordAllowed => "no",
|
||||||
telnetAllowed => "false",
|
telnetAllowed => "false",
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ is(
|
||||||
OVH::Bastion::plugin_config(
|
OVH::Bastion::plugin_config(
|
||||||
plugin => "help",
|
plugin => "help",
|
||||||
key => "disabled",
|
key => "disabled",
|
||||||
mock_data => {disabled => JSON->new->allow_nonref->decode("true")}
|
mock_data => {disabled => JSON::true}
|
||||||
)->value ? 1 : 0,
|
)->value ? 1 : 0,
|
||||||
1,
|
1,
|
||||||
"is_plugin_disabled(disabled=true)"
|
"is_plugin_disabled(disabled=true)"
|
||||||
|
@ -126,7 +126,7 @@ is(
|
||||||
OVH::Bastion::plugin_config(
|
OVH::Bastion::plugin_config(
|
||||||
plugin => "help",
|
plugin => "help",
|
||||||
key => "disabled",
|
key => "disabled",
|
||||||
mock_data => {disabled => JSON->new->allow_nonref->decode("false")}
|
mock_data => {disabled => JSON::false}
|
||||||
)->value ? 1 : 0,
|
)->value ? 1 : 0,
|
||||||
0,
|
0,
|
||||||
"is_plugin_disabled(disabled=false)"
|
"is_plugin_disabled(disabled=false)"
|
||||||
|
@ -135,7 +135,7 @@ is(
|
||||||
OVH::Bastion::plugin_config(
|
OVH::Bastion::plugin_config(
|
||||||
plugin => "help",
|
plugin => "help",
|
||||||
key => "disabled",
|
key => "disabled",
|
||||||
mock_data => {disabled => JSON->new->allow_nonref->decode("null")}
|
mock_data => {disabled => JSON::null}
|
||||||
)->value ? 1 : 0,
|
)->value ? 1 : 0,
|
||||||
0,
|
0,
|
||||||
"is_plugin_disabled(disabled=null)"
|
"is_plugin_disabled(disabled=null)"
|
||||||
|
|
Loading…
Add table
Reference in a new issue