From 1c12dfca93bb63977db65ac89fecfe36dc6d88a7 Mon Sep 17 00:00:00 2001 From: Dmitriy Matrenichev Date: Mon, 14 Oct 2024 11:33:14 +0300 Subject: [PATCH] fix: properly return error from `config.Init` Checking for file-not-exist error is not enough. Fixes #683 Signed-off-by: Dmitriy Matrenichev --- client/pkg/omnictl/config/config.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/pkg/omnictl/config/config.go b/client/pkg/omnictl/config/config.go index 2134775e..ea692cee 100644 --- a/client/pkg/omnictl/config/config.go +++ b/client/pkg/omnictl/config/config.go @@ -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