github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/filelocation/misc.go (about)

     1  package filelocation
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  )
     7  
     8  // SystemConfigDirs returns a list of directories to look for configuration files in.  The list is
     9  // ordered in highest-precedence to lowest-precedence.  Every one of these directories is however
    10  // lower precedence than UserConfigdir.
    11  //
    12  // This returns the value of the $XDG_CONFIG_DIRS environment variable if non-empty, or else
    13  // "/etc/xdg".
    14  //
    15  // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
    16  //
    17  // FIXME(lukeshu): Consider having SystemConfigDirs do something different on darwin/windows/plan9.
    18  //
    19  // FIXME(lukeshu): Consider having SystemConfigDirs vary depending on the installation prefix.
    20  func systemConfigDirs() []string {
    21  	str := os.Getenv("XDG_CONFIG_DIRS")
    22  	if str == "" {
    23  		str = "/etc/xdg"
    24  	}
    25  	return filepath.SplitList(str)
    26  }