2020-08-30 03:30:07 +00:00
|
|
|
package configfilearg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rancher/k3s/pkg/version"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func MustParse(args []string) []string {
|
|
|
|
parser := &Parser{
|
|
|
|
After: []string{"server", "agent"},
|
|
|
|
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
|
|
|
|
}
|
2020-12-16 17:27:57 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|