Esempio n. 1
0
// expandAndValidateConfig takes the initial Config and expands the other variables
// sets defaults etc.
func expandAndValidateConfig(config *Config) error {
	if config.Base == "" {
		return fmt.Errorf("Missing required 'Base' configuration item to the Parity Template")
	}
	if config.Version == "" {
		log.Warn("Missing required 'Version' configuration item to the Parity Template. Defaults to 'latest'")
		config.Version = "latest"
	}
	if config.TemplateSourceName == "" && config.TemplateSourceURL == "" {
		return fmt.Errorf("Must provide one of 'TemplateSourceName' or 'TemplateSourceURL' to the Parity Template")
	}
	if config.TemplateSourceName != "" && config.TemplateSourceURL != "" {
		return fmt.Errorf("Must provide only one of 'TemplateSourceName' or 'TemplateSourceURL' to the Parity Template")
	}
	if config.TemplateSourceURL != "" {
		config.templateIndex = fmt.Sprintf("%s/index.txt", config.TemplateSourceURL)
	}
	if config.TemplateSourceName != "" {
		url, err := getDefaultTemplateUrl(config.TemplateSourceName)
		if err == nil {
			config.TemplateSourceURL = url
			config.templateIndex = fmt.Sprintf("%s/index.txt", url)
		} else {
			return err
		}
	}
	if config.Ci == "" {
		config.Ci = fmt.Sprintf("%s-ci", config.Base)
	}
	if config.Dist == "" {
		config.Dist = fmt.Sprintf("%s-dist", config.Base)
	}
	return nil
}
Esempio n. 2
0
// CheckSharedFolders seturn true if shared folders exist and the user agrees to removing them
func CheckSharedFolders() bool {
	shares := FindSharedFolders()
	if len(shares) > 0 {
		log.Warn("For Parity to operate properly, Virtualbox shares must be removed. Parity will automatically do this for you")
		return true
	}
	return false
}
Esempio n. 3
0
// FindSharedFolders gets the list of shared folders on the remote Docker Host
func FindSharedFolders() []string {
	sharesRes, err := RunCommandAndReturn(DockerHost(), "mount | grep 'type vboxsf' | awk '{print $3}'")
	if err != nil {
		log.Warn("Unable to determine Virtualbox shared folders, please manually ensure shared folders are removed to ensure proper operation of Parity")
	}
	var shares []string
	for _, s := range strings.Split(sharesRes, "\n") {
		if s != "" {
			shares = append(shares, s)
		}
	}
	return shares
}