Skip to content

Commit

Permalink
Added missing error wrappings in kustomizationExists function (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahlunar authored Nov 17, 2021
1 parent af4b3c8 commit 74a3abe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/flow/kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -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
Expand All @@ -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" {
Expand All @@ -58,7 +58,7 @@ func kustomizationExists(directory string) (string, error) {
})

if err != nil {
return "", err
return "", errors.WithMessage(err, "walk directory")
}

return filePath, nil
Expand Down

0 comments on commit 74a3abe

Please sign in to comment.