示例#1
0
文件: cli.go 项目: rjeczalik/pulsekit
// Artifact is a a command line interface to Artifact method of a pulse.Client.
// It downloads all artifacts captured from given project and build number
func (cli *CLI) Artifact(ctx *cli.Context) {
	var projects []string
	err := cli.init(ctx)
	if err != nil {
		cli.Err(err)
		return
	}
	if cli.p.String() == pulse.ProjectPersonal {
		projects = append(projects, pulse.ProjectPersonal)
	} else if projects, err = cli.c.Projects(); err != nil {
		cli.Err(err)
		return
	}
	var build int64
	dir, url := cli.o.String(), strings.Trim(cli.cred.URL, "/xmlrpc")
	for _, p := range projects {
		if !cli.p.MatchString(p) {
			continue
		}
		if build, err = util.NormalizeBuildOrRequestID(cli.c, p, cli.n); err != nil {
			cli.Err(err)
			return
		}
		if err = cli.c.Artifact(build, p, dir, url); err != nil {
			cli.Err(err)
			return
		}
	}
}
示例#2
0
文件: cli.go 项目: rjeczalik/pulsekit
// Wait TODO(rjeczalik): document
func (cli *CLI) Wait(ctx *cli.Context) {
	if err := cli.init(ctx); err != nil {
		cli.Err(err)
		return
	}
	p := cli.p.String()
	if p == "" || p == ".*" {
		cli.Err("pulsecli: a --project name is missing")
		return
	}
	id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
	if err != nil {
		cli.Err(err)
		return
	}
	select {
	case <-time.After(cli.d):
		err = pulse.ErrTimeout
	case err = <-util.Wait(cli.c, time.Second, p, id):
	}
	if err != nil {
		cli.Err(err)
		return
	}
}
示例#3
0
文件: cli.go 项目: rjeczalik/pulsekit
// Status is a command line interface to a BuildResult methos of a pulse.Client.
// It outputs []BuildResult for every requested project in an YAML format.
func (cli *CLI) Status(ctx *cli.Context) {
	err := cli.init(ctx)
	if err != nil {
		cli.Err(err)
		return
	}
	var p []string
	if cli.p.String() == pulse.ProjectPersonal {
		p = append(p, pulse.ProjectPersonal)
	} else if p, err = cli.c.Projects(); err != nil {
		cli.Err(err)
		return
	}
	m := make(map[string][]pulse.BuildResult)
	for _, p := range p {
		if !cli.p.MatchString(p) {
			continue
		}
		id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
		if err != nil {
			cli.Err(err)
			return
		}
		b, err := cli.c.BuildResult(p, id)
		if err != nil {
			cli.Err(err)
			return
		}
		m[fmt.Sprintf("%s (build %d)", p, id)] = b
	}
	y, err := yaml.Marshal(m)
	if err != nil {
		cli.Err(err)
		return
	}
	cli.Out(string(y))
}
示例#4
0
文件: cli.go 项目: rjeczalik/pulsekit
func (cli *CLI) healthProject(ctx *cli.Context) {
	p, err := cli.c.Projects()
	if err != nil {
		cli.Err(err)
		return
	}
	all := make(map[string]pulse.Messages)
	for _, p := range p {
		if !cli.p.MatchString(p) {
			continue
		}
		id, err := util.NormalizeBuildOrRequestID(cli.c, p, cli.n)
		if err != nil {
			cli.Err(err)
			return
		}
		m, err := cli.c.Messages(p, id)
		if err != nil {
			cli.Err(err)
			return
		}
		if m = m.FilterOut(pulse.Info); len(m) > 0 {
			all[fmt.Sprintf("%s (build %d)", p, id)] = m
		}
	}
	if len(all) == 0 {
		cli.Out()
	} else {
		y, err := yaml.Marshal(all)
		if err != nil {
			cli.Err(err)
			return
		}
		cli.Err(string(y))
	}
}