Exemplo n.º 1
0
func push_image(image string) error {
	command := fmt.Sprintf(
		"docker push %s", image)

	exitcode, out := utils.RunCmd(command)
	if exitcode != 0 {
		fmt.Fprintln(os.Stderr, out)

		return errors.New(fmt.Sprintf("Could not push %s", image))
	}

	return nil
}
Exemplo n.º 2
0
func tag_image(image_name string, new_image_name string) error {
	command := fmt.Sprintf(
		"docker tag %s %s",
		image_name,
		new_image_name)

	exitcode, out := utils.RunCmd(command)
	if exitcode != 0 {
		fmt.Fprintln(os.Stderr, out)

		return errors.New(fmt.Sprintf(
			"Could not retag %s to %s",
			image_name,
			new_image_name))
	}

	return nil
}
Exemplo n.º 3
0
		panic(err)
	}
	return dir
}

func detectProjectName() string {
	dir := getAbsFilePath()
	if project := string(filepath.Base(dir)); project == "/" {
		return "noname"
	} else {
		return project
	}
}

var runCmd = func(command string) (int, string) {
	return utils.RunCmd(command)
}

var getGitRepoPresent = func() (bool, error) {
	exitcode, out := runCmd("git rev-parse --short HEAD")
	if exitcode == 127 {
		return false, errors.New("No git executable found")
	} else if exitcode == 128 {
		return false, errors.New("Not a git repository")
	} else if exitcode != 0 {
		return false, errors.New(out)
	}
	return true, nil
}

var getGitSemverTag = func() (string, error) {