detached 4511363

fix(cli) preserve custom transport in TLS config and reuse it for streaming

commit
4511363db0a3bf58c94af31b6807a5996559ab0d
author
bnema · · 2026-02-06 21:29 UTC
parent
ed92944
signature
unsigned
1 file · +15 -5
M internal/adapters/in/cli/remote/client.go +15 -5
@@ -92,10 +92,17 @@ func (c *Client) applyTLSConfig() {
9292 fmt.Fprintf(os.Stderr, "WARNING: TLS certificate verification disabled for %s\n", c.baseURL)
9393
9494 var transport *http.Transport
95- if existing, ok := c.httpClient.Transport.(*http.Transport); ok {
96- transport = existing.Clone()
97- } else {
95+ switch t := c.httpClient.Transport.(type) {
96+ case *http.Transport:
97+ transport = t.Clone()
98+ case nil:
9899 transport = http.DefaultTransport.(*http.Transport).Clone()
100+ default:
101+ // Cannot apply InsecureSkipVerify to a non-*http.Transport.
102+ // Log a warning and leave the transport intact rather than
103+ // silently replacing it (which would drop caller-provided behavior).
104+ fmt.Fprintf(os.Stderr, "WARNING: --insecure requires *http.Transport, got %T; TLS override not applied\n", t)
105+ return
99106 }
100107
101108 if transport.TLSClientConfig == nil {
@@ -741,8 +748,11 @@ func (c *Client) streamLogs(ctx context.Context, path string) (<-chan string, er
741748 req.Header.Set("Authorization", "Bearer "+c.token)
742749 }
743750
744- // Use a client without timeout for streaming
745- streamClient := &http.Client{}
751+ // Use the same transport as the main client (honoring TLS config and
752+ // custom transports) but without a timeout so streaming doesn't get cut off.
753+ streamClient := &http.Client{
754+ Transport: c.httpClient.Transport,
755+ }
746756 resp, err := streamClient.Do(req)
747757 if err != nil {
748758 return nil, fmt.Errorf("failed to connect: %w", err)
@@ -92,10 +92,17 @@ func (c *Client) applyTLSConfig() {
92 fmt.Fprintf(os.Stderr, "WARNING: TLS certificate verification disabled for %s\n", c.baseURL)92 fmt.Fprintf(os.Stderr, "WARNING: TLS certificate verification disabled for %s\n", c.baseURL)
93 93
94 var transport *http.Transport94 var transport *http.Transport
95- if existing, ok := c.httpClient.Transport.(*http.Transport); ok {95+ switch t := c.httpClient.Transport.(type) {
96- transport = existing.Clone()96+ case *http.Transport:
97- } else {97+ transport = t.Clone()
98+ case nil:
98 transport = http.DefaultTransport.(*http.Transport).Clone()99 transport = http.DefaultTransport.(*http.Transport).Clone()
100+ default:
101+ // Cannot apply InsecureSkipVerify to a non-*http.Transport.
102+ // Log a warning and leave the transport intact rather than
103+ // silently replacing it (which would drop caller-provided behavior).
104+ fmt.Fprintf(os.Stderr, "WARNING: --insecure requires *http.Transport, got %T; TLS override not applied\n", t)
105+ return
99 }106 }
100 107
101 if transport.TLSClientConfig == nil {108 if transport.TLSClientConfig == nil {
@@ -741,8 +748,11 @@ func (c *Client) streamLogs(ctx context.Context, path string) (<-chan string, er
741 req.Header.Set("Authorization", "Bearer "+c.token)748 req.Header.Set("Authorization", "Bearer "+c.token)
742 }749 }
743 750
744- // Use a client without timeout for streaming751+ // Use the same transport as the main client (honoring TLS config and
745- streamClient := &http.Client{}752+ // custom transports) but without a timeout so streaming doesn't get cut off.
753+ streamClient := &http.Client{
754+ Transport: c.httpClient.Transport,
755+ }
746 resp, err := streamClient.Do(req)756 resp, err := streamClient.Do(req)
747 if err != nil {757 if err != nil {
748 return nil, fmt.Errorf("failed to connect: %w", err)758 return nil, fmt.Errorf("failed to connect: %w", err)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close