Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scw/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"syscall"
"text/template"

"github.com/scaleway/scaleway-sdk-go/internal/auth"
Expand Down Expand Up @@ -182,11 +181,13 @@ func LoadConfig() (*Config, error) {

// LoadConfigFromPath read the config from the given path.
func LoadConfigFromPath(path string) (*Config, error) {
_, err := os.Stat(path)
if os.IsNotExist(err) {
return nil, configFileNotFound(path)
}

file, err := ioutil.ReadFile(path)
if err != nil {
if pathError, isPathError := err.(*os.PathError); isPathError && pathError.Err == syscall.ENOENT {
return nil, configFileNotFound(pathError.Path)
}
return nil, errors.Wrap(err, "cannot read config file")
}

Expand Down