Skip to content

curl: override any "-w" options that might exist #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kevinburkesegment
Copy link
Contributor

See the code comment for an explanation.

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -w would conflict with an existing curl option I believe:

       -w, --write-out <format>
              Make curl display information on stdout after a completed transfer. The format is a string that may contain plain text mixed with any number of variables. The format can be specified as a literal "string", or you can have curl read the format from a file with "@filename"
              and to tell curl to read the format from stdin you write "@-".
...

Do you have another preferred argument?

Alternatively we could use an environment variable to alter the behavior.

@kevinburke
Copy link

Sorry that's the goal - I have "-w \n" in my .curlrc because it makes most curl requests format better when printed to stdout. But it breaks pprof files downloaded with curl which is one of the main things you'd be downloading with kubectl-curl.

I guess I could check if stdout is a TTY or not, and only append the "-w" argument if it's not?

@achille-roussel
Copy link
Contributor

🤔 I believe it should work already then? Maybe it didn't because of #10 ?

Have you tried with the latest release?

@kevinburke
Copy link

I believe it should work already then?

When you say "it" what do you mean? On master, kubectl-curl reads the contents of .curlrc ("-w \n") and appends a newline, which I don't want it to do, since it breaks pprof file parsing. On this branch, kubectl-curl reads the contents of .curlrc but they are overridden by the argument passed directly here.

@achille-roussel
Copy link
Contributor

What I mean is passing of the -w option should already work? Can you do kubectl curl -w "" ... for example?

I think reading of the .curlrc file is the expected behavior, the goal of this plugin is to run a curl command against a running kubernetes pod, so it should behave the same as it would if the user was executing a curl command against any other http server.

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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants