api/weldr: getComposeState() -> getComposeStatus()
State is just one of the returned values, this will make more sense when composeStatus struct is introduced. Not a functional change.
This commit is contained in:
parent
fa5b775718
commit
fffec5fc38
1 changed files with 11 additions and 11 deletions
|
|
@ -145,7 +145,7 @@ func (api *API) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
|
||||||
// Returns the state of the image in `compose` and the times the job was
|
// Returns the state of the image in `compose` and the times the job was
|
||||||
// queued, started, and finished. Assumes that there's only one image in the
|
// queued, started, and finished. Assumes that there's only one image in the
|
||||||
// compose. Returns CWaiting on error.
|
// compose. Returns CWaiting on error.
|
||||||
func (api *API) getComposeState(compose store.Compose) (state common.ComposeState, queued, started, finished time.Time) {
|
func (api *API) getComposeStatus(compose store.Compose) (state common.ComposeState, queued, started, finished time.Time) {
|
||||||
jobId := compose.ImageBuild.JobID
|
jobId := compose.ImageBuild.JobID
|
||||||
|
|
||||||
// backwards compatibility: composes that were around before splitting
|
// backwards compatibility: composes that were around before splitting
|
||||||
|
|
@ -1669,7 +1669,7 @@ func (api *API) composeDeleteHandler(writer http.ResponseWriter, request *http.R
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
state, _, _, _ := api.getComposeState(compose)
|
state, _, _, _ := api.getComposeStatus(compose)
|
||||||
if state != common.CFinished && state != common.CFailed {
|
if state != common.CFinished && state != common.CFailed {
|
||||||
errors = append(errors, composeDeleteError{
|
errors = append(errors, composeDeleteError{
|
||||||
"BuildInWrongState",
|
"BuildInWrongState",
|
||||||
|
|
@ -1734,7 +1734,7 @@ func (api *API) composeQueueHandler(writer http.ResponseWriter, request *http.Re
|
||||||
|
|
||||||
composes := api.store.GetAllComposes()
|
composes := api.store.GetAllComposes()
|
||||||
for id, compose := range composes {
|
for id, compose := range composes {
|
||||||
state, queued, started, finished := api.getComposeState(compose)
|
state, queued, started, finished := api.getComposeStatus(compose)
|
||||||
switch state {
|
switch state {
|
||||||
case common.CWaiting:
|
case common.CWaiting:
|
||||||
reply.New = append(reply.New, composeToComposeEntry(id, compose, common.CWaiting, queued, started, finished, includeUploads))
|
reply.New = append(reply.New, composeToComposeEntry(id, compose, common.CWaiting, queued, started, finished, includeUploads))
|
||||||
|
|
@ -1805,7 +1805,7 @@ func (api *API) composeStatusHandler(writer http.ResponseWriter, request *http.R
|
||||||
if !exists {
|
if !exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
state, _, _, _ := api.getComposeState(compose)
|
state, _, _, _ := api.getComposeStatus(compose)
|
||||||
if filterBlueprint != "" && compose.Blueprint.Name != filterBlueprint {
|
if filterBlueprint != "" && compose.Blueprint.Name != filterBlueprint {
|
||||||
continue
|
continue
|
||||||
} else if filterStatus != "" && state.ToString() != filterStatus {
|
} else if filterStatus != "" && state.ToString() != filterStatus {
|
||||||
|
|
@ -1820,7 +1820,7 @@ func (api *API) composeStatusHandler(writer http.ResponseWriter, request *http.R
|
||||||
includeUploads := isRequestVersionAtLeast(params, 1)
|
includeUploads := isRequestVersionAtLeast(params, 1)
|
||||||
for _, id := range filteredUUIDs {
|
for _, id := range filteredUUIDs {
|
||||||
if compose, exists := composes[id]; exists {
|
if compose, exists := composes[id]; exists {
|
||||||
state, queued, started, finished := api.getComposeState(compose)
|
state, queued, started, finished := api.getComposeStatus(compose)
|
||||||
reply.UUIDs = append(reply.UUIDs, composeToComposeEntry(id, compose, state, queued, started, finished, includeUploads))
|
reply.UUIDs = append(reply.UUIDs, composeToComposeEntry(id, compose, state, queued, started, finished, includeUploads))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1880,7 +1880,7 @@ func (api *API) composeInfoHandler(writer http.ResponseWriter, request *http.Req
|
||||||
}
|
}
|
||||||
// Weldr API assumes only one image build per compose, that's why only the
|
// Weldr API assumes only one image build per compose, that's why only the
|
||||||
// 1st build is considered
|
// 1st build is considered
|
||||||
state, _, _, _ := api.getComposeState(compose)
|
state, _, _, _ := api.getComposeStatus(compose)
|
||||||
reply.ComposeType = compose.ImageBuild.ImageType.Name()
|
reply.ComposeType = compose.ImageBuild.ImageType.Name()
|
||||||
reply.QueueStatus = state.ToString()
|
reply.QueueStatus = state.ToString()
|
||||||
reply.ImageSize = compose.ImageBuild.Size
|
reply.ImageSize = compose.ImageBuild.Size
|
||||||
|
|
@ -1919,7 +1919,7 @@ func (api *API) composeImageHandler(writer http.ResponseWriter, request *http.Re
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state, _, _, _ := api.getComposeState(compose)
|
state, _, _, _ := api.getComposeStatus(compose)
|
||||||
if state != common.CFinished {
|
if state != common.CFinished {
|
||||||
errors := responseError{
|
errors := responseError{
|
||||||
ID: "BuildInWrongState",
|
ID: "BuildInWrongState",
|
||||||
|
|
@ -1978,7 +1978,7 @@ func (api *API) composeLogsHandler(writer http.ResponseWriter, request *http.Req
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state, _, _, _ := api.getComposeState(compose)
|
state, _, _, _ := api.getComposeStatus(compose)
|
||||||
if state != common.CFinished && state != common.CFailed {
|
if state != common.CFinished && state != common.CFailed {
|
||||||
errors := responseError{
|
errors := responseError{
|
||||||
ID: "BuildInWrongState",
|
ID: "BuildInWrongState",
|
||||||
|
|
@ -2066,7 +2066,7 @@ func (api *API) composeLogHandler(writer http.ResponseWriter, request *http.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state, _, _, _ := api.getComposeState(compose)
|
state, _, _, _ := api.getComposeStatus(compose)
|
||||||
if state == common.CWaiting {
|
if state == common.CWaiting {
|
||||||
errors := responseError{
|
errors := responseError{
|
||||||
ID: "BuildInWrongState",
|
ID: "BuildInWrongState",
|
||||||
|
|
@ -2121,7 +2121,7 @@ func (api *API) composeFinishedHandler(writer http.ResponseWriter, request *http
|
||||||
|
|
||||||
includeUploads := isRequestVersionAtLeast(params, 1)
|
includeUploads := isRequestVersionAtLeast(params, 1)
|
||||||
for id, compose := range api.store.GetAllComposes() {
|
for id, compose := range api.store.GetAllComposes() {
|
||||||
state, queued, started, finished := api.getComposeState(compose)
|
state, queued, started, finished := api.getComposeStatus(compose)
|
||||||
if state != common.CFinished {
|
if state != common.CFinished {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -2144,7 +2144,7 @@ func (api *API) composeFailedHandler(writer http.ResponseWriter, request *http.R
|
||||||
|
|
||||||
includeUploads := isRequestVersionAtLeast(params, 1)
|
includeUploads := isRequestVersionAtLeast(params, 1)
|
||||||
for id, compose := range api.store.GetAllComposes() {
|
for id, compose := range api.store.GetAllComposes() {
|
||||||
state, queued, started, finished := api.getComposeState(compose)
|
state, queued, started, finished := api.getComposeStatus(compose)
|
||||||
if state != common.CFailed {
|
if state != common.CFailed {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue