From 1e40a2aa9dfbf7e2bec35eb33578f76b928106e0 Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 18 May 2026 11:10:49 +0200 Subject: [PATCH] Plugins: add bool2int conversion (#29995) --- plugin/convert.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugin/convert.go b/plugin/convert.go index 59e6cd939..e03f2c47a 100644 --- a/plugin/convert.go +++ b/plugin/convert.go @@ -71,3 +71,23 @@ func (o *convertPlugin) IntSetter(param string) (func(int64) error, error) { return nil, fmt.Errorf("convert: invalid conversion: %s", o.Convert) } } + +var _ BoolSetter = (*convertPlugin)(nil) + +func (o *convertPlugin) BoolSetter(param string) (func(bool) error, error) { + switch o.Convert { + case "bool2int": + set, err := o.Set.IntSetter(o.ctx, param) + + return func(val bool) error { + var i int64 + if val { + i = 1 + } + return set(i) + }, err + + default: + return nil, fmt.Errorf("convert: invalid conversion: %s", o.Convert) + } +}