Skip to content

Commit

Permalink
🔊 Add value changed debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 11, 2022
1 parent 131ae0d commit 87ec052
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/template/line_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ func init() {

func LineComment(conf config.Config, node *yaml.Node) error {
if node.LineComment != "" && strings.HasPrefix(node.LineComment, conf.Prefix) {
tmplSrc := strings.TrimSpace(node.LineComment[len(conf.Prefix):])
tmpl, err := template.New("").
Funcs(FuncMap).
Delims(conf.LeftDelim, conf.RightDelim).
Option("missingkey=error").
Parse(strings.TrimSpace(node.LineComment[len(conf.Prefix):]))
Parse(tmplSrc)
if err != nil {
return err
}
Expand All @@ -40,7 +41,14 @@ func LineComment(conf config.Config, node *yaml.Node) error {
return err
}

node.Value = buf.String()
if buf.String() != node.Value {
log.WithFields(log.Fields{
"tmpl": tmplSrc,
"from": node.Value,
"to": buf.String(),
}).Debug("updating value")
node.Value = buf.String()
}
}
return nil
}

0 comments on commit 87ec052

Please sign in to comment.