Commit a2d1e339 authored by Brian Tiger Chow's avatar Brian Tiger Chow

refactor(init): write config at top level

parent 44f3d95c
...@@ -104,11 +104,15 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai ...@@ -104,11 +104,15 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai
return nil, errCannotInitConfigExists return nil, errCannotInitConfigExists
} }
conf, err := initConfig(configFilename, dspathOverride, nBitsForKeypair) conf, err := initConfig(dspathOverride, nBitsForKeypair)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if err := config.WriteConfigFile(configFilename, conf); err != nil {
return nil, err
}
err = addTheWelcomeFile(conf) err = addTheWelcomeFile(conf)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -165,7 +169,7 @@ func datastoreConfig(dspath string) (config.Datastore, error) { ...@@ -165,7 +169,7 @@ func datastoreConfig(dspath string) (config.Datastore, error) {
return ds, nil return ds, nil
} }
func initConfig(configFilename string, dspathOverride string, nBitsForKeypair int) (*config.Config, error) { func initConfig(dspathOverride string, nBitsForKeypair int) (*config.Config, error) {
ds, err := datastoreConfig(dspathOverride) ds, err := datastoreConfig(dspathOverride)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -214,10 +218,6 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in ...@@ -214,10 +218,6 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in
Version: config.VersionDefaultValue(), Version: config.VersionDefaultValue(),
} }
if err := config.WriteConfigFile(configFilename, conf); err != nil {
return nil, err
}
return conf, nil return conf, nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment