From 1ad79a2bb71c94cb4c232a8527ddde1953d41b39 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 14:21:57 -0500 Subject: [PATCH 01/18] converting inline log to slog Signed-off-by: Robert Sirchia --- internal/sympath/walk.go | 4 ++-- pkg/chart/v2/util/dependencies.go | 12 ++++++------ pkg/engine/engine.go | 8 ++++---- pkg/engine/lookup_func.go | 10 +++++----- pkg/ignore/rules.go | 10 +++++----- pkg/plugin/installer/http_installer.go | 3 ++- pkg/plugin/installer/installer.go | 10 ---------- pkg/plugin/installer/local_installer.go | 5 +++-- pkg/plugin/installer/vcs_installer.go | 15 ++++++++------- pkg/release/util/manifest_sorter.go | 4 ++-- pkg/repo/chartrepo.go | 5 +++-- 11 files changed, 40 insertions(+), 46 deletions(-) diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index 6b221fb6c..938a99bfe 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -21,7 +21,7 @@ limitations under the License. package sympath import ( - "log" + "log/slog" "os" "path/filepath" "sort" @@ -72,7 +72,7 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { return errors.Wrapf(err, "error evaluating symlink %s", path) } //This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons. - log.Printf("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) + slog.Info("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) if info, err = os.Lstat(resolved); err != nil { return err } diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 78ed46517..2a6912e84 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -16,7 +16,7 @@ limitations under the License. package util import ( - "log" + "log/slog" "strings" "github.com/mitchellh/copystructure" @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - log.Printf("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - log.Printf("Warning: PathValue returned error %v", err) + slog.Error("Warning: PathValue returned error %v", err) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - log.Printf("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err) + slog.Error("Warning: ImportValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - log.Printf("Warning: ImportValues missing table: %v", err) + slog.Error("Warning: ImportValues missing table: %v", err) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 0d0a398be..650b56a3a 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -18,7 +18,7 @@ package engine import ( "fmt" - "log" + "log/slog" "path" "path/filepath" "regexp" @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - log.Printf("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - log.Printf("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - log.Printf("[INFO] Fail: %s", msg) + slog.Info("[INFO] Fail: %s", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 75e85098d..c7f7226f4 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -18,7 +18,7 @@ package engine import ( "context" - "log" + "log/slog" "strings" "github.com/pkg/errors" @@ -101,7 +101,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + slog.Error("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - log.Printf("[ERROR] unable to get dynamic client %s", err) + slog.Error("[ERROR] unable to get dynamic client %s", err) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - log.Printf("[ERROR] unable to create discovery client %s", err) + slog.Error("[ERROR] unable to create discovery client %s", err) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - log.Printf("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 88de407ad..e59e8dee5 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -20,7 +20,7 @@ import ( "bufio" "bytes" "io" - "log" + "log/slog" "os" "path/filepath" "strings" @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - log.Printf("ignore: no matcher supplied for %q", p.raw) + slog.Info("ignore: no matcher supplied for %q", p.raw) return false } @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - log.Printf("Failed to compile %q: %s", rule, err) + slog.Error("Failed to compile %q: %s", rule, err) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - log.Printf("Failed to compile %q: %s", rule, err) + slog.Error("Failed to compile %q: %s", rule, err) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - log.Printf("Failed to compile %q: %s", rule, err) + slog.Error("Failed to compile %q: %s", rule, err) return false } return ok diff --git a/pkg/plugin/installer/http_installer.go b/pkg/plugin/installer/http_installer.go index b900fa401..7e457b0d0 100644 --- a/pkg/plugin/installer/http_installer.go +++ b/pkg/plugin/installer/http_installer.go @@ -20,6 +20,7 @@ import ( "bytes" "compress/gzip" "io" + "log/slog" "os" "path" "path/filepath" @@ -144,7 +145,7 @@ func (i *HTTPInstaller) Install() error { return err } - debug("copying %s to %s", src, i.Path()) + slog.Debug("copying %s to %s", src, i.Path()) return fs.CopyDir(src, i.Path()) } diff --git a/pkg/plugin/installer/installer.go b/pkg/plugin/installer/installer.go index 5fad58f99..1e90bcaa0 100644 --- a/pkg/plugin/installer/installer.go +++ b/pkg/plugin/installer/installer.go @@ -16,8 +16,6 @@ limitations under the License. package installer import ( - "fmt" - "log" "net/http" "os" "path/filepath" @@ -125,11 +123,3 @@ func isPlugin(dirname string) bool { _, err := os.Stat(filepath.Join(dirname, plugin.PluginFileName)) return err == nil } - -var logger = log.New(os.Stderr, "[debug] ", log.Lshortfile) - -func debug(format string, args ...interface{}) { - if Debug { - logger.Output(2, fmt.Sprintf(format, args...)) - } -} diff --git a/pkg/plugin/installer/local_installer.go b/pkg/plugin/installer/local_installer.go index a79ca7ec7..4c95134ca 100644 --- a/pkg/plugin/installer/local_installer.go +++ b/pkg/plugin/installer/local_installer.go @@ -16,6 +16,7 @@ limitations under the License. package installer // import "helm.sh/helm/v4/pkg/plugin/installer" import ( + "log/slog" "os" "path/filepath" @@ -57,12 +58,12 @@ func (i *LocalInstaller) Install() error { if !isPlugin(i.Source) { return ErrMissingMetadata } - debug("symlinking %s to %s", i.Source, i.Path()) + slog.Debug("symlinking %s to %s", i.Source, i.Path()) return os.Symlink(i.Source, i.Path()) } // Update updates a local repository func (i *LocalInstaller) Update() error { - debug("local repository is auto-updated") + slog.Debug("local repository is auto-updated") return nil } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 3967e46cd..41b47ed13 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -16,6 +16,7 @@ limitations under the License. package installer // import "helm.sh/helm/v4/pkg/plugin/installer" import ( + "log/slog" "os" "sort" @@ -88,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - debug("updating %s", i.Repo.Remote()) + slog.Debug("updating %s", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -128,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - debug("found refs: %s", refs) + slog.Debug("found refs: %s", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -139,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - debug("setting to %s", ver) + slog.Debug("setting to %s", ver) return ver, nil } } @@ -149,17 +150,17 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - debug("setting version to %q", i.Version) + slog.Debug("setting version to %q", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - debug("updating %s", repo.Remote()) + slog.Debug("updating %s", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index 15eb76174..8b5247cad 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -17,7 +17,7 @@ limitations under the License. package util import ( - "log" + "log/slog" "path" "sort" "strconv" @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - log.Printf("info: skipping unknown hook: %q", hookTypes) + slog.Info("info: skipping unknown hook: %q", hookTypes) continue } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 52f81be57..070069748 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -22,7 +22,7 @@ import ( "encoding/json" "fmt" "io" - "log" + "log/slog" "net/url" "os" "path/filepath" @@ -343,7 +343,8 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - log.Panic(err) + slog.Error("failed to marshal entry: %s", err) + panic(err) } return string(buf) } From c36bc25fb16577559c6573633c630f1295040202 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 14:48:29 -0500 Subject: [PATCH 02/18] fixing missing attributes Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 4 ++-- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 4 ++-- pkg/ignore/rules.go | 2 +- pkg/plugin/installer/vcs_installer.go | 10 +++++----- pkg/release/util/manifest_sorter.go | 2 +- pkg/repo/chartrepo.go | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 2a6912e84..8c64298c9 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("Warning: PathValue returned error %v", err) + slog.Error("Warning: PathValue returned error %v", slog.Any("err", err)) } } } @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("Warning: ImportValues missing table: %v", err) + slog.Error("Warning: ImportValues missing table: %v", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 650b56a3a..157338bbd 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", warn) + slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("[INFO] Fail: %s", msg) + slog.Info("[INFO] Fail: %s", "LintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index c7f7226f4..b8a0b8378 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("[ERROR] unable to get dynamic client %s", err) + slog.Error("[ERROR] unable to get dynamic client %s", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,7 +122,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("[ERROR] unable to create discovery client %s", err) + slog.Error("[ERROR] unable to create discovery client %s", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index e59e8dee5..6d146e719 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("ignore: no matcher supplied for %q", p.raw) + slog.Info("ignore: no matcher supplied for %q", "patterns", p.raw) return false } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 41b47ed13..cb7f3fa09 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -95,7 +95,7 @@ func (i *VCSInstaller) Install() error { // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating %s", i.Repo.Remote()) + slog.Debug("updating %s", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("found refs: %s", refs) + slog.Debug("found refs: %s", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("setting to %s", ver) + slog.Debug("setting to %s", "versions", ver) return ver, nil } } @@ -150,7 +150,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("setting version to %q", i.Version) + slog.Debug("setting version to %q", "versions", i.Version) return repo.UpdateVersion(ref) } @@ -160,7 +160,7 @@ func (i *VCSInstaller) sync(repo vcs.Repo) error { slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - slog.Debug("updating %s", repo.Remote()) + slog.Debug("updating %s", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index 8b5247cad..e1cf9171a 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("info: skipping unknown hook: %q", hookTypes) + slog.Info("info: skipping unknown hook: %q", "hookTypes", hookTypes) continue } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 070069748..748730f27 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -343,7 +343,7 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - slog.Error("failed to marshal entry: %s", err) + slog.Error("failed to marshal entry: %s", slog.Any("err", err)) panic(err) } return string(buf) From 8887d017915507ae3a28d6cfff4244f3fae79c5d Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Thu, 27 Feb 2025 15:47:28 -0500 Subject: [PATCH 03/18] fixing issues with my PR Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 10 +++++----- pkg/engine/engine.go | 10 +++++----- pkg/engine/lookup_func.go | 10 +++++----- pkg/ignore/rules.go | 2 +- pkg/plugin/installer/vcs_installer.go | 16 ++++++++-------- pkg/release/util/manifest_sorter.go | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 8c64298c9..387d8b297 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - slog.Warn("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("Condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("Warning: PathValue returned error %v", slog.Any("err", err)) + slog.Error("PathValue returned error %v", slog.Any("err", err)) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - slog.Warn("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("Tag '%s' for chart %s returned non-bool value", k, r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("Warning: ImportValues missing table from chart %s: %v", r.Name, err) + slog.Error("ImportValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("Warning: ImportValues missing table: %v", slog.Any("err", err)) + slog.Error("ImportValues missing table: %v", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 157338bbd..fa51f0923 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -176,12 +176,12 @@ func tplFun(parent *template.Template, includedNames map[string]int, strict bool // text string. (Maybe we could use a hash appended to the name?) t, err = t.New(parent.Name()).Parse(tpl) if err != nil { - return "", errors.Wrapf(err, "cannot parse template %q", tpl) + return "", errors.Wrapf(err, "Cannot parse template %q", tpl) } var buf strings.Builder if err := t.Execute(&buf, vals); err != nil { - return "", errors.Wrapf(err, "error during tpl function execution for %q", tpl) + return "", errors.Wrapf(err, "Error during tpl function execution for %q", tpl) } // See comment in renderWithReferences explaining the hack. @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) + slog.Warn("Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("[INFO] Missing required value: %s", "LintMode", warn) + slog.Warn("Missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("[INFO] Fail: %s", "LintMode", msg) + slog.Info("Fail: %s", "LintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index b8a0b8378..47f7dd179 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,8 +101,8 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) + slog.Error("Unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + return nil, false, errors.Wrapf(err, "Unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ Group: apiRes.Group, @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("[ERROR] unable to get dynamic client %s", slog.Any("err", err)) + slog.Error("Unable to get dynamic client %s", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("[ERROR] unable to create discovery client %s", slog.Any("err", err)) + slog.Error("Unable to create discovery client %s", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("Unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 6d146e719..a343030ea 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("ignore: no matcher supplied for %q", "patterns", p.raw) + slog.Info("This will be ignored no matcher supplied for %q", "patterns", p.raw) return false } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index cb7f3fa09..97b2f1cd4 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -89,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("Copying %s to %s", i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating %s", "repo", i.Repo.Remote()) + slog.Debug("Updating %s", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("found refs: %s", "refs", refs) + slog.Debug("Found refs: %s", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,27 +140,27 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("setting to %s", "versions", ver) + slog.Debug("Setting to %s", "versions", ver) return ver, nil } } - return "", errors.Errorf("requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) + return "", errors.Errorf("Requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) } // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("setting version to %q", "versions", i.Version) + slog.Debug("Setting version to %q", "versions", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("Cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - slog.Debug("updating %s", "remote", repo.Remote()) + slog.Debug("Updating %s", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index e1cf9171a..495b0ae0d 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("info: skipping unknown hook: %q", "hookTypes", hookTypes) + slog.Info("Skipping unknown hook: %q", "hookTypes", hookTypes) continue } From c2e6ed8ae5bcfa3ca1932bb4e0fb6a498b23283b Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 28 Feb 2025 08:22:53 -0500 Subject: [PATCH 04/18] fixing build error Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 10 +++++----- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 10 +++++----- pkg/ignore/rules.go | 8 ++++---- pkg/plugin/installer/vcs_installer.go | 16 ++++++++-------- pkg/release/util/manifest_sorter.go | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 387d8b297..07d2ad055 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - slog.Warn("Condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("condition path '%s' for chart %s returned non-bool value", c, r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("PathValue returned error %v", slog.Any("err", err)) + slog.Error("pathValue returned error %v", slog.Any("err", err)) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - slog.Warn("Tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("tag '%s' for chart %s returned non-bool value", k, r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table from chart %s: %v", r.Name, err) + slog.Error("importValues missing table from chart %s: %v", r.Name, err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table: %v", slog.Any("err", err)) + slog.Error("importValues missing table: %v", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index fa51f0923..4da458e73 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("Missing required value: %s", "LintMode", warn) + slog.Warn("missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("Missing required value: %s", "LintMode", warn) + slog.Warn("missing required value: %s", "LintMode", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("Fail: %s", "LintMode", msg) + slog.Info("fail: %s", "lintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 47f7dd179..9043b519b 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,8 +101,8 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("Unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) - return nil, false, errors.Wrapf(err, "Unable to get apiresource from unstructured: %s", gvk.String()) + slog.Error("unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ Group: apiRes.Group, @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("Unable to get dynamic client %s", slog.Any("err", err)) + slog.Error("unable to get dynamic client %s", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("Unable to create discovery client %s", slog.Any("err", err)) + slog.Error("unable to create discovery client %s", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("Unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index a343030ea..25a9c6715 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("This will be ignored no matcher supplied for %q", "patterns", p.raw) + slog.Info("this will be ignored no matcher supplied for %q", "patterns", p.raw) return false } @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("Failed to compile %q: %s", rule, err) + slog.Error("failed to compile %q: %s", rule, err) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("Failed to compile %q: %s", rule, err) + slog.Error("failed to compile %q: %s", rule, err) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("Failed to compile %q: %s", rule, err) + slog.Error("failed to compile %q: %s", rule, err) return false } return ok diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 97b2f1cd4..cb7f3fa09 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -89,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - slog.Debug("Copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("Updating %s", "repo", i.Repo.Remote()) + slog.Debug("updating %s", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("Found refs: %s", "refs", refs) + slog.Debug("found refs: %s", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,27 +140,27 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("Setting to %s", "versions", ver) + slog.Debug("setting to %s", "versions", ver) return ver, nil } } - return "", errors.Errorf("Requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) + return "", errors.Errorf("requested version %q does not exist for plugin %q", i.Version, i.Repo.Remote()) } // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("Setting version to %q", "versions", i.Version) + slog.Debug("setting version to %q", "versions", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - slog.Debug("Cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) return repo.Get() } - slog.Debug("Updating %s", "remote", repo.Remote()) + slog.Debug("updating %s", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index 495b0ae0d..a0107c8ee 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("Skipping unknown hook: %q", "hookTypes", hookTypes) + slog.Info("skipping unknown hook: %q", "hookTypes", hookTypes) continue } From 848c134e0c0b8d47285a61c5c923e7c449e1a67c Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 28 Feb 2025 16:14:48 -0500 Subject: [PATCH 05/18] fixing error messages Signed-off-by: Robert Sirchia --- internal/sympath/walk.go | 2 +- pkg/chart/v2/util/dependencies.go | 10 +++++----- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 8 ++++---- pkg/ignore/rules.go | 8 ++++---- pkg/plugin/installer/http_installer.go | 2 +- pkg/plugin/installer/local_installer.go | 2 +- pkg/plugin/installer/vcs_installer.go | 14 +++++++------- pkg/release/util/manifest_sorter.go | 2 +- pkg/repo/chartrepo.go | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/internal/sympath/walk.go b/internal/sympath/walk.go index 938a99bfe..0cd258d39 100644 --- a/internal/sympath/walk.go +++ b/internal/sympath/walk.go @@ -72,7 +72,7 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error { return errors.Wrapf(err, "error evaluating symlink %s", path) } //This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons. - slog.Info("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) + slog.Info("found symbolic link in path. Contents of linked file included and used", "path", path, "resolved", resolved) if info, err = os.Lstat(resolved); err != nil { return err } diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 07d2ad055..80268b45c 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s r.Enabled = bv break } - slog.Warn("condition path '%s' for chart %s returned non-bool value", c, r.Name) + slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("pathValue returned error %v", slog.Any("err", err)) + slog.Error("pathValue returned error", slog.Any("err", err)) } } } @@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) { hasFalse = true } } else { - slog.Warn("tag '%s' for chart %s returned non-bool value", k, r.Name) + slog.Warn("returned non-bool value", "tag", k, "chart", r.Name) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table from chart %s: %v", r.Name, err) + slog.Error("importValues missing table from chart", "chart", r.Name, "value", err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table: %v", slog.Any("err", err)) + slog.Error("importValues missing table", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 4da458e73..d47606ee6 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required value: %s", "LintMode", warn) + slog.Warn("missing required value", "value", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required value: %s", "LintMode", warn) + slog.Warn("missing required values", "value", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("fail: %s", "lintMode", msg) + slog.Info("funcMap fail", "lintMode", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 9043b519b..b36e6a7ef 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -101,7 +101,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) gvk := schema.FromAPIVersionAndKind(apiversion, kind) apiRes, err := getAPIResourceForGVK(gvk, config) if err != nil { - slog.Error("unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) + slog.Error("unable to get apiresource", "groupVersionKind", gvk.String(), "error", err) return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) } gvr := schema.GroupVersionResource{ @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("unable to get dynamic client %s", slog.Any("err", err)) + slog.Error("unable to get dynamic client", slog.Any("err", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("unable to create discovery client %s", slog.Any("err", err)) + slog.Error("unable to create discovery client", slog.Any("err", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) + slog.Error("unable to retrieve resource list", "list", gvk.GroupVersion().String(), "error", err) return res, err } for _, resource := range resList.APIResources { diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 25a9c6715..3f672873c 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool { } for _, p := range r.patterns { if p.match == nil { - slog.Info("this will be ignored no matcher supplied for %q", "patterns", p.raw) + slog.Info("this will be ignored no matcher supplied", "patterns", p.raw) return false } @@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error { rule = strings.TrimPrefix(rule, "/") ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile %q: %s", rule, err) + slog.Error("failed to compile", "rule", rule, "error", err) return false } return ok @@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error { p.match = func(n string, _ os.FileInfo) bool { ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile %q: %s", rule, err) + slog.Error("failed to compile", "rule", rule, "error", err) return false } return ok @@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error { n = filepath.Base(n) ok, err := filepath.Match(rule, n) if err != nil { - slog.Error("failed to compile %q: %s", rule, err) + slog.Error("failed to compile", "rule", rule, "error", err) return false } return ok diff --git a/pkg/plugin/installer/http_installer.go b/pkg/plugin/installer/http_installer.go index 7e457b0d0..cc45787bf 100644 --- a/pkg/plugin/installer/http_installer.go +++ b/pkg/plugin/installer/http_installer.go @@ -145,7 +145,7 @@ func (i *HTTPInstaller) Install() error { return err } - slog.Debug("copying %s to %s", src, i.Path()) + slog.Debug("copying", "source", src, "path", i.Path()) return fs.CopyDir(src, i.Path()) } diff --git a/pkg/plugin/installer/local_installer.go b/pkg/plugin/installer/local_installer.go index 4c95134ca..52636d019 100644 --- a/pkg/plugin/installer/local_installer.go +++ b/pkg/plugin/installer/local_installer.go @@ -58,7 +58,7 @@ func (i *LocalInstaller) Install() error { if !isPlugin(i.Source) { return ErrMissingMetadata } - slog.Debug("symlinking %s to %s", i.Source, i.Path()) + slog.Debug("symlinking", "source", i.Source, "path", i.Path()) return os.Symlink(i.Source, i.Path()) } diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index cb7f3fa09..049775094 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -89,13 +89,13 @@ func (i *VCSInstaller) Install() error { return ErrMissingMetadata } - slog.Debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) + slog.Debug("copying files", "source", i.Repo.LocalPath(), "destination", i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path()) } // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating %s", "repo", i.Repo.Remote()) + slog.Debug("updating", "repo", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -129,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if err != nil { return "", err } - slog.Debug("found refs: %s", "refs", refs) + slog.Debug("found refs", "refs", refs) // Convert and filter the list to semver.Version instances semvers := getSemVers(refs) @@ -140,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { if constraint.Check(v) { // If the constraint passes get the original reference ver := v.Original() - slog.Debug("setting to %s", "versions", ver) + slog.Debug("setting to version", "version", ver) return ver, nil } } @@ -150,17 +150,17 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) { // setVersion attempts to checkout the version func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { - slog.Debug("setting version to %q", "versions", i.Version) + slog.Debug("setting version", "version", i.Version) return repo.UpdateVersion(ref) } // sync will clone or update a remote repo. func (i *VCSInstaller) sync(repo vcs.Repo) error { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { - slog.Debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) + slog.Debug("cloning", "source", repo.Remote(), "destination", repo.LocalPath()) return repo.Get() } - slog.Debug("updating %s", "remote", repo.Remote()) + slog.Debug("updating", "remote", repo.Remote()) return repo.Update() } diff --git a/pkg/release/util/manifest_sorter.go b/pkg/release/util/manifest_sorter.go index a0107c8ee..df3bd71d7 100644 --- a/pkg/release/util/manifest_sorter.go +++ b/pkg/release/util/manifest_sorter.go @@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error { } if isUnknownHook { - slog.Info("skipping unknown hook: %q", "hookTypes", hookTypes) + slog.Info("skipping unknown hooks", "hookTypes", hookTypes) continue } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 748730f27..766e31a61 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -343,7 +343,7 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - slog.Error("failed to marshal entry: %s", slog.Any("err", err)) + slog.Error("failed to marshal entry", slog.Any("err", err)) panic(err) } return string(buf) From 442200033027ce2512a5974a52993a7af4aac3d6 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 5 Mar 2025 17:21:29 +0100 Subject: [PATCH 06/18] fixing case issues with the logging of my errors Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 6 +++--- pkg/engine/engine.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 80268b45c..493bd31d6 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("pathValue returned error", slog.Any("err", err)) + slog.Error("the method PathValue returned error", slog.Any("err", err)) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table from chart", "chart", r.Name, "value", err) + slog.Error("ImportValues missing table from chart", "chart", r.Name, "value", err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("importValues missing table", slog.Any("err", err)) + slog.Error("ImportValues missing table", slog.Any("err", err)) continue } if merge { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index d47606ee6..9c91fd43b 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -176,12 +176,12 @@ func tplFun(parent *template.Template, includedNames map[string]int, strict bool // text string. (Maybe we could use a hash appended to the name?) t, err = t.New(parent.Name()).Parse(tpl) if err != nil { - return "", errors.Wrapf(err, "Cannot parse template %q", tpl) + return "", errors.Wrapf(err, "cannot parse template %q", tpl) } var buf strings.Builder if err := t.Execute(&buf, vals); err != nil { - return "", errors.Wrapf(err, "Error during tpl function execution for %q", tpl) + return "", errors.Wrapf(err, "error during tpl function execution for %q", tpl) } // See comment in renderWithReferences explaining the hack. From 2192c4e0d172ad2d200a8ccd496fef988335f5ca Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Wed, 5 Mar 2025 17:25:32 +0100 Subject: [PATCH 07/18] changing errors back to warns Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 493bd31d6..9a77920b1 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Error("the method PathValue returned error", slog.Any("err", err)) + slog.Warn("the method PathValue returned error", slog.Any("err", err)) } } } @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table from chart", "chart", r.Name, "value", err) + slog.Warn("ImportValues missing table from chart", "chart", r.Name, "value", err) continue } // create value map from child to be merged into parent @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Error("ImportValues missing table", slog.Any("err", err)) + slog.Warn("ImportValues missing table", slog.Any("err", err)) continue } if merge { From 3a195763778f52fe6cd5a9e1f478f6a232b3d15d Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Mon, 10 Mar 2025 15:40:10 -0400 Subject: [PATCH 08/18] making changes as requested by matt Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 4 ++-- pkg/engine/lookup_func.go | 4 ++-- pkg/plugin/installer/vcs_installer.go | 4 ++-- pkg/repo/chartrepo.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 9a77920b1..6c9da4430 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -51,7 +51,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s slog.Warn("returned non-bool value", "path", c, "chart", r.Name) } else if _, ok := err.(ErrNoValue); !ok { // this is a real error - slog.Warn("the method PathValue returned error", slog.Any("err", err)) + slog.Warn("the method PathValue returned error", slog.Any("error", err)) } } } @@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error { }) vm, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Warn("ImportValues missing table", slog.Any("err", err)) + slog.Warn("ImportValues missing table", slog.Any("error", err)) continue } if merge { diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index b36e6a7ef..89f2707ec 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) } intf, err := dynamic.NewForConfig(config) if err != nil { - slog.Error("unable to get dynamic client", slog.Any("err", err)) + slog.Error("unable to get dynamic client", slog.Any("error", err)) return nil, false, err } res := intf.Resource(gvr) @@ -122,7 +122,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met res := metav1.APIResource{} discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) if err != nil { - slog.Error("unable to create discovery client", slog.Any("err", err)) + slog.Error("unable to create discovery client", slog.Any("error", err)) return res, err } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) diff --git a/pkg/plugin/installer/vcs_installer.go b/pkg/plugin/installer/vcs_installer.go index 049775094..d1b704d6e 100644 --- a/pkg/plugin/installer/vcs_installer.go +++ b/pkg/plugin/installer/vcs_installer.go @@ -95,7 +95,7 @@ func (i *VCSInstaller) Install() error { // Update updates a remote repository func (i *VCSInstaller) Update() error { - slog.Debug("updating", "repo", i.Repo.Remote()) + slog.Debug("updating", "source", i.Repo.Remote()) if i.Repo.IsDirty() { return errors.New("plugin repo was modified") } @@ -160,7 +160,7 @@ func (i *VCSInstaller) sync(repo vcs.Repo) error { slog.Debug("cloning", "source", repo.Remote(), "destination", repo.LocalPath()) return repo.Get() } - slog.Debug("updating", "remote", repo.Remote()) + slog.Debug("updating", "source", repo.Remote(), "destination", repo.LocalPath()) return repo.Update() } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 766e31a61..3fe5383f3 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -343,7 +343,7 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) { func (e *Entry) String() string { buf, err := json.Marshal(e) if err != nil { - slog.Error("failed to marshal entry", slog.Any("err", err)) + slog.Error("failed to marshal entry", slog.Any("error", err)) panic(err) } return string(buf) From 835ff78f482c12703c61720e293a3ad82d652d03 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Wed, 19 Mar 2025 14:50:16 +0100 Subject: [PATCH 09/18] Remove ClientOptResolver from OCI Client This option was kept to avoid compile-time incompatibilities in Helm v3 when upgrading to ORAS v2. Let's remove it for Helm v4. This allows Helm to drop the containerd dependency entirely. Signed-off-by: Tom Wieczorek --- go.mod | 4 ---- go.sum | 8 -------- pkg/registry/client.go | 9 --------- pkg/registry/client_test.go | 33 --------------------------------- 4 files changed, 54 deletions(-) delete mode 100644 pkg/registry/client_test.go diff --git a/go.mod b/go.mod index 723cfc769..0589b84e9 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/Masterminds/squirrel v1.5.4 github.com/Masterminds/vcs v1.13.3 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 - github.com/containerd/containerd v1.7.27 github.com/cyphar/filepath-securejoin v0.4.1 github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/evanphx/json-patch v5.9.11+incompatible @@ -60,9 +59,6 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect - github.com/containerd/errdefs v0.3.0 // indirect - github.com/containerd/log v0.1.0 // indirect - github.com/containerd/platforms v0.2.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect diff --git a/go.sum b/go.sum index b0e35d8b9..20dd5c0b9 100644 --- a/go.sum +++ b/go.sum @@ -48,14 +48,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= -github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII= -github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0= -github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4= -github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= -github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= diff --git a/pkg/registry/client.go b/pkg/registry/client.go index ecc7a0d04..2078ecd75 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -31,7 +31,6 @@ import ( "sync" "github.com/Masterminds/semver/v3" - "github.com/containerd/containerd/remotes" "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" @@ -56,8 +55,6 @@ storing semantic versions, Helm adopts the convention of changing plus (+) to an underscore (_) in chart version tags when pushing to a registry and back to a plus (+) when pulling from a registry.` -var errDeprecatedRemote = errors.New("providing github.com/containerd/containerd/remotes.Resolver via ClientOptResolver is no longer suported") - type ( // RemoteClient shadows the ORAS remote.Client interface // (hiding the ORAS type from Helm client visibility) @@ -231,12 +228,6 @@ func ClientOptPlainHTTP() ClientOption { } } -func ClientOptResolver(_ remotes.Resolver) ClientOption { - return func(c *Client) { - c.err = errDeprecatedRemote - } -} - type ( // LoginOption allows specifying various settings on login LoginOption func(*loginOperation) diff --git a/pkg/registry/client_test.go b/pkg/registry/client_test.go deleted file mode 100644 index 4c5a78849..000000000 --- a/pkg/registry/client_test.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright The Helm Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package registry - -import ( - "testing" - - "github.com/containerd/containerd/remotes" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewClientResolverNotSupported(t *testing.T) { - var r remotes.Resolver - - client, err := NewClient(ClientOptResolver(r)) - require.Equal(t, err, errDeprecatedRemote) - assert.Nil(t, client) -} From a45cf1bab970430d599aa1d735615ef5264e9f38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:51:55 +0000 Subject: [PATCH 10/18] build(deps): bump actions/upload-artifact from 4.6.1 to 4.6.2 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1...ea165f8d65b6e75b540449e92b4886f43607fa02) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index f89fcd98c..a8c2e8a15 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -55,7 +55,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: SARIF file path: results.sarif From f95410f66c42759325dec33ca162056a762affbb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:51:59 +0000 Subject: [PATCH 11/18] build(deps): bump actions/setup-go from 5.3.0 to 5.4.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.3.0 to 5.4.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/f111f3307d8850f501ac008e886eec1fd1932a34...0aaccfd150d50ccaeb58ebd88d36e91967a5f35b) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/govulncheck.yml | 2 +- .github/workflows/release.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 2ccea3d0e..b654bf4d6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -20,7 +20,7 @@ jobs: - name: Checkout source code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 0d11cd531..6fbbd2c53 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index f8572f2d6..b376c7b8e 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5e7c6840..63e5c0e26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' @@ -81,7 +81,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 - name: Setup Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0 with: go-version: '1.23' check-latest: true From fc476f7235a6135acbf902aacb42af54d8edccad Mon Sep 17 00:00:00 2001 From: linghuying <1599935829@qq.com> Date: Thu, 20 Mar 2025 22:18:28 +0800 Subject: [PATCH 12/18] chore: make function comment match function name Signed-off-by: linghuying <1599935829@qq.com> --- pkg/registry/client.go | 2 +- pkg/storage/driver/mock_test.go | 2 +- pkg/storage/storage_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/registry/client.go b/pkg/registry/client.go index ecc7a0d04..fadffac5b 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -771,7 +771,7 @@ func PushOptStrictMode(strictMode bool) PushOption { } } -// PushOptCreationDate returns a function that sets the creation time +// PushOptCreationTime returns a function that sets the creation time func PushOptCreationTime(creationTime string) PushOption { return func(operation *pushOperation) { operation.creationTime = creationTime diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index 199da6505..53919b45d 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -166,7 +166,7 @@ func (mock *MockConfigMapsInterface) Delete(_ context.Context, name string, _ me return nil } -// newTestFixture initializes a MockSecretsInterface. +// newTestFixtureSecrets initializes a MockSecretsInterface. // Secrets are created for each release provided. func newTestFixtureSecrets(t *testing.T, releases ...*rspb.Release) *Secrets { var mock MockSecretsInterface diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index 056b7f5f5..1dadc9c93 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -476,7 +476,7 @@ func TestStorageLast(t *testing.T) { } } -// TestUpgradeInitiallyFailedRelease tests a case when there are no deployed release yet, but history limit has been +// TestUpgradeInitiallyFailedReleaseWithHistoryLimit tests a case when there are no deployed release yet, but history limit has been // reached: the has-no-deployed-releases error should not occur in such case. func TestUpgradeInitiallyFailedReleaseWithHistoryLimit(t *testing.T) { storage := Init(driver.NewMemory()) From 0e4d185370b6e1e8cf186dcb8946bb44ca410e24 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 21 Mar 2025 09:54:44 +0100 Subject: [PATCH 13/18] Inform about time spent waiting resources to be ready in slog format Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 7eb931496..8844b0876 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -19,6 +19,7 @@ package kube // import "helm.sh/helm/v4/pkg/kube" import ( "context" "fmt" + "log/slog" "net/http" "time" @@ -101,12 +102,13 @@ func (w *waiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached func (w *waiter) waitForDeletedResources(deleted ResourceList) error { - w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), w.timeout) + slog.Info("beginning wait for resources to be deleted", "count", len(deleted), "timeout", w.timeout) + startTime := time.Now() ctx, cancel := context.WithTimeout(context.Background(), w.timeout) defer cancel() - return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) { + err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) { for _, v := range deleted { err := v.Get() if err == nil || !apierrors.IsNotFound(err) { @@ -115,6 +117,15 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error { } return true, nil }) + + elapsed := time.Since(startTime).Round(time.Second) + if err != nil { + slog.Debug("wait for resources failed", "elapsed", elapsed, "error", err) + } else { + slog.Debug("wait for resources succeeded", "elapsed", elapsed) + } + + return err } // SelectorsForObject returns the pod label selector for a given object From e3e84b6dfe462cbd45e5252796f0b3b7f431dc6e Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 21 Mar 2025 10:08:05 +0100 Subject: [PATCH 14/18] "beginning wait" is dedicated to be display as debug log Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 8844b0876..de53a67f1 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -102,7 +102,7 @@ func (w *waiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool { // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached func (w *waiter) waitForDeletedResources(deleted ResourceList) error { - slog.Info("beginning wait for resources to be deleted", "count", len(deleted), "timeout", w.timeout) + slog.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", w.timeout) startTime := time.Now() ctx, cancel := context.WithTimeout(context.Background(), w.timeout) From 94cb21c7c48ccefafbd8ad04defe5846bcfb2751 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Fri, 21 Mar 2025 10:33:45 +0100 Subject: [PATCH 15/18] Follow convention for error with slog.Any() Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index de53a67f1..6a709b22d 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -120,7 +120,7 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error { elapsed := time.Since(startTime).Round(time.Second) if err != nil { - slog.Debug("wait for resources failed", "elapsed", elapsed, "error", err) + slog.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err)) } else { slog.Debug("wait for resources succeeded", "elapsed", elapsed) } From e4e602e13c3363b8c479607cd932e6a4efd9c38f Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Fri, 21 Mar 2025 08:06:01 -0400 Subject: [PATCH 16/18] Error when failed repo update. In Helm v3 we did not change exit codes for existing commands to maintain compat. A flag was introduced so a failure would result in a non-0 exit code. A note was left to make this the default in Helm v4. That's what this change does. Closes #10016 Signed-off-by: Matt Farina --- pkg/cmd/repo_update.go | 21 ++++++------------ pkg/cmd/repo_update_test.go | 43 +++++-------------------------------- 2 files changed, 12 insertions(+), 52 deletions(-) diff --git a/pkg/cmd/repo_update.go b/pkg/cmd/repo_update.go index 25071377b..6590d9872 100644 --- a/pkg/cmd/repo_update.go +++ b/pkg/cmd/repo_update.go @@ -42,11 +42,10 @@ To update all the repositories, use 'helm repo update'. var errNoRepositories = errors.New("no repositories found. You must add one before updating") type repoUpdateOptions struct { - update func([]*repo.ChartRepository, io.Writer, bool) error - repoFile string - repoCache string - names []string - failOnRepoUpdateFail bool + update func([]*repo.ChartRepository, io.Writer) error + repoFile string + repoCache string + names []string } func newRepoUpdateCmd(out io.Writer) *cobra.Command { @@ -69,12 +68,6 @@ func newRepoUpdateCmd(out io.Writer) *cobra.Command { }, } - f := cmd.Flags() - - // Adding this flag for Helm 3 as stop gap functionality for https://github.com/helm/helm/issues/10016. - // This should be deprecated in Helm 4 by update to the behaviour of `helm repo update` command. - f.BoolVar(&o.failOnRepoUpdateFail, "fail-on-repo-update-fail", false, "update fails if any of the repository updates fail") - return cmd } @@ -112,10 +105,10 @@ func (o *repoUpdateOptions) run(out io.Writer) error { } } - return o.update(repos, out, o.failOnRepoUpdateFail) + return o.update(repos, out) } -func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { +func updateCharts(repos []*repo.ChartRepository, out io.Writer) error { fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") var wg sync.WaitGroup var repoFailList []string @@ -133,7 +126,7 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdate } wg.Wait() - if len(repoFailList) > 0 && failOnRepoUpdateFail { + if len(repoFailList) > 0 { return fmt.Errorf("Failed to update the following repositories: %s", repoFailList) } diff --git a/pkg/cmd/repo_update_test.go b/pkg/cmd/repo_update_test.go index 5b27a6dfb..6fc4c8f4b 100644 --- a/pkg/cmd/repo_update_test.go +++ b/pkg/cmd/repo_update_test.go @@ -34,7 +34,7 @@ func TestUpdateCmd(t *testing.T) { var out bytes.Buffer // Instead of using the HTTP updater, we provide our own for this test. // The TestUpdateCharts test verifies the HTTP behavior independently. - updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { + updater := func(repos []*repo.ChartRepository, out io.Writer) error { for _, re := range repos { fmt.Fprintln(out, re.Config.Name) } @@ -59,7 +59,7 @@ func TestUpdateCmdMultiple(t *testing.T) { var out bytes.Buffer // Instead of using the HTTP updater, we provide our own for this test. // The TestUpdateCharts test verifies the HTTP behavior independently. - updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { + updater := func(repos []*repo.ChartRepository, out io.Writer) error { for _, re := range repos { fmt.Fprintln(out, re.Config.Name) } @@ -85,7 +85,7 @@ func TestUpdateCmdInvalid(t *testing.T) { var out bytes.Buffer // Instead of using the HTTP updater, we provide our own for this test. // The TestUpdateCharts test verifies the HTTP behavior independently. - updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { + updater := func(repos []*repo.ChartRepository, out io.Writer) error { for _, re := range repos { fmt.Fprintln(out, re.Config.Name) } @@ -145,7 +145,7 @@ func TestUpdateCharts(t *testing.T) { } b := bytes.NewBuffer(nil) - updateCharts([]*repo.ChartRepository{r}, b, false) + updateCharts([]*repo.ChartRepository{r}, b) got := b.String() if strings.Contains(got, "Unable to get an update") { @@ -161,39 +161,6 @@ func TestRepoUpdateFileCompletion(t *testing.T) { checkFileCompletion(t, "repo update repo1", false) } -func TestUpdateChartsFail(t *testing.T) { - defer resetEnv()() - ensure.HelmHome(t) - - ts := repotest.NewTempServer( - t, - repotest.WithChartSourceGlob("testdata/testserver/*.*"), - ) - defer ts.Stop() - - var invalidURL = ts.URL() + "55" - r, err := repo.NewChartRepository(&repo.Entry{ - Name: "charts", - URL: invalidURL, - }, getter.All(settings)) - if err != nil { - t.Error(err) - } - - b := bytes.NewBuffer(nil) - if err := updateCharts([]*repo.ChartRepository{r}, b, false); err != nil { - t.Error("Repo update should not return error if update of repository fails") - } - - got := b.String() - if !strings.Contains(got, "Unable to get an update") { - t.Errorf("Repo should have failed update but instead got: %q", got) - } - if !strings.Contains(got, "Update Complete.") { - t.Error("Update was not successful") - } -} - func TestUpdateChartsFailWithError(t *testing.T) { defer resetEnv()() ensure.HelmHome(t) @@ -214,7 +181,7 @@ func TestUpdateChartsFailWithError(t *testing.T) { } b := bytes.NewBuffer(nil) - err = updateCharts([]*repo.ChartRepository{r}, b, true) + err = updateCharts([]*repo.ChartRepository{r}, b) if err == nil { t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set") return From c5991028e01588a4f5b86cc31d794e15ffde8f64 Mon Sep 17 00:00:00 2001 From: Robert Sirchia Date: Fri, 21 Mar 2025 16:12:53 -0400 Subject: [PATCH 17/18] fixing matts changes Signed-off-by: Robert Sirchia --- pkg/chart/v2/util/dependencies.go | 2 +- pkg/engine/engine.go | 6 +++--- pkg/engine/lookup_func.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go index 6c9da4430..72a08b2a9 100644 --- a/pkg/chart/v2/util/dependencies.go +++ b/pkg/chart/v2/util/dependencies.go @@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error { // get child table vv, err := cvals.Table(r.Name + "." + child) if err != nil { - slog.Warn("ImportValues missing table from chart", "chart", r.Name, "value", err) + slog.Warn("ImportValues missing table from chart", "chart", r.Name, "error", err) continue } // create value map from child to be merged into parent diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 9c91fd43b..7235b026a 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == nil { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required value", "value", warn) + slog.Warn("missing required value", "message", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) { if val == "" { if e.LintMode { // Don't fail on missing required values when linting - slog.Warn("missing required values", "value", warn) + slog.Warn("missing required values", "message", warn) return "", nil } return val, errors.New(warnWrap(warn)) @@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) { funcMap["fail"] = func(msg string) (string, error) { if e.LintMode { // Don't fail when linting - slog.Info("funcMap fail", "lintMode", msg) + slog.Info("funcMap fail", "message", msg) return "", nil } return "", errors.New(warnWrap(msg)) diff --git a/pkg/engine/lookup_func.go b/pkg/engine/lookup_func.go index 89f2707ec..b7460850a 100644 --- a/pkg/engine/lookup_func.go +++ b/pkg/engine/lookup_func.go @@ -127,7 +127,7 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met } resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) if err != nil { - slog.Error("unable to retrieve resource list", "list", gvk.GroupVersion().String(), "error", err) + slog.Error("unable to retrieve resource list", "GroupVersion", gvk.GroupVersion().String(), "error", err) return res, err } for _, resource := range resList.APIResources { From 4f4c858f9c8f2e55871d80e877241abb9fa69b21 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sun, 23 Mar 2025 15:38:59 +0100 Subject: [PATCH 18/18] Ignore unused parameter Signed-off-by: Benoit Tigeot --- pkg/kube/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 6a709b22d..71c6add53 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -108,7 +108,7 @@ func (w *waiter) waitForDeletedResources(deleted ResourceList) error { ctx, cancel := context.WithTimeout(context.Background(), w.timeout) defer cancel() - err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) { for _, v := range deleted { err := v.Get() if err == nil || !apierrors.IsNotFound(err) {