Skip to content

Commit 47102fe

Browse files
committed
just fill in the blank config with default content
1 parent cabf0b1 commit 47102fe

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

context/context.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ func (c *fsContext) Config() (config.Config, error) {
165165
if c.config == nil {
166166
cfg, err := config.ParseDefaultConfig()
167167
if errors.Is(err, os.ErrNotExist) {
168-
cfg, err = config.InitDefaultConfig()
169-
if err != nil {
170-
return nil, fmt.Errorf("could not create default config: %w", err)
171-
}
168+
cfg = config.NewBlankConfig()
172169
} else if err != nil {
173170
return nil, err
174171
}

internal/config/config_type.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ func NewConfig(root *yaml.Node) Config {
122122
}
123123
}
124124

125-
func InitDefaultConfig() (Config, error) {
126-
cfg := NewConfig(&yaml.Node{
125+
func NewBlankConfig() Config {
126+
return NewConfig(&yaml.Node{
127127
Kind: yaml.DocumentNode,
128128
Content: []*yaml.Node{
129129
{
@@ -169,21 +169,6 @@ func InitDefaultConfig() (Config, error) {
169169
},
170170
},
171171
})
172-
173-
err := cfg.Write()
174-
if err != nil {
175-
return nil, err
176-
}
177-
178-
return cfg, nil
179-
180-
}
181-
182-
func NewBlankConfig() Config {
183-
return NewConfig(&yaml.Node{
184-
Kind: yaml.DocumentNode,
185-
Content: []*yaml.Node{{Kind: yaml.MappingNode}},
186-
})
187172
}
188173

189174
// This type implements a Config interface and represents a config file on disk.

0 commit comments

Comments
 (0)