k3s/pkg/configfilearg/defaultparser.go
Derek Nola 918945da45
Added configuration input to etcd-snapshot (#4280)
Signed-off-by: dereknola <derek.nola@suse.com>
2021-10-22 12:03:32 -07:00

35 lines
863 B
Go

package configfilearg
import (
"github.com/rancher/k3s/pkg/version"
"github.com/sirupsen/logrus"
)
func MustParse(args []string) []string {
parser := &Parser{
After: []string{"server", "agent", "etcd-snapshot"},
FlagNames: []string{"--config", "-c"},
EnvName: version.ProgramUpper + "_CONFIG_FILE",
DefaultConfig: "/etc/rancher/" + version.Program + "/config.yaml",
}
result, err := parser.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
}