Skip to content

Commit

Permalink
Rename taskConfig regex
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario committed Jan 29, 2024
1 parent 28aaa05 commit d013b31
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions flyteplugins/go/tasks/pluginmachinery/tasklog/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import (
)

func MustCreateRegex(varName string) *regexp.Regexp {
// TODO: Is this regex correct? Why are we allowing $? Shouldn't it be {{\s*\.%s\s*}}?
// Also, case insensitive matching is enabled. Is this correct?
return regexp.MustCompile(fmt.Sprintf(`(?i){{\s*[\.$]%s\s*}}`, varName))
}

var dynamicLogRegex = regexp.MustCompile(`(?i){{\s*.taskConfig[\.$]([a-zA-Z_]+)\s*}}`)
var taskConfigVarRegex = regexp.MustCompile(`(?i){{\s*.taskConfig[\.$]([a-zA-Z_]+)\s*}}`)

func MustCreateDynamicLogRegex(varName string) *regexp.Regexp {
return regexp.MustCompile(fmt.Sprintf(`(?i){{\s*.taskConfig[\.$]%s\s*}}`, varName))
Expand Down Expand Up @@ -211,7 +209,7 @@ func (p TemplateLogPlugin) GetTaskLogs(input Input) (Output, error) {
for _, dynamicLogLinkType := range getDynamicLogLinkTypes(input.TaskTemplate) {
for _, dynamicTemplateURI := range p.DynamicTemplateURIs {
if p.Name == dynamicLogLinkType {
for _, match := range dynamicLogRegex.FindAllStringSubmatch(dynamicTemplateURI, -1) {
for _, match := range taskConfigVarRegex.FindAllStringSubmatch(dynamicTemplateURI, -1) {
if len(match) > 1 {
if value, found := input.TaskTemplate.GetConfig()[match[1]]; found {
templateVars = append(templateVars, TemplateVar{MustCreateDynamicLogRegex(match[1]), value})
Expand Down

0 comments on commit d013b31

Please sign in to comment.