NAME

Config::HAProxy::Node::Section - HAProxy configuration section

DESCRIPTION

Objects of this class represent a section in the HAProxy configuration file. A section is a statement that can contain sub-statements. The following statements form sections: global, defaults, frontend, and backend.

ATTRIBUTES

is_section

Always true.

METHODS

kw

Returns the configuration keyword.

argv

Returns the list of arguments to the configuration keyword.

arg

$s = $node->arg($n)

Returns the $nth argument.

orig

Returns original line as it appeared in the configuration file.

locus

Returns the location of this statement in the configuration file (the Text::Locus object).

append_node

$section->append_node(@nodes);

Takes a list of objects of Config::HAProxy::Node derived classes as arguments. Adds these objects after the last node in the subtree in this section.

append_node_nonempty

$section->append_node_nonempty(@nodes);

Same as append_node, but adds new nodes after the last non-empty node in the subtree.

insert_node

$section->insert_node($idx, @nodes);

Inserts @nodes after subnode in position $idx (0-based).

delete_node

$section->delete_node($i);

Deletes $ith subnode from the $section.

tree

@nodes = $section->tree;

Returns subnodes as a list of Config::HAProxy::Node derived objects.

$node = $section->tree($i);

Returns $ith subnode from the $section.

ends_in_empty

$bool = $section->ends_in_empty

Returns true if the last node in the list of sub-nodes in $section is an empty node.

select

@nodes = $section->select(%cond);

Returns nodes from $section that match conditions in %cond. Valid conditions are:

name => $s

Node matches if its keyword (kw) equals $s.

arg => { n => $n, v => $s }

Node mathches if its $nth argument equals $s.

section => $bool

Node matches if it is (or is not, if $bool is false) a section.

statement => $bool

Node matches if it is (not) a simple statement.

comment => $bool

Node matches if it is (not) a comment.

Multiple conditions are checked in the order of their appearance in the argument list and are joined by the short-circuit logical and.

For example, to return all frontend statements:

@fe = $section->select(name => 'frontend');

To return the frontend named in:

($fe) = $section->select( name => 'frontend',
                          arg => { n => 0, v => 'in' } );

SEE ALSO

Config::HAProxy::Node, Config::HAProxy, Text::Locus.