From 14a2af04a8376c4519566b72225d8f6b06ab9170 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 8 Apr 2022 16:43:13 -0700 Subject: [PATCH] curl: add User-Agent and update README Better to use the `-o`, `--output` flag than redirect stdout because that will omit any `-w` flags that you may have set in e.g. `.curlrc`. --- README.md | 2 +- curl.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5075594..f4365f0 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ This section records common use cases for this kubectl plugin. ### Collecting profiles of Go programs ``` -$ kubectl curl "http://{pod}/debug/pprof/profile?debug=1&seconds=10" > ./profile +$ kubectl curl -o profile "http://{pod}/debug/pprof/profile?debug=1&seconds=10" $ go tool pprof -http :6060 ./profile ``` diff --git a/curl.go b/curl.go index 2a7bfea..9ffa88d 100644 --- a/curl.go +++ b/curl.go @@ -96,7 +96,9 @@ func main() { } func run(ctx context.Context) error { - cArgs := make([]string, 0) + cArgs := []string{ + "--header", "User-Agent: kubectl-curl", + } flags.ParseAll(os.Args[1:], func(flag *pflag.Flag, value string) error { if flag.Name == "silent" { 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 { } }() - log.Printf("waiting for port fowarding to be established") + log.Printf("waiting for port forwarding to be established") select { case <-f.Ready: case <-ctx.Done():