@@ -3,6 +3,7 @@ package config
3
3
import (
4
4
"bytes"
5
5
"encoding/json"
6
+ "errors"
6
7
"fmt"
7
8
"io"
8
9
"os"
@@ -11,7 +12,7 @@ import (
11
12
12
13
validation "github.com/go-ozzo/ozzo-validation"
13
14
shlex "github.com/google/shlex"
14
- "github.com/pkg/errors"
15
+
15
16
"github.com/runatlantis/atlantis/server/core/config/raw"
16
17
"github.com/runatlantis/atlantis/server/core/config/valid"
17
18
yaml "gopkg.in/yaml.v3"
@@ -29,11 +30,11 @@ func (p *ParserValidator) HasRepoCfg(absRepoDir, repoConfigFile string) (bool, e
29
30
const invalidExtensionFilename = "atlantis.yml"
30
31
_ , err := os .Stat (p .repoCfgPath (absRepoDir , invalidExtensionFilename ))
31
32
if err == nil {
32
- return false , errors .Errorf ("found %q as config file; rename using the .yaml extension" , invalidExtensionFilename )
33
+ return false , fmt .Errorf ("found %q as config file; rename using the .yaml extension" , invalidExtensionFilename )
33
34
}
34
35
35
36
_ , err = os .Stat (p .repoCfgPath (absRepoDir , repoConfigFile ))
36
- if os . IsNotExist (err ) {
37
+ if errors . Is (err , os . ErrNotExist ) {
37
38
return false , nil
38
39
}
39
40
return err == nil , err
@@ -48,12 +49,7 @@ func (p *ParserValidator) ParseRepoCfg(absRepoDir string, globalCfg valid.Global
48
49
configData , err := os .ReadFile (configFile ) // nolint: gosec
49
50
50
51
if err != nil {
51
- if ! os .IsNotExist (err ) {
52
- return valid.RepoCfg {}, errors .Wrapf (err , "unable to read %s file" , repoConfigFile )
53
- }
54
- // Don't wrap os.IsNotExist errors because we want our callers to be
55
- // able to detect if it's a NotExist err.
56
- return valid.RepoCfg {}, err
52
+ return valid.RepoCfg {}, fmt .Errorf ("unable to read %s file: %w" , repoConfigFile , err )
57
53
}
58
54
return p .ParseRepoCfgData (configData , globalCfg , repoID , branch )
59
55
}
@@ -115,7 +111,7 @@ func (p *ParserValidator) ParseRepoCfgData(repoCfgData []byte, globalCfg valid.G
115
111
func (p * ParserValidator ) ParseGlobalCfg (configFile string , defaultCfg valid.GlobalCfg ) (valid.GlobalCfg , error ) {
116
112
configData , err := os .ReadFile (configFile ) // nolint: gosec
117
113
if err != nil {
118
- return valid.GlobalCfg {}, errors . Wrapf ( err , "unable to read %s file" , configFile )
114
+ return valid.GlobalCfg {}, fmt . Errorf ( "unable to read %s file: %w " , configFile , err )
119
115
}
120
116
if len (configData ) == 0 {
121
117
return valid.GlobalCfg {}, fmt .Errorf ("file %s was empty" , configFile )
@@ -204,7 +200,7 @@ func (p *ParserValidator) applyLegacyShellParsing(cfg *valid.RepoCfg) error {
204
200
if s .StepName == "run" {
205
201
split , err := shlex .Split (s .RunCommand )
206
202
if err != nil {
207
- return errors . Wrapf ( err , "unable to parse %q" , s .RunCommand )
203
+ return fmt . Errorf ( "unable to parse %q: %w " , s .RunCommand , err )
208
204
}
209
205
s .RunCommand = strings .Join (split , " " )
210
206
}
0 commit comments