]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: vars: Enable optional conditions to set-var converter and actions
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 16 Dec 2021 16:14:39 +0000 (17:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Dec 2021 16:31:57 +0000 (17:31 +0100)
commit0b9e1900282b33001c87c8d41ac01ddda5376fa1
treef9abaae042ee8019b9f75c66100e5636e9fb5070
parentbb6bc95b1eb22b7239d4d75016fda8210bd5d492
MEDIUM: vars: Enable optional conditions to set-var converter and actions

This patch adds the possibility to add a set of conditions to a set-var
call, be it a converter or an action (http-request or http-response
action for instance). The conditions must all be true for the given
set-var call for the variable to actually be set. If any of the
conditions is false, the variable is left untouched.
The managed conditions are the following : "ifexists", "ifnotexists",
"ifempty", "ifnotempty", "ifset", "ifnotset", "ifgt", "iflt".  It is
possible to combine multiple conditions in a single set-var call since
some of them apply to the variable itself, and some others to the input.

This patch does not change the fact that variables of scope proc are
still created during configuration parsing, regardless of the conditions
that might be added to the set-var calls in which they are mentioned.
For instance, such a line :
    http-request set-var(proc.foo,ifexists) int(5)
would not prevent the creation of the variable during init, and when
actually reaching this line during runtime, the proc.foo variable would
already exist. This is specific to the proc scope.

These new conditions mean that a set-var could "fail" for other reasons
than memory allocation failures but without clearing the contents of the
variable.
src/vars.c