Skip to content

Commit 2280dbb

Browse files
curl: override any "-w" options that might exist
See the code comment for an explanation.
1 parent e8701a2 commit 2280dbb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

curl.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ func main() {
9696
}
9797

9898
func run(ctx context.Context) error {
99-
cArgs := make([]string, 0)
99+
cArgs := []string{
100+
"--header", "User-Agent: kubectl-curl",
101+
}
100102
flags.ParseAll(os.Args[1:], func(flag *pflag.Flag, value string) error {
101103
if flag.Name == "silent" {
102104
return nil // --silent is added later to all curl arguments so don't add here
@@ -239,7 +241,7 @@ func run(ctx context.Context) error {
239241
}
240242
}()
241243

242-
log.Printf("waiting for port fowarding to be established")
244+
log.Printf("waiting for port forwarding to be established")
243245
select {
244246
case <-f.Ready:
245247
case <-ctx.Done():
@@ -253,6 +255,11 @@ func run(ctx context.Context) error {
253255
// print the dynamic progress view for the scenarios in which this
254256
// plugin is useful for.
255257
cArgs = append(cArgs, "--silent")
258+
// Override any settings that users might have by default - for example,
259+
// Kevin Burke has "-w \n" in his .curlrc file. Adding a new line to the end
260+
// of the file is great for readability for most responses but breaks pprof
261+
// and trace parsing.
262+
cArgs = append(cArgs, "-w", "")
256263

257264
cmd := exec.CommandContext(ctx, "curl", cArgs...)
258265
cmd.Stdin = os.Stdin

0 commit comments

Comments
 (0)