Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent odo fail if ~/.kube is not present #739

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if err is something else than IsNotExist?

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