Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Make rendering template in agent client temporary (#395)
Browse files Browse the repository at this point in the history
Signed-off-by: Edwin Yu <[email protected]>
  • Loading branch information
edwinyyyu authored Sep 14, 2023
1 parent 8eddca3 commit ff9f55b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/tasks/plugins/webapi/agent/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ 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(),
Inputs: taskCtx.InputReader(),
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
Expand All @@ -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(),
Expand Down

0 comments on commit ff9f55b

Please sign in to comment.