From 11a13f8b39509288cc6957348d0a5879db3aa364 Mon Sep 17 00:00:00 2001 From: itaiad200 Date: Sun, 13 Dec 2020 13:27:33 +0200 Subject: [PATCH] Allow lakectl to run without a config file (#1040) --- cmd/lakectl/cmd/root.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/lakectl/cmd/root.go b/cmd/lakectl/cmd/root.go index ee2263ca475..9b8f6059d11 100644 --- a/cmd/lakectl/cmd/root.go +++ b/cmd/lakectl/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "encoding/json" + "errors" "fmt" "io" "os" @@ -40,8 +41,13 @@ lakectl is a CLI tool allowing exploration and manipulation of a lakeFS environm if cmd == configCmd { return } - if _, ok := cfgFileErr.(viper.ConfigFileNotFoundError); ok { - // specific message in case the file doesn't not found + + if errors.As(cfgFileErr, &viper.ConfigFileNotFoundError{}) { + if cfgFile == "" { + // if the config file wasn't provided, try to run using the default values + env vars + return + } + // specific message in case the file isn't found DieFmt("config file not found, please run \"lakectl config\" to create one\n%s\n", cfgFileErr) } else if cfgFileErr != nil { // other errors while reading the config file