1
0
Fork 0

Support YAML for the dynamic configuration.

This commit is contained in:
Ludovic Fernandez 2019-06-26 18:18:04 +02:00 committed by Traefiker Bot
parent 96962dd21f
commit e69d4cba88
36 changed files with 1529 additions and 289 deletions

View file

@ -5,6 +5,7 @@ import (
"io/ioutil"
"path/filepath"
"reflect"
"strings"
"github.com/BurntSushi/toml"
"github.com/containous/traefik/pkg/config/parser"
@ -22,7 +23,7 @@ func decodeFileToNode(filePath string, filters ...string) (*parser.Node, error)
data := make(map[string]interface{})
switch filepath.Ext(filePath) {
switch strings.ToLower(filepath.Ext(filePath)) {
case ".toml":
err = toml.Unmarshal(content, &data)
if err != nil {
@ -30,14 +31,11 @@ func decodeFileToNode(filePath string, filters ...string) (*parser.Node, error)
}
case ".yml", ".yaml":
var err error
err = yaml.Unmarshal(content, data)
if err != nil {
return nil, err
}
return decodeRawToNode(data, parser.DefaultRootName, filters...)
default:
return nil, fmt.Errorf("unsupported file extension: %s", filePath)
}