From d3079ae354f9c17ab46a3d8c0746d02773e55602 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 22 May 2025 17:26:56 +0300 Subject: [PATCH] update value processor context --- pkg/action/action.go | 7 ++++--- pkg/action/process.go | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 7f65579..8fc6015 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -251,13 +251,13 @@ func (a *Action) SetInput(input *Input) (err error) { def := a.ActionDef() // Process arguments. - err = a.processInputParams(def.Arguments, input.Args(), input.ArgsChanged()) + err = a.processInputParams(def.Arguments, input.Args(), input.ArgsChanged(), input) if err != nil { return err } // Process options. - err = a.processInputParams(def.Options, input.Opts(), input.OptsChanged()) + err = a.processInputParams(def.Options, input.Opts(), input.OptsChanged(), input) if err != nil { return err } @@ -273,7 +273,7 @@ func (a *Action) SetInput(input *Input) (err error) { return a.EnsureLoaded() } -func (a *Action) processInputParams(def ParametersList, inp InputParams, changed InputParams) error { +func (a *Action) processInputParams(def ParametersList, inp InputParams, changed InputParams, input *Input) error { var err error for _, p := range def { _, isChanged := changed[p.Name] @@ -283,6 +283,7 @@ func (a *Action) processInputParams(def ParametersList, inp InputParams, changed res, err = handler(res, ValueProcessorContext{ ValOrig: inp[p.Name], IsChanged: isChanged, + Input: input, DefParam: p, Action: a, }) diff --git a/pkg/action/process.go b/pkg/action/process.go index b730bd7..1b48959 100644 --- a/pkg/action/process.go +++ b/pkg/action/process.go @@ -20,6 +20,7 @@ type ValueProcessor interface { type ValueProcessorContext struct { ValOrig any // ValOrig is the value before processing. IsChanged bool // IsChanged indicates if the value was input by user. + Input *Input // Input represents the associated action input in the current context. DefParam *DefParameter // DefParam is the definition of the currently processed parameter. Action *Action // Action is the related action definition. }