Skip to content

Commit

Permalink
Merge pull request #739 from surajnarwade/check_error
Browse files Browse the repository at this point in the history
 Prevent odo fail if `~/.kube` is not present
  • Loading branch information
syamgk authored Sep 17, 2018
2 parents 0764b57 + 827e41c commit 773aa0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Execute() {
// before proceeding with fetching the latest version
cfg, err := config.New()
if err != nil {
fmt.Println("unable to fetch configuration from Odo config file.")
checkError(err, "")
}
if cfg.GetUpdateNotification() == true {
updateInfo := make(chan string)
Expand Down
10 changes: 9 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ func New() (*ConfigInfo, error) {
if err != nil {
return nil, errors.Wrap(err, "unable to get odo config file")
}

// Check whether directory present or not
_, err = os.Stat(filepath.Dir(configFile))
if os.IsNotExist(err) {
err = os.MkdirAll(filepath.Dir(configFile), 0755)
if err != nil {
return nil, errors.Wrap(err, "unable to create directory")
}
}
// Check whether config file is present or not
_, err = os.Stat(configFile)
if os.IsNotExist(err) {
file, err := os.Create(configFile)
Expand Down

0 comments on commit 773aa0d

Please sign in to comment.