extendable config format

This commit is contained in:
Darien Raymond committed 2018-02-14 23:57:40 +01:00
1 parent 94125236e6
commit 2a07838bb9
6 files changed
+129 -117

No files matched your search

+11 -7
View File
@@ -45,7 +45,7 @@ func jsonToProto(input io.Reader) (*core.Config, error) {
var config *core.Config
loadTask := signal.ExecuteAsync(func() error {
c, err := core.LoadConfig(core.ConfigFormat_Protobuf, stdoutReader)
c, err := core.LoadConfig("protobuf", "", stdoutReader)
if err != nil {
return err
}
@@ -65,11 +65,15 @@ func jsonToProto(input io.Reader) (*core.Config, error) {
}
func init() {
common.Must(core.RegisterConfigLoader(core.ConfigFormat_JSON, func(input io.Reader) (*core.Config, error) {
config, err := jsonToProto(input)
if err != nil {
return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning()
}
return config, nil
common.Must(core.RegisterConfigLoader(&core.ConfigFormat{
Name: "JSON",
Extension: []string{"json"},
Loader: func(input io.Reader) (*core.Config, error) {
config, err := jsonToProto(input)
if err != nil {
return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning()
}
return config, nil
},
}))
}