mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
332fd73d46
* Add support for both config-file and data-dir at a global level in the self-extracting wrapper for K3s Signed-off-by: Chris Kim <oats87g@gmail.com>
35 lines
846 B
Go
35 lines
846 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"},
|
|
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
|
|
}
|