Skip to content

Commit fc18af8

Browse files
author
Oleg Sucharevich
authored
Merge pull request #5 from pchico83/get
Add GET endpoint and deserialize more info about builds
2 parents 1be6174 + 05a1121 commit fc18af8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.19.0
1+
0.19.1

pkg/codefresh/workflow.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,46 @@ import (
99
type (
1010
IWorkflowAPI interface {
1111
WaitForStatus(string, string, time.Duration, time.Duration) error
12+
Get(string) (*Workflow, error)
1213
}
1314

1415
workflow struct {
1516
codefresh Codefresh
1617
}
1718

1819
Workflow struct {
19-
ID string `json:"id"`
20-
Status string `json:"status"`
20+
ID string `json:"id"`
21+
Status string `json:"status"`
22+
UserYamlDescriptor string `json:"userYamlDescriptor"`
23+
Progress string `json:"progress"`
24+
Created time.Time `json:"created"`
25+
Updated time.Time `json:"updated"`
26+
Finished time.Time `json:"finished"`
2127
}
2228
)
2329

2430
func newWorkflowAPI(codefresh Codefresh) IWorkflowAPI {
2531
return &workflow{codefresh}
2632
}
2733

34+
func (w *workflow) Get(id string) (*Workflow, error) {
35+
wf := &Workflow{}
36+
resp, err := w.codefresh.requestAPI(&requestOptions{
37+
path: fmt.Sprintf("/api/builds/%s", id),
38+
method: "GET",
39+
})
40+
// failed in api call
41+
if err != nil {
42+
return nil, err
43+
}
44+
err = w.codefresh.decodeResponseInto(resp, wf)
45+
// failed to decode
46+
if err != nil {
47+
return nil, err
48+
}
49+
return wf, nil
50+
}
51+
2852
func (w *workflow) WaitForStatus(id string, status string, interval time.Duration, timeout time.Duration) error {
2953
err := waitFor(interval, timeout, func() (bool, error) {
3054

0 commit comments

Comments
 (0)