just fill in the blank config with default content

This commit is contained in:
vilmibm 2020-06-11 14:04:29 -05:00
parent cabf0b1972
commit 47102fe427
2 changed files with 3 additions and 21 deletions

View file

@ -165,10 +165,7 @@ func (c *fsContext) Config() (config.Config, error) {
if c.config == nil {
cfg, err := config.ParseDefaultConfig()
if errors.Is(err, os.ErrNotExist) {
cfg, err = config.InitDefaultConfig()
if err != nil {
return nil, fmt.Errorf("could not create default config: %w", err)
}
cfg = config.NewBlankConfig()
} else if err != nil {
return nil, err
}

View file

@ -122,8 +122,8 @@ func NewConfig(root *yaml.Node) Config {
}
}
func InitDefaultConfig() (Config, error) {
cfg := NewConfig(&yaml.Node{
func NewBlankConfig() Config {
return NewConfig(&yaml.Node{
Kind: yaml.DocumentNode,
Content: []*yaml.Node{
{
@ -169,21 +169,6 @@ func InitDefaultConfig() (Config, error) {
},
},
})
err := cfg.Write()
if err != nil {
return nil, err
}
return cfg, nil
}
func NewBlankConfig() Config {
return NewConfig(&yaml.Node{
Kind: yaml.DocumentNode,
Content: []*yaml.Node{{Kind: yaml.MappingNode}},
})
}
// This type implements a Config interface and represents a config file on disk.