chore: move the parser to a dedicated package.

This commit is contained in:
Ludovic Fernandez 2020-08-17 18:04:03 +02:00 committed by GitHub
parent eecc2f4dd7
commit 1502d20def
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
90 changed files with 191 additions and 14278 deletions

View file

@ -5,9 +5,10 @@ import (
"os"
"strings"
"github.com/containous/traefik/v2/pkg/config/file"
"github.com/containous/traefik/v2/pkg/config/flag"
"github.com/containous/traefik/v2/pkg/log"
"github.com/traefik/paerser/cli"
"github.com/traefik/paerser/file"
"github.com/traefik/paerser/flag"
)
// FileLoader loads a configuration from a file.
@ -22,7 +23,7 @@ func (f *FileLoader) GetFilename() string {
}
// Load loads the command's configuration from a file either specified with the -traefik.configfile flag, or from default locations.
func (f *FileLoader) Load(args []string, cmd *Command) (bool, error) {
func (f *FileLoader) Load(args []string, cmd *cli.Command) (bool, error) {
ref, err := flag.Parse(args, cmd.Configuration)
if err != nil {
_ = cmd.PrintHelp(os.Stdout)
@ -64,7 +65,7 @@ func (f *FileLoader) Load(args []string, cmd *Command) (bool, error) {
// loadConfigFiles tries to decode the given configuration file and all default locations for the configuration file.
// It stops as soon as decoding one of them is successful.
func loadConfigFiles(configFile string, element interface{}) (string, error) {
finder := Finder{
finder := cli.Finder{
BasePaths: []string{"/etc/traefik/traefik", "$XDG_CONFIG_HOME/traefik", "$HOME/.config/traefik", "./traefik"},
Extensions: []string{"toml", "yaml", "yml"},
}