Skip to content

Commit

Permalink
handling gosec issue
Browse files Browse the repository at this point in the history
Signed-off-by: Prateeknandle <prateeknandle@gmail.com>
  • Loading branch information
Prateeknandle committed Feb 7, 2023
1 parent 64e65a6 commit f437049
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/cluster/clusterMgmtHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ func getResponseBytes(method string, url string, data map[string]interface{}) []
return nil
}
dumpHttpClient(nil, resp)
defer resp.Body.Close()
defer func() {
if err := resp.Body.Close(); err != nil {
log.Error().Msgf("Error closing http stream %s\n", err)
}
}()

// read response to []byte
resByte, err := ioutil.ReadAll(resp.Body)
Expand Down
6 changes: 5 additions & 1 deletion src/cluster/kvmServiceHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ func GetResourcesFromKvmService() ([]string, []types.Pod) {
log.Error().Msgf("http response error: %s", err.Error())
return nil, nil
}
defer resp.Body.Close()
defer func() {
if err := resp.Body.Close(); err != nil {
log.Error().Msgf("Error closing http stream %s\n", err)
}
}()

data, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion src/recommendpolicy/downloadTemplates.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ func unZip(source, dest string) error {
if err = create.Close(); err != nil {
return err
}
defer open.Close()
defer func() {
if err := open.Close(); err != nil {
log.Error().Msgf("Error closing file %s\n", err)
}
}()
}
return nil
}
Expand Down

0 comments on commit f437049

Please sign in to comment.