func findConfigPath(topDir string) (configPath string, err error) {
	configTestPath := filepath.Join(topDir, ConfigFileName)
	_, err = os.Stat(configTestPath)
	if err != nil && os.IsNotExist(err) && filepath.Clean(topDir) != "/" {
		configPath, err = findConfigPath(filepath.Join(topDir, ".."))
	} else if err != nil && os.IsNotExist(err) {
		err = fmt.Errorf("No config file '%s' found in current or parent directories", ConfigFileName)
	} else if err != nil {
		err = fmt.Errorf("Failed to find config file '%s': %s", ConfigFileName, err)
	} else {
		configPath = configTestPath
	}
	return
}
findConfigPath recursively searches for a config file starting at topDir, ending at fs root
package internal
import (
	"encoding/json"
	"fmt"
	"os"
	"path/filepath"
)
const ConfigFileName = "ahab.json"
const UserConfigFilePath = ".config/ahab/config.json"
var Version string
type Configuration struct {
	AhabVersion       string            `json:"ahab"`
	BuildContext      string            `json:"buildContext"`
	Command           string            `json:"command"`
	Dockerfile        string            `json:"dockerfile"`
	Entrypoint        string            `json:"entrypoint"`
	Environment       []string          `json:"environment"`
	Hostname          string            `json:"hostname"`
	ImageURI          string            `json:"image"`
	Init              []string          `json:"init"`
	Name              string            `json:"name"`
	Options           []string          `json:"options"`
	Permissions       PermConfiguration `json:"permissions"`
	RestartAfterSetup bool              `json:"restartAfterSetup"`
	ShareDisplay      bool              `json:"shareDisplay"`
	User              string            `json:"user"`
	Volumes           []string          `json:"volumes"`
	Workdir           string            `json:"workdir"`
}
type UserConfiguration struct {
	Environment  []string `json:"environment"`
	Options      []string `json:"options"`
	HideCommands bool     `json:"hideCommands"`
	Volumes      []string `json:"volumes"`
}
type PermConfiguration struct {
	CmdSet  string   `json:"cmdSet"`
	Disable bool     `json:"disable"`
	Groups  []string `json:"groups"`
}
func UserConfig() (userConfig *UserConfiguration, err error) {
	homeDir, err := os.UserHomeDir()
	if err != nil {
		err = fmt.Errorf("Failed to get user home directory: %s", err)
		return
	}
	configPath := filepath.Join(homeDir, UserConfigFilePath)
	configFile, err := os.Open(configPath)
	if err != nil && os.IsNotExist(err) {
		var blankConfig UserConfiguration
		return &blankConfig, nil
	}
	defer configFile.Close()
	decoder := json.NewDecoder(configFile)
	if err = decoder.Decode(&userConfig); err != nil {
		err = fmt.Errorf("Failed to parse user config file: %s", err)
	}
	return
}
func checkConfigVersion(configVersion string) error {
	configVersionOrd, err := versionOrdinal(configVersion)
	if err != nil {
		return err
	}
	selfVersionOrd, err := versionOrdinal(Version)
	if err != nil {
		return err
	}
	if configVersionOrd > selfVersionOrd {
		return fmt.Errorf("Config file requires ahab >= %s (your version: %s)", configVersion, Version)
	}
	return nil
}