Skip to content

Commit 55e8665

Browse files
author
Oleg Sucharevich
authored
Merge pull request #2 from funkycode/master
Fix the example of the code to get pipelines in README file
2 parents 3d05f48 + de3183f commit 55e8665

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
`go get -u github.com/codefresh-io/go-sdk`
1010

1111
```go
12-
1312
import (
1413
"fmt"
1514
"os"
@@ -20,10 +19,24 @@ import (
2019

2120
func main() {
2221
path := fmt.Sprintf("%s/.cfconfig", os.Getenv("HOME"))
23-
options := utils.ReadAuthContext(path, "")
24-
cf := codefresh.New(options)
25-
cf.Pipelines().List()
22+
options, err := utils.ReadAuthContext(path, "")
23+
if err != nil {
24+
fmt.Println("Failed to read codefresh config file")
25+
panic(err)
26+
}
27+
clientOptions := codefresh.ClientOptions{Host: options.URL,
28+
Auth: codefresh.AuthOptions{Token: options.Token}}
29+
cf := codefresh.New(&clientOptions)
30+
pipelines, err := cf.Pipelines().List()
31+
if err != nil {
32+
fmt.Println("Failed to get Pipelines from Codefresh API")
33+
panic(err)
34+
}
35+
for _, p := range pipelines {
36+
fmt.Printf("Pipeline: %+v\n\n", p)
37+
}
2638
}
39+
2740
```
2841

29-
This is not an official Codefresh project.
42+
This is not an official Codefresh project.

0 commit comments

Comments
 (0)