示例#1
0
func RequireVersion(r *version.R) {
	vs := cmd.Table("docker", "--version")[0][2]
	vs = strings.Trim(vs, ",")
	v := version.Version(vs)
	if !r.IsSatisfiedBy(v) {
		cli.Fatalf("got docker version %s; want %s", v, r)
	}
}
示例#2
0
func Layers(image string) []string {
	t := cmd.Table("docker", "history", "--no-trunc", image)
	layers := make([]string, len(t))
	for i, r := range t {
		layers[i] = r[0]
	}
	return layers
}
示例#3
0
文件: git.go 项目: liamjbennett/sous
func RequireVersion(r *version.R) {
	if c := cmd.ExitCode("git", "--version"); c != 0 {
		cli.Fatalf("git required")
	}
	v := version.Version(cmd.Table("git", "--version")[0][2])
	if !r.IsSatisfiedBy(v) {
		cli.Fatalf("you have git version %s; want %s", v, r.Original)
	}
}
示例#4
0
func ImageExists(tag string) bool {
	rows := cmd.Table("docker", "images")
	for _, r := range rows {
		comp := r[0] + ":" + r[1]
		if comp == tag {
			return true
		}
	}
	return false
}
示例#5
0
文件: sous.go 项目: liamjbennett/sous
func (s *Sous) LsImages(c *Context) []*docker.Image {
	labelFilter := fmt.Sprintf("label=%s.build.package.name=%s", s.Config.DockerLabelPrefix, c.CanonicalPackageName())
	results := cmd.Table("docker", "images", "--filter", labelFilter)
	// The first line is just table headers
	if len(results) < 2 {
		return nil
	}
	results = results[1:]
	images := make([]*docker.Image, len(results))
	for i, row := range results {
		images[i] = docker.NewImage(row[0], row[1])
	}
	return images
}
示例#6
0
文件: sous.go 项目: liamjbennett/sous
func (s *Sous) LsContainers(c *Context) []docker.Container {
	labelFilter := fmt.Sprintf("label=%s.build.package.name=%s", s.Config.DockerLabelPrefix, c.CanonicalPackageName())
	results := cmd.Table("docker", "ps", "-a", "--filter", labelFilter)
	// The first line is just table headers
	if len(results) < 2 {
		return nil
	}
	results = results[1:]
	containers := make([]docker.Container, len(results))
	for i, row := range results {
		nameIndex := len(row) - 1
		containers[i] = docker.NewContainer(row[0], row[nameIndex])
	}
	return containers
}
示例#7
0
文件: git.go 项目: liamjbennett/sous
func getOriginURL() *url.URL {
	table := cmd.Table("git", "remote", "-v")
	if len(table) == 0 {
		cli.Fatalf("no git remotes set up")
	}
	for _, row := range table {
		if row[0] == "origin" {
			u, err := url.Parse(row[1])
			if err != nil {
				cli.Fatalf("unable to parse origin (%s) as URL; %s", row[1], err)
			}
			return u
		}
	}
	return nil
}