Skip to content

Commit

Permalink
replase %s err.Error() with %v err
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Jan 2, 2024
1 parent 4252a44 commit a220bf8
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 141 deletions.
38 changes: 19 additions & 19 deletions api/alerting/alerting_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func EnvironmentRouteAccessCheck(handler models.RadixHandlerFunc) models.RadixHa

if _, err := a.ServiceAccount.RadixClient.RadixV1().RadixEnvironments().Get(r.Context(), envNamespace, v1.GetOptions{}); err != nil {
if err = radixhttp.ErrorResponse(rw, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func UpdateEnvironmentAlertingConfig(accounts models.Accounts, w http.ResponseWr
var updateAlertingConfig alertingModels.UpdateAlertingConfig
if err := json.NewDecoder(r.Body).Decode(&updateAlertingConfig); err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand All @@ -156,13 +156,13 @@ func UpdateEnvironmentAlertingConfig(accounts models.Accounts, w http.ResponseWr

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -213,13 +213,13 @@ func GetEnvironmentAlertingConfig(accounts models.Accounts, w http.ResponseWrite

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -272,13 +272,13 @@ func EnableEnvironmentAlerting(accounts models.Accounts, w http.ResponseWriter,

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -330,13 +330,13 @@ func DisableEnvironmentAlerting(accounts models.Accounts, w http.ResponseWriter,
alertsConfig, err := alertHandler.DisableAlerting(r.Context())
if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -388,7 +388,7 @@ func UpdateApplicationAlertingConfig(accounts models.Accounts, w http.ResponseWr
var updateAlertingConfig alertingModels.UpdateAlertingConfig
if err := json.NewDecoder(r.Body).Decode(&updateAlertingConfig); err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand All @@ -398,13 +398,13 @@ func UpdateApplicationAlertingConfig(accounts models.Accounts, w http.ResponseWr

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -449,13 +449,13 @@ func GetApplicationAlertingConfig(accounts models.Accounts, w http.ResponseWrite

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -502,13 +502,13 @@ func EnableApplicationAlerting(accounts models.Accounts, w http.ResponseWriter,

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -554,12 +554,12 @@ func DisableApplicationAlerting(accounts models.Accounts, w http.ResponseWriter,
alertsConfig, err := alertHandler.DisableAlerting(r.Context())
if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, alertsConfig); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}
10 changes: 5 additions & 5 deletions api/buildsecrets/buildsecrets_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ func GetBuildSecrets(accounts models.Accounts, w http.ResponseWriter, r *http.Re

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, buildSecrets); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ func ChangeBuildSecret(accounts models.Accounts, w http.ResponseWriter, r *http.
var secretParameters environmentModels.SecretParameters
if err := json.NewDecoder(r.Body).Decode(&secretParameters); err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand All @@ -151,12 +151,12 @@ func ChangeBuildSecret(accounts models.Accounts, w http.ResponseWriter, r *http.

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, "Success"); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}
22 changes: 11 additions & 11 deletions api/deployments/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func GetDeployments(accounts models.Accounts, w http.ResponseWriter, r *http.Req
useLatest, err = strconv.ParseBool(r.FormValue("latest"))
if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand All @@ -116,13 +116,13 @@ func GetDeployments(accounts models.Accounts, w http.ResponseWriter, r *http.Req

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, appDeployments); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -169,13 +169,13 @@ func GetDeployment(accounts models.Accounts, w http.ResponseWriter, r *http.Requ

if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, appDeployment); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -221,13 +221,13 @@ func GetComponents(accounts models.Accounts, w http.ResponseWriter, r *http.Requ
components, err := deployHandler.GetComponentsForDeploymentName(r.Context(), appName, deploymentName)
if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}

if err = radixhttp.JSONResponse(w, r, components); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}

Expand Down Expand Up @@ -304,7 +304,7 @@ func GetPodLog(accounts models.Accounts, w http.ResponseWriter, r *http.Request)
since, asFile, logLines, err, previousLog := logs.GetLogParams(r)
if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand All @@ -313,7 +313,7 @@ func GetPodLog(accounts models.Accounts, w http.ResponseWriter, r *http.Request)
logs, err := deployHandler.GetLogs(r.Context(), appName, podName, &since, logLines, previousLog)
if err != nil {
if err = radixhttp.ErrorResponse(w, r, err); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
return
}
Expand All @@ -322,11 +322,11 @@ func GetPodLog(accounts models.Accounts, w http.ResponseWriter, r *http.Request)
if asFile {
fileName := fmt.Sprintf("%s.log", time.Now().Format("20060102150405"))
if err = radixhttp.ReaderFileResponse(w, logs, fileName, "text/plain; charset=utf-8"); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
} else {
if err = radixhttp.ReaderResponse(w, logs, "text/plain; charset=utf-8"); err != nil {
log.Errorf("%s: failed to write response: %s", r.URL.Path, err.Error())
log.Errorf("%s: failed to write response: %v", r.URL.Path, err)
}
}
}
Loading

0 comments on commit a220bf8

Please sign in to comment.