From 14451bd4863c989f1fb96964d6fd42e88de92cd8 Mon Sep 17 00:00:00 2001 From: Oleg Sucharevich Date: Fri, 28 Dec 2018 22:21:47 +0200 Subject: [PATCH] support run pipeline interface --- cmd/root.go | 1 - pkg/codefresh/pipeline.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 42279d2..bd9b23f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -30,7 +30,6 @@ var cfgFile string var rootCmd = &cobra.Command{ Use: "cfctl", Short: "A command line application for Codefresh", - Long: ``, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { configPath := cmd.Flag("cfconfig").Value.String() diff --git a/pkg/codefresh/pipeline.go b/pkg/codefresh/pipeline.go index c6a5eda..b0d03b2 100644 --- a/pkg/codefresh/pipeline.go +++ b/pkg/codefresh/pipeline.go @@ -1,6 +1,8 @@ package codefresh import ( + "fmt" + "net/url" "time" ) @@ -8,6 +10,7 @@ type ( // IPipelineAPI declers Codefresh pipeline API IPipelineAPI interface { GetPipelines() []*Pipeline + RunPipeline(string) string } PipelineMetadata struct { @@ -67,3 +70,11 @@ func (c *codefresh) GetPipelines() []*Pipeline { resp.JSON(r) return r.Docs } + +func (c *codefresh) RunPipeline(name string) string { + resp := c.requestAPI(&requestOptions{ + path: fmt.Sprintf("/api/pipelines/run/%s", url.PathEscape(name)), + method: "POST", + }) + return resp.String() +}