2016-11-16 17:19:26 +01:00
|
|
|
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
|
2016-11-16 18:29:44 +01:00
|
|
|
package encoding
|
2016-11-16 17:19:26 +01:00
|
|
|
|
|
|
|
import (
|
2016-11-20 01:13:13 +01:00
|
|
|
"github.com/marapongo/mu/pkg/util"
|
2016-11-16 17:19:26 +01:00
|
|
|
"github.com/marapongo/mu/pkg/workspace"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// Ensure a marshaler is available for every possible Mufile extension
|
|
|
|
Marshalers = make(map[string]Marshaler)
|
2016-11-20 17:20:19 +01:00
|
|
|
for _, ext := range workspace.Exts {
|
2016-11-16 17:19:26 +01:00
|
|
|
switch ext {
|
|
|
|
case ".json":
|
|
|
|
Marshalers[ext] = &jsonMarshaler{}
|
|
|
|
case ".yml":
|
|
|
|
fallthrough
|
|
|
|
case ".yaml":
|
|
|
|
Marshalers[ext] = &yamlMarshaler{}
|
|
|
|
default:
|
2016-11-20 01:13:13 +01:00
|
|
|
util.FailMF("No Marshaler available for MufileExt %v", ext)
|
2016-11-16 17:19:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|