You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
k3s/pkg/datadir/datadir.go

31 lines
523 B

package datadir
import (
"os"
"github.com/pkg/errors"
"github.com/rancher/norman/pkg/resolvehome"
)
const (
DefaultDataDir = "/var/lib/rancher/k3s"
DefaultHomeDataDir = "${HOME}/.rancher/k3s"
)
func Resolve(dataDir string) (string, error) {
if dataDir == "" {
if os.Getuid() == 0 {
dataDir = DefaultDataDir
} else {
dataDir = DefaultHomeDataDir
}
}
dataDir, err := resolvehome.Resolve(dataDir)
if err != nil {
return "", errors.Wrapf(err, "resolving %s", dataDir)
}
return dataDir, nil
}