summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-26 09:20:32 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-26 09:33:43 +0300
commitf12defd06dfab84dd5a6a1d6f9839d6bb3af2c62 (patch)
tree7f7b3c3f3a2fe45161e2855c9a9ce73a67dfc612
parent585a5a925342c357d46fbad273bfafc03bc33dcd (diff)
downloadconfig-haproxy-f12defd06dfab84dd5a6a1d6f9839d6bb3af2c62.tar.gz
config-haproxy-f12defd06dfab84dd5a6a1d6f9839d6bb3af2c62.tar.bz2
Config::HAProxy version 1.03v1.03
-rw-r--r--Changes6
-rw-r--r--lib/Config/HAProxy.pm18
-rw-r--r--t/Test/HAProxy.pm1
3 files changed, 16 insertions, 9 deletions
diff --git a/Changes b/Changes
index 2fe0426..5bb1939 100644
--- a/Changes
+++ b/Changes
@@ -1,9 +1,15 @@
Revision history for Perl extension Config::HAProxy.
+1.03 Sun May 26 09:12:10 2019
+ - implement configuration syntax check
+
+1.02 Mon Jul 16 07:38:31 2018
+ - remove the leftover use of autodie
+
1.01 Thu Jul 12 09:04:28 2018
- set minimal required Perl version
- drop dependency on autodie
1.00 Sun Jul 8 19:57:57 2018
- original revision
diff --git a/lib/Config/HAProxy.pm b/lib/Config/HAProxy.pm
index ff4fa8a..794a80f 100644
--- a/lib/Config/HAProxy.pm
+++ b/lib/Config/HAProxy.pm
@@ -7,25 +7,25 @@ use Config::HAProxy::Node::Root;
use Config::HAProxy::Node::Section;
use Config::HAProxy::Node::Statement;
use Config::HAProxy::Node::Comment;
use Config::HAProxy::Node::Empty;
use Text::ParseWords;
use File::Basename;
use File::Temp qw(tempfile);
use File::stat;
use File::Spec;
use IPC::Cmd;
use Carp;
-our $VERSION = '1.01';
+our $VERSION = '1.03';
my %sections = (
global => 1,
defaults => 1,
frontend => 1,
backend => 1,
);
sub new {
my $class = shift;
my $filename = shift // '/etc/haproxy/haproxy.cfg';
my $self = bless { _filename => $filename,
@@ -420,64 +420,66 @@ Removes the tail node from the tree and returns it.
Returns the top of the tree.
=head2 tos
$node = $cfg->tos;
Returns the last node in the tree.
=head1 SAVING
=head2 lint
- $cfg->lint(%ARGS);
+ $cfg->lint(%hash);
-Configures syntax checking program to be run before saving. Takes a
-hash as argument. Allowed keys are:
+Configures configuration syntax check. The check will be run by the B<save>
+method prior to writing to the configuration file. Takes a hash as argument.
+Allowed keys are:
=over 4
=item B<enable =E<gt> I<BOOL>>
If I<BOOL> is 0, disables syntax check. Default is 1.
=item B<command =E<gt> I<CMD>>
-Configures the command to use for syntax check. The command will be run as
+Defines the shell command to use for syntax check. The command will be run
+as
CMD FILE
where I<FILE> is the name of the HAProxy configuration file to check.
Default command is B<haproxy -c -f>.
=item B<path =E<gt> I<PATH>>
-Sets the search path for the check program. I<PATH> is a colon-delimited
+Sets the search path for the syntax checker. I<PATH> is a colon-delimited
list of directories. Unless the first word of B<command> is an absolute
file name, it will be looked for in these directories. The first match
will be used. Default is system B<$PATH>.
=back
Returns the command name.
=head2 save
$cfg->save(%hash);
Saves the parse tree in the configuration file. Syntax check will be run
prior to saving (unless previously disabled). If syntax errors are discovered,
-the method will B<croak> with the appropriate diagnostics, beginning with
-words C<Syntax check failed:>.
+the method will B<croak> with a diagnostic message starting with words
+C<Syntax check failed:>.
If I<%hash> contains a non-zero B<dry_run> value, B<save> will only run syntax
check, without actually saving the file. If B<$cfg-E<gt>lint(enable =E<gt> 0)>
was called previously, this is a no-op.
Other keys in I<%hash> are the same as in B<write>, described below.
=head2 write
$cfg->write($file, %hash);
Writes configuration to the named file or file handle. First argument
diff --git a/t/Test/HAProxy.pm b/t/Test/HAProxy.pm
index b5b8a19..ca7d8ce 100644
--- a/t/Test/HAProxy.pm
+++ b/t/Test/HAProxy.pm
@@ -1,19 +1,18 @@
package Test::HAProxy;
use strict;
use warnings;
use parent 'Config::HAProxy';
use File::Basename;
use File::Temp;
-use autodie;
sub new {
my $class = shift;
my $file = new File::Temp;
while (<main::DATA>) {
print $file $_;
}
close $file;
$class->SUPER::new($file->filename)->parse;
}

Return to:

Send suggestions and report system problems to the System administrator.