cli icon indicating copy to clipboard operation
cli copied to clipboard

feat(cli): add --http-header option

Open mapleeit opened this issue 2 years ago • 7 comments

Signed-off-by: Zhaofeng Miao [email protected]

- What I did

Add --http-header option to CLI to allow adding custom http headers when doing docker command

- How I did it

See the diff

- How to verify it

I tested it locally, if you think it's good to continue, I'll add test for it and polish the code.

Screen Shot 2022-05-30 at 4 19 23 PM

- Description for the changelog

Add --http-header option to CLI to allow specifying http headers. docker --http-header "key: value" version

- A picture of a cute animal (not mandatory but encouraged)

: )

mapleeit avatar May 30 '22 08:05 mapleeit

@thaJeztah It's good to have your opinion here. Thanks in advance.

mapleeit avatar May 30 '22 08:05 mapleeit

Could you describe the use-case for this feature? The CLI already supports a HttpHeaders option in the cli configuration file (https://docs.docker.com/engine/reference/commandline/cli/#custom-http-headers), so I'm wondering if that would be an alternative to use.

thaJeztah avatar May 30 '22 08:05 thaJeztah

Thanks for the quick response. @thaJeztah

We are treating docker daemon as a microservice in our system. So we need to append x-request-id http header to the each request, so that we can trace and route them as we need. And it will change every time apparently. Writing it to the config.json doesn't work in concurrent cases.

mapleeit avatar May 30 '22 08:05 mapleeit

And it will change every time apparently. Writing it to the config.json doesn't work in concurrent cases.

Ah, right, gotcha, yes, understand the use-case.

thaJeztah avatar May 30 '22 09:05 thaJeztah

Do you think I should continue to add unit test and polish the code now? or still need consideration or discussion.

mapleeit avatar May 30 '22 09:05 mapleeit

Do you think I should continue to add unit test and polish the code now? or still need consideration or discussion.

I was writing down some first comments (let me post them below); overall, I'm not against adding this as a top-level flag (but of course things can still be discussed with other maintainers/reviewers as well).

thaJeztah avatar May 30 '22 09:05 thaJeztah

What should I do to push this PR forward? @thaJeztah

mapleeit avatar Jul 05 '22 08:07 mapleeit