cli: add --debug-http flag (#7192)

This makes it easier to help debug client issues.
This commit is contained in:
Ammar Bandukwala
2023-04-19 11:07:53 -05:00
committed by GitHub
parent f94ac55f02
commit 2b9d12828a
2 changed files with 46 additions and 0 deletions
+13
View File
@@ -364,6 +364,13 @@ func (r *RootCmd) Command(subcommands []*clibase.Cmd) (*clibase.Cmd, error) {
Value: clibase.BoolOf(&r.verbose),
Group: globalGroup,
},
{
Flag: "debug-http",
Description: "Debug codersdk HTTP requests.",
Value: clibase.BoolOf(&r.debugHTTP),
Group: globalGroup,
Hidden: true,
},
{
Flag: config.FlagName,
Env: "CODER_CONFIG_DIR",
@@ -412,6 +419,7 @@ type RootCmd struct {
forceTTY bool
noOpen bool
verbose bool
debugHTTP bool
noVersionCheck bool
noFeatureWarning bool
@@ -464,6 +472,11 @@ func (r *RootCmd) InitClient(client *codersdk.Client) clibase.MiddlewareFunc {
client.SetSessionToken(r.token)
if r.debugHTTP {
client.PlainLogger = os.Stderr
client.LogBodies = true
}
// We send these requests in parallel to minimize latency.
var (
versionErr = make(chan error)