Skip to content

Commit

Permalink
fix: init command build empty config file (#108)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰
v    Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Description
<!-- Small description -->

This PR intends to fix the init command building empty config instead of
the default config since `bytes` value of `DefaultConfig` built by
constructor is `nil`.

## Checklist
- [x] Targeted PR against correct branch.
- [ ] Linked to Github issue with discussion and accepted design OR link
to spec that describes this work.
- [ ] Wrote unit tests.
- [x] Re-reviewed `Files changed` in the Github PR explorer.
  • Loading branch information
dadamu authored and RiccardoM committed Mar 27, 2024
1 parent 9464fb3 commit 96eba55
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion types/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package config
import (
"strings"

"gopkg.in/yaml.v3"

databaseconfig "github.com/forbole/juno/v4/database/config"
loggingconfig "github.com/forbole/juno/v4/logging/config"
nodeconfig "github.com/forbole/juno/v4/node/config"
Expand Down Expand Up @@ -41,11 +43,19 @@ func NewConfig(
}

func DefaultConfig() Config {
return NewConfig(
cfg := NewConfig(
nodeconfig.DefaultConfig(),
DefaultChainConfig(), databaseconfig.DefaultDatabaseConfig(),
parserconfig.DefaultParsingConfig(), loggingconfig.DefaultLoggingConfig(),
)

bz, err := yaml.Marshal(cfg)
if err != nil {
panic(err)
}

cfg.bytes = bz
return cfg
}

func (c Config) GetBytes() ([]byte, error) {
Expand Down

0 comments on commit 96eba55

Please sign in to comment.