traefik/pkg/cli/loader_flag.go

27 lines
612 B
Go
Raw Normal View History

package cli
import (
"fmt"
2019-08-03 01:58:23 +00: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 14:40:06 +00: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
}