Exemple #1
0
// DefaultRunner is the default function used to run commands. It calls
// os/exec.Run so that stdout and stderr are written to the terminal.
// DefaultRunner also logs all executed commands.
func DefaultRunner(args []string) error {
	log.Debugf("exec: %s\n", strings.Join(args, " "))
	cmd := goexec.Command(args[0], args[1:]...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	return cmd.Run()
}
Exemple #2
0
func readInstanceConfig(instance string) (*instanceConfig, error) {
	configFile := path.Join(".kitchen", instance+".yml")
	log.Debugf("Kitchen config file = %s\n", configFile)

	data, err := ioutil.ReadFile(configFile)
	if err != nil {
		return nil, err
	}

	var config instanceConfig
	if err := yaml.Unmarshal(data, &config); err != nil {
		return nil, err
	}
	log.Debugf("Kitchen config = %+v\n", config)

	return &config, nil
}
Exemple #3
0
func (i Installer) writeOmnibusScript() error {
	script := path.Join(i.SandboxPath, "install.sh")
	log.Debugf("Writing Omnibus script to %s\n", script)
	data, err := Asset("assets/install.sh")
	if err != nil {
		return err
	}
	return ioutil.WriteFile(script, []byte(data), 0644)
}
Exemple #4
0
func findInstanceName(instance string) (string, error) {
	instanceNames, err := readInstanceNames()
	if err != nil {
		return "", err
	}
	log.Debugf("Kitchen instances = %s\n", instanceNames)

	for _, name := range instanceNames {
		// Return first match
		if strings.Contains(name, instance) {
			return name, nil
		}
	}
	return "", errors.New("Kitchen instance not found")
}