]> git.kaiwu.me - haproxy.git/commit
MEDIUM: vars: Add the set-vars-from-map action
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 1 Oct 2026 12:33:27 +0000 (14:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 1 Oct 2026 12:45:10 +0000 (14:45 +0200)
commitd900a230e8f95acf7986a50859e3ff08d1d24b93
treefa454273b5720b4e41665c199f9b93bb64ada147
parent6b2aad631c0e0f079431a7b455d8336488f63023
MEDIUM: vars: Add the set-vars-from-map action

Add a new action, set-vars-from-map(<scope>,<map-file>[,<type>]), that
loads a two-column (key/value) map file and sets one variable per entry,
named "<scope>.<key>", to the entry's value. The scope is one of sess,
txn, req, res or check and the variable name is relative to it.
The new "tune.vars.from-map.max" global option defines the maximum
number of entries taken into account in each map. It default to 100.

Values are read as strings and converted according to the optional
<type>, which may be "str" (default), "int" or "bool". Integer
conversion is strict, so an entry with trailing garbage is rejected
rather than silently truncated, and booleans accept 0/1 as well as
true/false in any case. An entry that cannot be parsed is skipped
without aborting the remaining entries.

The file is loaded as a pattern reference flagged PAT_REF_SMP, or reused
if it was already loaded, in which case it must also have been loaded as
a two-column file. The action is registered for all rule sets that
already support set-var.

This was GH issue #1619.
doc/configuration.txt
include/haproxy/pattern.h
src/vars.c