From 4a9c1b8046382bef9905e2d4ae2539548b76de60 Mon Sep 17 00:00:00 2001 From: Paul Chen Date: Wed, 7 Feb 2024 21:31:21 +0800 Subject: [PATCH] fix: init command build empty config file (#108) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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. --- types/config/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/types/config/config.go b/types/config/config.go index 671c054b..bb470fea 100644 --- a/types/config/config.go +++ b/types/config/config.go @@ -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 ( @@ -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) {