From ff9f55bcdfc490132fde619cc652f2c676eb6ea7 Mon Sep 17 00:00:00 2001 From: Edwin Yu <92917168+edwinyyyu@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:54:42 -0700 Subject: [PATCH] Make rendering template in agent client temporary (#395) Signed-off-by: Edwin Yu --- go/tasks/plugins/webapi/agent/plugin.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/go/tasks/plugins/webapi/agent/plugin.go b/go/tasks/plugins/webapi/agent/plugin.go index 128753b74..d97d0c186 100644 --- a/go/tasks/plugins/webapi/agent/plugin.go +++ b/go/tasks/plugins/webapi/agent/plugin.go @@ -68,6 +68,7 @@ func (p Plugin) Create(ctx context.Context, taskCtx webapi.TaskExecutionContextR return nil, nil, err } + var argTemplate []string if taskTemplate.GetContainer() != nil { templateParameters := template.Parameters{ TaskExecMetadata: taskCtx.TaskExecutionMetadata(), @@ -75,6 +76,7 @@ func (p Plugin) Create(ctx context.Context, taskCtx webapi.TaskExecutionContextR OutputPath: taskCtx.OutputWriter(), Task: taskCtx.TaskReader(), } + argTemplate = taskTemplate.GetContainer().Args modifiedArgs, err := template.Render(ctx, taskTemplate.GetContainer().Args, templateParameters) if err != nil { return nil, nil, err @@ -101,6 +103,11 @@ func (p Plugin) Create(ctx context.Context, taskCtx webapi.TaskExecutionContextR return nil, nil, err } + // Restore unrendered template for subsequent renders. + if taskTemplate.GetContainer() != nil { + taskTemplate.GetContainer().Args = argTemplate + } + return &ResourceMetaWrapper{ OutputPrefix: outputPrefix, AgentResourceMeta: res.GetResourceMeta(),