Skip to content

Commit

Permalink
Fix local settings command (#4200)
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiad200 authored Sep 19, 2022
1 parent 84e231e commit 6b0bbb5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/lakefs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func useLocal() bool {

func newConfig() (*config.Config, error) {
if useLocal() {
config.SetDefaultLocalConfig()
return config.NewLocalConfig()
}

return config.NewConfig()
Expand Down
10 changes: 9 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ type Config struct {
}

func NewConfig() (*Config, error) {
return newConfig(false)
}

func NewLocalConfig() (*Config, error) {
return newConfig(true)
}

func newConfig(local bool) (*Config, error) {
c := &Config{}

// Inform viper of all expected fields. Otherwise, it fails to deserialize from the
Expand All @@ -53,7 +61,7 @@ func NewConfig() (*Config, error) {
viper.SetDefault(key, nil)
}

setDefaults()
setDefaults(local)
setupLogger()

err := viper.UnmarshalExact(&c.values, viper.DecodeHook(
Expand Down
8 changes: 6 additions & 2 deletions pkg/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,19 @@ const (
UIEnabledKey = "ui.enabled"
)

func SetDefaultLocalConfig() {
func setDefaultLocalConfig() {
viper.SetDefault(DatabaseTypeKey, DefaultDatabaseType)
viper.SetDefault(DatabaseKVLocalPath, DefaultDatabaseLocalKVPath)
viper.SetDefault(BlockstoreLocalPathKey, DefaultBlockstoreLocalPath)
viper.SetDefault(AuthEncryptSecretKey, DefaultAuthEncryptSecretKey)
viper.SetDefault(BlockstoreTypeKey, DefaultBlockstoreType)
}

func setDefaults() {
func setDefaults(local bool) {
if local {
setDefaultLocalConfig()
}

viper.SetDefault(ListenAddressKey, DefaultListenAddr)

viper.SetDefault(LoggingFormatKey, DefaultLoggingFormat)
Expand Down

0 comments on commit 6b0bbb5

Please sign in to comment.