Skip to content

Commit

Permalink
fix: properly return error from config.Init
Browse files Browse the repository at this point in the history
Checking for file-not-exist error is not enough.

Fixes #683

Signed-off-by: Dmitriy Matrenichev <[email protected]>
  • Loading branch information
DmitriyMV committed Oct 14, 2024
1 parent 3655206 commit 1c12dfc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/pkg/omnictl/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,22 @@ var (
func Init(path string, create bool) (*Config, error) {
conf, err := load(path)

if os.IsNotExist(err) {
switch {
case os.IsNotExist(err):
if !create {
return nil, err
}

defaultConfig.Path = path

err := defaultConfig.Save()
err = defaultConfig.Save()
if err != nil {
return nil, err
}

conf = &defaultConfig
case err != nil:
return nil, err
}

current = conf
Expand Down

0 comments on commit 1c12dfc

Please sign in to comment.