api: support wildcard /compose/status
This commit is contained in:
parent
df7e14d5eb
commit
7fbe8453ef
1 changed files with 18 additions and 11 deletions
|
|
@ -1228,6 +1228,7 @@ func (api *API) composeQueueHandler(writer http.ResponseWriter, request *http.Re
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) composeStatusHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {
|
func (api *API) composeStatusHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {
|
||||||
|
// TODO: lorax has some params: /api/v0/compose/status/<uuids>[?blueprint=<blueprint_name>&status=<compose_status>&type=<compose_type>]
|
||||||
if !verifyRequestVersion(writer, params, 0) { // TODO: version 1 API
|
if !verifyRequestVersion(writer, params, 0) { // TODO: version 1 API
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1236,19 +1237,25 @@ func (api *API) composeStatusHandler(writer http.ResponseWriter, request *http.R
|
||||||
UUIDs []*store.ComposeEntry `json:"uuids"`
|
UUIDs []*store.ComposeEntry `json:"uuids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
uuidStrings := strings.Split(params.ByName("uuids"), ",")
|
uuidsParam := params.ByName("uuids")
|
||||||
uuids := make([]uuid.UUID, len(uuidStrings))
|
|
||||||
for _, uuidString := range uuidStrings {
|
var uuids []uuid.UUID
|
||||||
id, err := uuid.Parse(uuidString)
|
|
||||||
if err != nil {
|
if uuidsParam != "*" {
|
||||||
errors := responseError{
|
uuidStrings := strings.Split(uuidsParam, ",")
|
||||||
ID: "UnknownUUID",
|
uuids = make([]uuid.UUID, len(uuidStrings))
|
||||||
Msg: fmt.Sprintf("%s is not a valid build uuid", uuidString),
|
for _, uuidString := range uuidStrings {
|
||||||
|
id, err := uuid.Parse(uuidString)
|
||||||
|
if err != nil {
|
||||||
|
errors := responseError{
|
||||||
|
ID: "UnknownUUID",
|
||||||
|
Msg: fmt.Sprintf("%s is not a valid build uuid", uuidString),
|
||||||
|
}
|
||||||
|
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
uuids = append(uuids, id)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
uuids = append(uuids, id)
|
|
||||||
}
|
}
|
||||||
reply.UUIDs = api.store.ListQueue(uuids)
|
reply.UUIDs = api.store.ListQueue(uuids)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue