mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
9a849b1bb7
* changing package to k3s-io Signed-off-by: Luther Monson <luther.monson@gmail.com> Co-authored-by: Derek Nola <derek.nola@suse.com>
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package configfilearg
|
|
|
|
import (
|
|
"github.com/k3s-io/k3s/pkg/cli/cmds"
|
|
"github.com/k3s-io/k3s/pkg/version"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var DefaultParser = &Parser{
|
|
After: []string{"server", "agent", "etcd-snapshot:1"},
|
|
FlagNames: []string{"--config", "-c"},
|
|
EnvName: version.ProgramUpper + "_CONFIG_FILE",
|
|
DefaultConfig: "/etc/rancher/" + version.Program + "/config.yaml",
|
|
ValidFlags: map[string][]cli.Flag{"server": cmds.ServerFlags, "etcd-snapshot": cmds.EtcdSnapshotFlags},
|
|
}
|
|
|
|
func MustParse(args []string) []string {
|
|
result, err := DefaultParser.Parse(args)
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func MustFindString(args []string, target string) string {
|
|
parser := &Parser{
|
|
After: []string{},
|
|
FlagNames: []string{},
|
|
EnvName: version.ProgramUpper + "_CONFIG_FILE",
|
|
DefaultConfig: "/etc/rancher/" + version.Program + "/config.yaml",
|
|
}
|
|
result, err := parser.FindString(args, target)
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
return result
|
|
}
|