Skip to content

Commit

Permalink
add debug logs for atmos vals func
Browse files Browse the repository at this point in the history
  • Loading branch information
speier committed Nov 12, 2024
1 parent 7606174 commit 2b17230
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/exec/template_funcs_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"sync"
"time"

"github.com/helmfile/vals"

Expand Down Expand Up @@ -47,19 +48,23 @@ func valsFunc(cliConfig schema.CliConfiguration, ref string) (any, error) {
return nil, fmt.Errorf("vals failed to initialize runtime: %w", err)
}

now := time.Now()
res, err := vrt.Get(ref)
if err != nil {
return nil, fmt.Errorf("vals failed to get value for reference %q: %w", ref, err)
}
u.LogDebug(cliConfig, fmt.Sprintf("vals get: '%s' in %s", ref, time.Since(now)))

return res, nil
}

// vals singleton runtime to support builtin LRU cache and avoid multiple initialization
func valsRuntime(cliConfig schema.CliConfiguration) (*vals.Runtime, error) {
valsOnce.Do(func() {
now := time.Now()
vlw := valsLogWriter{cliConfig}
valsInst, valsErr = vals.New(vals.Options{LogOutput: vlw})
u.LogDebug(cliConfig, fmt.Sprintf("vals runtime init in %s", time.Since(now)))
})
return valsInst, valsErr
}

0 comments on commit 2b17230

Please sign in to comment.