Skip to content

Commit

Permalink
fix(kcurl): more info for statuscode not in MaybeSuccessfulStatuscode…
Browse files Browse the repository at this point in the history
…List
  • Loading branch information
neargle committed Jun 10, 2022
1 parent fd1190e commit 71d0646
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/tool/kubectl/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,24 @@ func ServerAccountRequest(opts K8sRequestOption) (string, error) {
}
//defer resp.Body.Close()

content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", &errors.CDKRuntimeError{Err: err, CustomMsg: "err found in post request."}
}

res := string(content)

// Fix a bug reported by the author of crossc2 on whc2021.
// When the DeployBackdoorDaemonset call fails and returns an error, it will still feedback true.
if !util.IntContains(MaybeSuccessfulStatuscodeList, resp.StatusCode) {
errMsg := fmt.Sprintf("err found in post request, error response code: %v.", resp.Status)
return "", &errors.CDKRuntimeError{
return res, &errors.CDKRuntimeError{
Err: err,
CustomMsg: errMsg,
}
}

content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", &errors.CDKRuntimeError{Err: err, CustomMsg: "err found in post request."}
}

return string(content), nil
return res, nil
}

func GetServerVersion(serverAddr string) (string, error) {
Expand Down

0 comments on commit 71d0646

Please sign in to comment.