Skip to content

Commit dba844b

Browse files
committed
fix: handle response body close errors
- Added error handling for closing HTTP response body to improve robustness - Changed list function to return result of writer flush for better error reporting Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent b6fe645 commit dba844b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pkg/cmd/tknpac/bootstrap/route.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ func detectSelfSignedCertificate(ctx context.Context, url string) string {
5959
} else if err != nil {
6060
return fmt.Sprintf("⚠️ could not connect to the route %s, make sure the pipelines-as-code controller is running", url)
6161
}
62-
resp.Body.Close()
62+
if err := resp.Body.Close(); err != nil {
63+
return fmt.Sprintf("⚠️ could not close the response body: %v", err)
64+
}
6365
return ""
6466
}
6567

pkg/cmd/tknpac/list/list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,5 @@ func list(ctx context.Context, cs *params.Run, opts *cli.PacCliOpts, ioStreams *
188188
if err := t.Execute(w, data); err != nil {
189189
return err
190190
}
191-
w.Flush()
192-
return nil
191+
return w.Flush()
193192
}

0 commit comments

Comments
 (0)