Skip to content

Commit

Permalink
fix: init command build empty config file (forbole#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 dzmitryhil committed Dec 16, 2024
1 parent 9868445 commit 038d182
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion types/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
loggingconfig "github.com/forbole/juno/v5/logging/config"
nodeconfig "github.com/forbole/juno/v5/node/config"
parserconfig "github.com/forbole/juno/v5/parser/config"
"gopkg.in/yaml.v3"
)

var (
Expand Down Expand Up @@ -41,11 +42,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 038d182

Please sign in to comment.