From c2c5b14b8ed9ff624e9c47bc3544fcc7cf13135d Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Tue, 17 Dec 2024 00:15:54 +0100 Subject: [PATCH] WIP: magically write output of "namespaced" steps to namespace Signed-off-by: Hidde Beydals --- internal/directives/simple_engine_promote.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/directives/simple_engine_promote.go b/internal/directives/simple_engine_promote.go index d262e83b8..238d478c0 100644 --- a/internal/directives/simple_engine_promote.go +++ b/internal/directives/simple_engine_promote.go @@ -120,7 +120,21 @@ func (e *SimpleEngine) executeSteps( stepExecMeta.Status = result.Status stepExecMeta.Message = result.Message } - state[step.Alias] = result.Output + + // TODO(hidde): until we have a better way to handle the output of steps + // inflated from tasks, we need to apply a special treatment to the output + // to allow it to become available under the alias of the "task". + aliasNamespace := getAliasNamespace(step.Alias) + if aliasNamespace != "" && reg.Runner.Name() == (&outputComposer{}).Name() { + if state[aliasNamespace] == nil { + state[aliasNamespace] = make(State) + } + for k, v := range result.Output { + state[aliasNamespace].(State)[k] = v // nolint: forcetypeassert + } + } else { + state[step.Alias] = result.Output + } if stepExecMeta.Status == kargoapi.PromotionPhaseSucceeded { stepExecMeta.FinishedAt = ptr.To(metav1.Now())