// GetConfigFilePath gets the full path to the given config file name.
196520
func GetConfigFilePath(file string) (string, error) {
	if configPath := os.Getenv("XDG_CONFIG_HOME"); configPath != "" {
		return path.Join(configPath, configDir, file), nil
	}

	userHomeDir := getUserHomeDir()

	if runtime.GOOS == "linux" {
		return path.Join(userHomeDir, ".config", configDir, file), nil
	}
	return path.Join(userHomeDir, configDirHidden, file), nil
}
1171495
func LocalConfigFileAbsolutePath() (string, error) {
	configDir, err := LocalConfigDirectoryAbsolutePath()
	if err != nil {
		return "", err
	}
	return filepath.Join(configDir, LocalConfigFilename), nil
}
1366054
func (c *ConfigFile) Filename() string {
	rw, err := NewConfigReadWriter(c.version)
	if err != nil {
		return ""
	}
	return rw.Filename(c)
}
637520
func (c Config) GetEnginePath(base string) string {
	if c.EnginePath != "" {
		return c.EnginePath
	}
	return filepath.Join(base, DefaultEngineDirectoryName)
}
692056
func ExpandConfigPath(path, defaultPath string) (string, error) {
	if path != "" {
		return ExpandPath(path, false)
	}

	configHome := lookupConfigHome()
	if configHome != "" {
		return filepath.Join(configHome, defaultPath), nil
	}

	return ExpandPath(fmt.Sprintf("~/.config/%s", defaultPath), false)
}
615479
func (c *Config) LoadConfigFromFilePath(filePath string) (err error) {
	if strings.Index(filePath, "~/") == 0 {
		filePath = strings.Replace(filePath, "~/", getHome()+"/", 1)
	}

	yamlString, err := ioutil.ReadFile(filePath)
	if err != nil {
		logger.Errorf(nil, "File not found: %s.", filePath)
		return err
	}

	return c.LoadConfigFromContent(yamlString)
}
649605
func (s *storeImpl) GetConfigFiles(ctx datastore.Context, tenantID string, svcPath string) ([]*SvcConfigFile, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceConfigFileStore.GetConfigFiles"))

	size := 20
	from := 0
	var confs []*SvcConfigFile

	for {
		search := search.Search("controlplane").Type(kind).Filter(
			"and",
			search.Filter().Terms("ServiceTenantID", tenantID),
			search.Filter().Terms("ServicePath", svcPath),
		).From(strconv.Itoa(from)).Size(strconv.Itoa(size))

		q := datastore.NewQuery(ctx)

		results, err := q.Execute(search)
		if err != nil {
			return nil, err
		}

		conv, err := convert(results)
		if err != nil {
			return nil, err
		} else if len(conv) == 0 {
			return confs, nil
		}

		from += size
		confs = append(confs, conv...)
	}
}
1348547
func (conf *Config) GetInitPath() string {
	conf.Lock()
	defer conf.Unlock()
	if conf.InitPath != "" {
		return conf.InitPath
	}
	if conf.DefaultInitBinary != "" {
		return conf.DefaultInitBinary
	}
	return DefaultInitBinary
}
583694
func GetConfigHome() (string, error) {
	if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
		return xdgConfigHome, nil
	}
	home := os.Getenv("HOME")
	if home == "" {
		return "", errors.New("could not get either XDG_CONFIG_HOME or HOME")
	}
	return filepath.Join(home, ".config"), nil
}
1067635
func LoadConfigDir(dir string) (*Config, error) {
	f, err := os.Open(dir)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	fi, err := f.Stat()
	if err != nil {
		return nil, err
	}
	if !fi.IsDir() {
		return nil, fmt.Errorf(
			"configuration path must be a directory: %s", dir)
	}

	var files []string
	err = nil
	for err != io.EOF {
		var fis []os.FileInfo
		fis, err = f.Readdir(128)
		if err != nil && err != io.EOF {
			return nil, err
		}

		for _, fi := range fis {
			// Ignore directories
			if fi.IsDir() {
				continue
			}

			// Only care about files that are valid to load.
			name := fi.Name()
			skip := true
			if strings.HasSuffix(name, ".hcl") {
				skip = false
			} else if strings.HasSuffix(name, ".json") {
				skip = false
			}
			if skip || isTemporaryFile(name) {
				continue
			}

			path := filepath.Join(dir, name)
			files = append(files, path)
		}
	}

	// Fast-path if we have no files
	if len(files) == 0 {
		return &Config{}, nil
	}

	sort.Strings(files)

	var result *Config
	for _, f := range files {
		config, err := ParseConfigFile(f)
		if err != nil {
			return nil, fmt.Errorf("Error loading %s: %s", f, err)
		}
		config.Files = append(config.Files, f)

		if result == nil {
			result = config
		} else {
			result = result.Merge(config)
		}
	}

	return result, nil
}
839806
func (api *API) GetVPNConfigFile(filepath string, vpn_id string) (string, error) {
	result := new(configZipFile)
	url := createUrl(api, vpnPathSegment, vpn_id, "configuration_file")
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return "", err
	}
	filestring, err := base64.StdEncoding.DecodeString(result.Base64String)
	d1 := []byte(filestring)
	fileErr := ioutil.WriteFile(filepath+".zip", d1, 0644)
	check(fileErr)

	return result.Base64String, nil
}
311935
func ReadConfigFile(cliConfigPath string) (*FileConfig, error) {
	configFilePath := defaults.ConfigFilePath
	// --config tells us to use a specific conf. file:
	if cliConfigPath != "" {
		configFilePath = cliConfigPath
		if !fileExists(configFilePath) {
			return nil, trace.Errorf("file not found: %s", configFilePath)
		}
	}
	// default config doesn't exist? quietly return:
	if !fileExists(configFilePath) {
		log.Info("not using a config file")
		return nil, nil
	}
	log.Debug("reading config file: ", configFilePath)
	return ReadFromFile(configFilePath)
}
1168450
func GetKubeConfigPath() string {
	kubeConfigEnv := os.Getenv(constants.KubeconfigEnvVar)
	if kubeConfigEnv == "" {
		return constants.KubeconfigPath
	}
	return filepath.SplitList(kubeConfigEnv)[0]
}
1179039
func (a App) ConfigPath(file string) string {
	return a.path("XDG_CONFIG_HOME", ConfigHome, file)
}
396362
func GetKubeConfigPath() string {
	kubeconfig := os.Getenv(clientcmd.RecommendedConfigPathEnvVar)
	if kubeconfig == "" {
		kubeconfig = clientcmd.RecommendedHomeFile
	}
	logger.Debugf("The kubeconfig file path: %q", kubeconfig)
	return kubeconfig
}
910893
func LoadConfigFile(path string, logger log.Logger) (*Config, error) {
	// Read the file
	d, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	return ParseConfig(string(d), logger)
}
14365
func GetConfigurationDir() (string, error) {
	gaugeHome := os.Getenv(GaugeHome)
	if gaugeHome != "" {
		return filepath.Join(gaugeHome, config), nil
	}

	var configDir string

	if isWindows() {
		appDataPath := os.Getenv(appData)
		if appDataPath == "" {
			return "", fmt.Errorf("Cannot locate gauge shared file. Could not find App Data directory.")
		}
		configDir = filepath.Join(appDataPath, ProductName, config)
	} else {
		home := os.Getenv("HOME")
		configDir = filepath.Join(home, DotGauge, config)
	}

	if configDir != "" {
		return configDir, nil
	}

	return "", fmt.Errorf("Can't find configuration files")
}