Skip to content

Commit 1bbfc95

Browse files
author
Oleg Sucharevich
committed
update runtime interface to have ability ot mark a runtime env as default
1 parent 12e5a08 commit 1bbfc95

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/codefresh/runtime_enrionment.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type (
1616
Get(string) (*RuntimeEnvironment, error)
1717
List() ([]*RuntimeEnvironment, error)
1818
Delete(string) (bool, error)
19+
Default(string) (bool, error)
1920
}
2021

2122
RuntimeEnvironment struct {
@@ -201,3 +202,19 @@ func (r *runtimeEnvironment) Delete(name string) (bool, error) {
201202
}
202203
return false, fmt.Errorf(body)
203204
}
205+
206+
func (r *runtimeEnvironment) Default(name string) (bool, error) {
207+
path := fmt.Sprintf("/api/runtime-environments/%s/default", url.PathEscape(name))
208+
resp, err := r.codefresh.requestAPI(&requestOptions{
209+
path: path,
210+
method: "PUT",
211+
})
212+
if err != nil {
213+
return false, err
214+
}
215+
if resp.StatusCode == 201 {
216+
return true, nil
217+
} else {
218+
return false, fmt.Errorf("Unknown error: %v", resp.Body)
219+
}
220+
}

0 commit comments

Comments
 (0)