Skip to content

Commit 7ba5868

Browse files
author
Oleg Sucharevich
committed
breaking change, run pipeline now accept RunOptions, pass nil to keep backward competibility
1 parent 3fadcb9 commit 7ba5868

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.0
1+
0.7.0

cmd/run_pipeline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var runPipelineCmd = &cobra.Command{
4040
client := viper.Get("codefresh")
4141
codefreshClient := utils.CastToCodefreshOrDie(client)
4242
for _, name := range args {
43-
build, err := codefreshClient.Pipelines().Run(name)
43+
build, err := codefreshClient.Pipelines().Run(name, nil)
4444
internal.DieOnError(err)
4545
fmt.Printf("Pipeline started with ID: %s\n", build)
4646
}

pkg/codefresh/pipeline.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type (
1010
// IPipelineAPI declers Codefresh pipeline API
1111
IPipelineAPI interface {
1212
List() ([]*Pipeline, error)
13-
Run(string) (string, error)
13+
Run(string, *RunOptions) (string, error)
1414
}
1515

1616
PipelineMetadata struct {
@@ -62,6 +62,11 @@ type (
6262
pipeline struct {
6363
codefresh Codefresh
6464
}
65+
66+
RunOptions struct {
67+
Branch string
68+
Variables map[string]string
69+
}
6570
)
6671

6772
func newPipelineAPI(codefresh Codefresh) IPipelineAPI {
@@ -79,10 +84,18 @@ func (p *pipeline) List() ([]*Pipeline, error) {
7984
return r.Docs, err
8085
}
8186

82-
func (p *pipeline) Run(name string) (string, error) {
87+
func (p *pipeline) Run(name string, options *RunOptions) (string, error) {
88+
variables := []string{}
89+
for k, v := range options.Variables {
90+
variables = append(variables, fmt.Sprintf("%s=%s", k, v))
91+
}
8392
resp, err := p.codefresh.requestAPI(&requestOptions{
8493
path: fmt.Sprintf("/api/pipelines/run/%s", url.PathEscape(name)),
8594
method: "POST",
95+
body: map[string]interface{}{
96+
"branch": options.Branch,
97+
"variables": variables,
98+
},
8699
})
87100
if err != nil {
88101
return "", err

0 commit comments

Comments
 (0)