func runBuild(c *cli.Context) { client := api.NewClient(c.String("url")) opts := api.CreateFlowOptions{ Name: api.NewString("test"), } flow, err := client.CreateFlow(opts) if err != nil { log.Fatal("Fail to create flow: %v", err) } _ = flow }
func runWeb(c *cli.Context) { if err := models.InitDb(); err != nil { log.Fatal("Fail to init DB: %v", err) } if c.IsSet("port") { setting.HTTPPort = c.Int("port") } bindIgnErr := binding.BindIgnErr m := macaron.New() m.Use(macaron.Logger()) m.Use(macaron.Recovery()) m.Use(macaron.Renderer(macaron.RenderOptions{ IndentJSON: !setting.ProdMode, })) m.Use(web.Contexter()) group := func() { m.Group("/flows", func() { m.Combo("").Get(web.Flows). Post(bindIgnErr(api.CreateFlowOptions{}), web.CreateFlow) m.Combo("/:uuid").Get(web.GetFlow). Post(bindIgnErr(api.CreateFlowOptions{}), web.UpdateFlow). Delete(web.DeleteFlow) }) m.Group("/pipelines", func() { m.Combo("").Get(web.Pipelines). Post(bindIgnErr(api.CreatePipelineOptions{}), web.CreatePipeline) m.Combo("/:uuid").Get(web.GetPipeline). Post(bindIgnErr(api.CreatePipelineOptions{}), web.UpdatePipeline). Delete(web.DeletePipeline) }) m.Group("/stages", func() { m.Combo("").Get(web.Stages). Post(bindIgnErr(api.CreateStageOptions{}), web.CreateStage) m.Combo("/:uuid").Get(web.GetStage). Post(bindIgnErr(api.CreateStageOptions{}), web.UpdateStage). Delete(web.DeleteStage) }) m.Group("/jobs", func() { m.Combo("").Get(web.Jobs). Post(bindIgnErr(api.CreateJobOptions{}), web.CreateJob) m.Combo("/:uuid").Get(web.GetJob). Post(bindIgnErr(api.CreateJobOptions{}), web.UpdateJob). Delete(web.DeleteJob) }) m.Post("/build", web.Build) } m.Group("", group) m.Group("/v1", group) listenAddr := fmt.Sprintf("0.0.0.0:%d", setting.HTTPPort) log.Info("Vessel %s %s", setting.AppVer, listenAddr) if err := http.ListenAndServe(listenAddr, m); err != nil { log.Fatal("Fail to start web server: %v", err) } }