Skip to content

Commit

Permalink
Ensure skip_diff_on_missing_files to work with relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Nov 13, 2020
1 parent 2c669a4 commit b24131f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/helmfile/skip_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ import (
"errors"
"golang.org/x/xerrors"
"os"
"path/filepath"
)

func shouldDiff(rs *ReleaseSet) (bool, error) {
for _, path := range rs.SkipDiffOnMissingFiles {
if _, err := os.Stat(path); err != nil {
logf("processing %q in skip_diff_on_missing_files...", path)

abs, err := filepath.Abs(path)
if err != nil {
return false, xerrors.Errorf("determining absolute path to %s: %w", path, err)
}

if _, err := os.Stat(abs); err != nil {
if errors.Is(err, os.ErrNotExist) {
logf("detected missing file: %s", path)
logf("detected missing file: %s", abs)

return false, nil
}

return false, xerrors.Errorf("failed calling stat: %w", err)
}

logf("detected existing file: %s", abs)
}

return true, nil
Expand Down

0 comments on commit b24131f

Please sign in to comment.