weldr/upload: uploadRequestToTarget() cannot fail
Drop the error return and simplify code accordingly. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
87b0bb6e5d
commit
c66db42677
2 changed files with 5 additions and 14 deletions
|
|
@ -1409,16 +1409,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
|
||||
var uploadTarget *target.Target
|
||||
if isRequestVersionAtLeast(params, 1) && cr.Upload != nil {
|
||||
uploadTarget, err = uploadRequestToTarget(*cr.Upload, imageType)
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "UploadError",
|
||||
Msg: fmt.Sprintf("bad input format: %s", err.Error()),
|
||||
}
|
||||
|
||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||
return
|
||||
}
|
||||
uploadTarget = uploadRequestToTarget(*cr.Upload, imageType)
|
||||
}
|
||||
|
||||
bp := api.store.GetBlueprintCommitted(cr.BlueprintName)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
type uploadResponse struct {
|
||||
Uuid uuid.UUID `json:"uuid"`
|
||||
UUID uuid.UUID `json:"uuid"`
|
||||
Status common.ImageBuildState `json:"status"`
|
||||
ProviderName string `json:"provider_name"`
|
||||
ImageName string `json:"image_name"`
|
||||
|
|
@ -87,7 +87,7 @@ func targetsToUploadResponses(targets []*target.Target) []uploadResponse {
|
|||
var uploads []uploadResponse
|
||||
for _, t := range targets {
|
||||
upload := uploadResponse{
|
||||
Uuid: t.Uuid,
|
||||
UUID: t.Uuid,
|
||||
Status: t.Status,
|
||||
ImageName: t.ImageName,
|
||||
CreationTime: float64(t.Created.UnixNano()) / 1000000000,
|
||||
|
|
@ -118,7 +118,7 @@ func targetsToUploadResponses(targets []*target.Target) []uploadResponse {
|
|||
return uploads
|
||||
}
|
||||
|
||||
func uploadRequestToTarget(u uploadRequest, imageType distro.ImageType) (*target.Target, error) {
|
||||
func uploadRequestToTarget(u uploadRequest, imageType distro.ImageType) *target.Target {
|
||||
var t target.Target
|
||||
|
||||
t.Uuid = uuid.New()
|
||||
|
|
@ -147,5 +147,5 @@ func uploadRequestToTarget(u uploadRequest, imageType distro.ImageType) (*target
|
|||
}
|
||||
}
|
||||
|
||||
return &t, nil
|
||||
return &t
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue