Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.19.0
0.19.1
28 changes: 26 additions & 2 deletions pkg/codefresh/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,46 @@ import (
type (
IWorkflowAPI interface {
WaitForStatus(string, string, time.Duration, time.Duration) error
Get(string) (*Workflow, error)
}

workflow struct {
codefresh Codefresh
}

Workflow struct {
ID string `json:"id"`
Status string `json:"status"`
ID string `json:"id"`
Status string `json:"status"`
UserYamlDescriptor string `json:"userYamlDescriptor"`
Progress string `json:"progress"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Finished time.Time `json:"finished"`
}
)

func newWorkflowAPI(codefresh Codefresh) IWorkflowAPI {
return &workflow{codefresh}
}

func (w *workflow) Get(id string) (*Workflow, error) {
wf := &Workflow{}
resp, err := w.codefresh.requestAPI(&requestOptions{
path: fmt.Sprintf("/api/builds/%s", id),
method: "GET",
})
// failed in api call
if err != nil {
return nil, err
}
err = w.codefresh.decodeResponseInto(resp, wf)
// failed to decode
if err != nil {
return nil, err
}
return wf, nil
}

func (w *workflow) WaitForStatus(id string, status string, interval time.Duration, timeout time.Duration) error {
err := waitFor(interval, timeout, func() (bool, error) {

Expand Down