fixing error messages

Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
pull/30603/head
Robert Sirchia 7 months ago
parent c2e6ed8ae5
commit 848c134e0c
No known key found for this signature in database
GPG Key ID: C2D40F4D8196E874

@ -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
}

@ -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 {

@ -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))

@ -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 {

@ -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

@ -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())
}

@ -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())
}

@ -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()
}

@ -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
}

@ -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)

Loading…
Cancel
Save