Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: aliculPix4D <[email protected]>
  • Loading branch information
aliculPix4D committed Oct 3, 2024
1 parent 59acf05 commit f2acb2f
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions go-concourse/concourse/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,34 @@ func (team *team) CreateOrUpdatePipelineConfig(pipelineRef atc.PipelineRef, conf

switch response.StatusCode {
case http.StatusOK, http.StatusCreated:
if response.Header.Get("Content-Type") == "application/json" {
configResponse := setConfigResponse{}
err = json.Unmarshal(body, &configResponse)
if err != nil {
return false, false, []ConfigWarning{}, fmt.Errorf("client: unable to JSON parse the response body: %w", err)
}
created := response.StatusCode == http.StatusCreated
return created, !created, configResponse.Warnings, nil
} else {
if response.Header.Get("Content-Type") != "application/json" {
return false, false, []ConfigWarning{}, internal.UnexpectedResponseError{
StatusCode: response.StatusCode,
Status: response.Status,
Body: string(body),
}
}
configResponse := setConfigResponse{}
err = json.Unmarshal(body, &configResponse)
if err != nil {
return false, false, []ConfigWarning{}, fmt.Errorf("client: unable to JSON parse the response body: %w", err)
}
created := response.StatusCode == http.StatusCreated
return created, !created, configResponse.Warnings, nil
case http.StatusBadRequest:
if response.Header.Get("Content-Type") == "application/json" {
var validationErr atc.SaveConfigResponse
err = json.Unmarshal(body, &validationErr)
if err != nil {
return false, false, []ConfigWarning{}, fmt.Errorf("client: unable to JSON parse the response body: %w", err)
}
return false, false, []ConfigWarning{}, InvalidConfigError{Errors: validationErr.Errors}
} else {
if response.Header.Get("Content-Type") != "application/json" {
return false, false, []ConfigWarning{}, internal.UnexpectedResponseError{
StatusCode: response.StatusCode,
Status: response.Status,
Body: string(body),
}
}
var validationErr atc.SaveConfigResponse
err = json.Unmarshal(body, &validationErr)
if err != nil {
return false, false, []ConfigWarning{}, fmt.Errorf("client: unable to JSON parse the response body: %w", err)
}
return false, false, []ConfigWarning{}, InvalidConfigError{Errors: validationErr.Errors}
case http.StatusForbidden:
return false, false, []ConfigWarning{}, internal.ForbiddenError{
Reason: string(body),
Expand Down

0 comments on commit f2acb2f

Please sign in to comment.