Skip to content

Commit 14a2af0

Browse files
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`.
1 parent e8701a2 commit 14a2af0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This section records common use cases for this kubectl plugin.
4545
### Collecting profiles of Go programs
4646

4747
```
48-
$ kubectl curl "http://{pod}/debug/pprof/profile?debug=1&seconds=10" > ./profile
48+
$ kubectl curl -o profile "http://{pod}/debug/pprof/profile?debug=1&seconds=10"
4949
$ go tool pprof -http :6060 ./profile
5050
```
5151

curl.go

Lines changed: 4 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():

0 commit comments

Comments
 (0)