fix(engine): add debug logging to the no-cluster lookup placeholder

The lookup function has two implementations: a real one backed by a
Kubernetes client, and a placeholder that always returns empty and is
used whenever there is no cluster connection (the default for plain
helm template, without --validate or --dry-run=server).

The earlier fix for issue 32101 only added logging to the real
implementation, so plain helm template --debug, which is the common
case, still silently returned empty with no indication why. Add the
same kind of debug log to the placeholder.

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
pull/32660/head
Ogulcan Aydogan 2 weeks ago
parent c3bb7ad28e
commit b696c31694
No known key found for this signature in database
GPG Key ID: 00C439F668BFC3F6

@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"maps"
"math"
"reflect"
@ -88,8 +89,16 @@ func funcMap() template.FuncMap {
"tpl": func(string, any) any { return "not implemented" },
"required": func(string, any) (any, error) { return "not implemented", nil },
// Provide a placeholder for the "lookup" function, which requires a kubernetes
// connection.
"lookup": func(string, string, string, string) (map[string]any, error) {
// connection. This is what actually runs for a plain `helm template` (client-only
// dry run, no cluster connection), which is the common case users hit when they
// expect lookup to see real cluster state and get an empty result instead.
"lookup": func(apiversion, kind, namespace, name string) (map[string]any, error) {
slog.Debug("lookup: no cluster connection, returning empty result",
slog.String("apiVersion", apiversion),
slog.String("kind", kind),
slog.String("namespace", namespace),
slog.String("name", name),
)
return map[string]any{}, nil
},
}

Loading…
Cancel
Save