Update server dependencies
This commit is contained in:
parent
6865bf2832
commit
f1c3326af1
152 changed files with 16097 additions and 4318 deletions
31
Godeps/_workspace/src/github.com/spf13/viper/util.go
generated
vendored
31
Godeps/_workspace/src/github.com/spf13/viper/util.go
generated
vendored
|
@ -21,6 +21,7 @@ import (
|
|||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/hashicorp/hcl"
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/BurntSushi/toml"
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/magiconair/properties"
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/spf13/cast"
|
||||
|
@ -28,6 +29,16 @@ import (
|
|||
"github.com/khlieng/dispatch/Godeps/_workspace/src/gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Denotes failing to parse configuration file.
|
||||
type ConfigParseError struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// Returns the formatted configuration error.
|
||||
func (pe ConfigParseError) Error() string {
|
||||
return fmt.Sprintf("While parsing config: %s", pe.err.Error())
|
||||
}
|
||||
|
||||
func insensitiviseMap(m map[string]interface{}) {
|
||||
for key, val := range m {
|
||||
lower := strings.ToLower(key)
|
||||
|
@ -119,31 +130,40 @@ func findCWD() (string, error) {
|
|||
return path, nil
|
||||
}
|
||||
|
||||
func marshallConfigReader(in io.Reader, c map[string]interface{}, configType string) {
|
||||
func unmarshallConfigReader(in io.Reader, c map[string]interface{}, configType string) error {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(in)
|
||||
|
||||
switch strings.ToLower(configType) {
|
||||
case "yaml", "yml":
|
||||
if err := yaml.Unmarshal(buf.Bytes(), &c); err != nil {
|
||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
||||
return ConfigParseError{err}
|
||||
}
|
||||
|
||||
case "json":
|
||||
if err := json.Unmarshal(buf.Bytes(), &c); err != nil {
|
||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
||||
return ConfigParseError{err}
|
||||
}
|
||||
|
||||
case "hcl":
|
||||
obj, err := hcl.Parse(string(buf.Bytes()))
|
||||
if err != nil {
|
||||
return ConfigParseError{err}
|
||||
}
|
||||
if err = hcl.DecodeObject(&c, obj); err != nil {
|
||||
return ConfigParseError{err}
|
||||
}
|
||||
|
||||
case "toml":
|
||||
if _, err := toml.Decode(buf.String(), &c); err != nil {
|
||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
||||
return ConfigParseError{err}
|
||||
}
|
||||
|
||||
case "properties", "props", "prop":
|
||||
var p *properties.Properties
|
||||
var err error
|
||||
if p, err = properties.Load(buf.Bytes(), properties.UTF8); err != nil {
|
||||
jww.ERROR.Fatalf("Error parsing config: %s", err)
|
||||
return ConfigParseError{err}
|
||||
}
|
||||
for _, key := range p.Keys() {
|
||||
value, _ := p.Get(key)
|
||||
|
@ -152,6 +172,7 @@ func marshallConfigReader(in io.Reader, c map[string]interface{}, configType str
|
|||
}
|
||||
|
||||
insensitiviseMap(c)
|
||||
return nil
|
||||
}
|
||||
|
||||
func safeMul(a, b uint) uint {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue