1
0
mirror of https://github.com/containous/traefik.git synced 2025-01-07 17:17:53 +03:00
traefik/pkg/cli/loader_flag.go

27 lines
612 B
Go
Raw Normal View History

package cli
import (
"fmt"
2019-08-03 04:58:23 +03:00
"github.com/containous/traefik/v2/pkg/config/flag"
"github.com/containous/traefik/v2/pkg/log"
)
// FlagLoader loads configuration from flags.
type FlagLoader struct{}
// Load loads the command's configuration from flag arguments.
func (*FlagLoader) Load(args []string, cmd *Command) (bool, error) {
2019-06-24 17:40:06 +03:00
if len(args) == 0 {
return false, nil
}
if err := flag.Decode(args, cmd.Configuration); err != nil {
return false, fmt.Errorf("failed to decode configuration from flags: %v", err)
}
log.WithoutContext().Println("Configuration loaded from flags.")
return true, nil
}