Skip to content

Commit

Permalink
Allow lakectl to run without a config file (#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiad200 authored Dec 13, 2020
1 parent 182bb7a commit 11a13f8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/lakectl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 11a13f8

Please sign in to comment.