From 74a3abe4d57a3991764f92f882650b24032cc118 Mon Sep 17 00:00:00 2001 From: Martin Anker Have Date: Wed, 17 Nov 2021 12:34:21 +0100 Subject: [PATCH] Added missing error wrappings in kustomizationExists function (#269) --- internal/flow/kustomization.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/flow/kustomization.go b/internal/flow/kustomization.go index 8593705b..785ef1c7 100644 --- a/internal/flow/kustomization.go +++ b/internal/flow/kustomization.go @@ -25,7 +25,7 @@ func kustomizationExists(directory string) (string, error) { err := filepath.WalkDir(directory, func(path string, d fs.DirEntry, err error) error { if err != nil { - return err + return errors.WithMessagef(err, "walk dir '%s'", directory) } if filePath != "" { @@ -38,7 +38,7 @@ func kustomizationExists(directory string) (string, error) { file, err := os.OpenFile(path, os.O_RDWR, os.ModePerm) if err != nil { - return err + return errors.WithMessagef(err, "open file '%s'", path) } var spec kustomizationSpec @@ -47,7 +47,7 @@ func kustomizationExists(directory string) (string, error) { err = yaml.NewDecoder(file).Decode(&spec) if err != nil { if errors.Cause(err) != io.EOF { - return err + return errors.WithMessagef(err, "decode '%s'", path) } } if strings.HasPrefix(spec.APIVersion, "kustomize.toolkit.fluxcd.io/") && spec.Kind == "Kustomization" { @@ -58,7 +58,7 @@ func kustomizationExists(directory string) (string, error) { }) if err != nil { - return "", err + return "", errors.WithMessage(err, "walk directory") } return filePath, nil