File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ package configuration
1717
1818import (
1919 "encoding/json"
20+ "errors"
2021 "fmt"
22+ "io/fs"
2123 "math/rand"
2224 "os"
2325 "path/filepath"
@@ -223,7 +225,7 @@ func (c *Configuration) Load() error {
223225 c .storage = & StorageHCL {}
224226 }
225227 if err = c .storage .Load (c .HAProxy .DataplaneConfig ); err != nil {
226- if os . IsNotExist (err ) {
228+ if errors . Is (err , fs . ErrNotExist ) {
227229 log .Warningf ("configuration file %s does not exists, creating one" , c .HAProxy .DataplaneConfig )
228230 } else {
229231 return fmt .Errorf ("configuration file %s not valid: %w" , c .HAProxy .DataplaneConfig , err )
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
1919 "encoding/base64"
2020 "errors"
2121 "fmt"
22+ "io/fs"
2223 "os"
2324 "path"
2425 "strconv"
@@ -75,7 +76,7 @@ func processExists(pid int) bool {
7576
7677func fileExists (filename string ) bool {
7778 info , err := os .Stat (filename )
78- if os . IsNotExist (err ) {
79+ if errors . Is (err , fs . ErrNotExist ) {
7980 return false
8081 }
8182 return ! info .IsDir ()
Original file line number Diff line number Diff line change 1616package configuration
1717
1818import (
19+ "errors"
1920 "fmt"
21+ "io/fs"
2022 "os"
2123 "strings"
2224 "sync"
@@ -134,7 +136,7 @@ func (u *Users) RemoveUser(user types.User) error {
134136
135137func (u * Users ) getUsersFromUsersListSection (filename , userlistSection string ) error {
136138 // if file doesn't exists
137- if _ , err := os .Stat (filename ); os . IsNotExist (err ) {
139+ if _ , err := os .Stat (filename ); errors . Is (err , fs . ErrNotExist ) {
138140 return fmt .Errorf ("cannot read %s, file does not exist" , filename )
139141 }
140142 p , errP := parser .New (options .Path (filename ))
You can’t perform that action at this time.
0 commit comments