Example #1
0
func newImageBuilder(c *Context) github.ImageBuilder {
	builder := c.String(FlagGithubDeploymentsImageBuilder)

	switch builder {
	case "template":
		tmpl := template.Must(template.New("image").Parse(c.String(FlagGithubDeploymentsImageTemplate)))
		return github.ImageFromTemplate(tmpl)
	case "conveyor":
		s := conveyor.NewService(conveyor.DefaultClient)
		s.URL = c.String(FlagConveyorURL)
		return github.NewConveyorImageBuilder(s)
	default:
		panic(fmt.Sprintf("unknown image builder: %s", builder))
	}
}
Example #2
0
func newClient(t testing.TB) *Client {
	c := newConveyor(t)
	s := httptest.NewServer(server.NewServer(c.Conveyor, server.Config{
		APIAuth: func(h http.Handler) http.Handler { return h },
	}))

	cl := conveyor.NewService(conveyor.DefaultClient)
	cl.URL = s.URL

	return &Client{
		Service: cl,
		s:       s,
		c:       c,
	}
}