Skip to content
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

feat: support --custom-header flags #5127

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

jiuker
Copy link
Contributor

@jiuker jiuker commented Feb 10, 2025

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers
under the terms of the Apache 2 license.
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.

Description

support header flags
Allows user use --custom-header="HeaderA:ValueA" --custom-header="HeaderB:ValueB" to sent custom header to S3.

Motivation and Context

How to test this PR?

mc ls minio --custom-header "MyHeaderA:Value" --custom-header "MyHeaderB:Value" --debug

mc: <DEBUG> GET / HTTP/1.1
Host: 192.168.101.100:9000
User-Agent: MinIO (windows; amd64) minio-go/v7.0.84 mc/DEVELOPMENT.GOGET
Accept-Encoding: zstd,gzip
Authorization: AWS4-HMAC-SHA256 Credential=minioadmin/20250210/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**
Headera: ValueA
Headerb: ValueB
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20250210T081507Z

mc: <DEBUG> HTTP/1.1 200 OK
Content-Length: 568
Accept-Ranges: bytes
Content-Type: application/xml
Date: Mon, 10 Feb 2025 08:15:07 GMT
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
X-Amz-Request-Id: 1822CABA539717AC
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 4454
X-Ratelimit-Remaining: 4454
X-Xss-Protection: 1; mode=block

mc: <DEBUG> Response Time:  3.6695ms

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please add commit-id or PR # here)
  • Unit tests added/updated
  • Internal documentation updated
  • Create a documentation update request here

@jiuker jiuker changed the title support header flags feat: support header flags Feb 10, 2025
cmd/globals.go Outdated Show resolved Hide resolved
cmd/flags.go Outdated Show resolved Hide resolved
@jiuker jiuker requested a review from klauspost February 10, 2025 09:06
cmd/client.go Outdated Show resolved Hide resolved
cmd/globals.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ramondeklein ramondeklein left a comment

Choose a reason for hiding this comment

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

Don't use globals. Although it may be tempting for a "run-once" per process tool as mc to use globals it makes unit-testing harder (and it's considered bad practice anyway).

cmd/client.go Outdated Show resolved Hide resolved
cmd/client.go Outdated Show resolved Hide resolved
@jiuker jiuker force-pushed the support_header_flags branch from 1e9ee66 to a3fd0b5 Compare February 11, 2025 05:42
@jiuker jiuker marked this pull request as draft February 11, 2025 05:43
@jiuker jiuker force-pushed the support_header_flags branch from 7b7d191 to c8eed15 Compare February 11, 2025 08:16
@jiuker jiuker marked this pull request as ready for review February 11, 2025 08:36
@klauspost
Copy link
Contributor

This is worse now. @ramondeklein was this what you meant?

@ramondeklein
Copy link
Contributor

@klauspost No. There should be a better way to provide CLI parameters. A 200 file change PR is not acceptable. I've not the time to work on this, but it's hard to believe we need to change 200 files to send a custom header...

@jiuker jiuker force-pushed the support_header_flags branch 2 times, most recently from 7a92ee9 to 4350d40 Compare February 12, 2025 04:07
@jiuker jiuker changed the title feat: support header flags feat: support --custom-header flags Feb 12, 2025
cmd/globals.go Outdated Show resolved Hide resolved
@jiuker jiuker force-pushed the support_header_flags branch from 212b74d to b86dbf8 Compare February 13, 2025 01:41
add custom-header flags
@jiuker jiuker force-pushed the support_header_flags branch from 3d604ed to 1e5d857 Compare February 13, 2025 01:45
@jiuker jiuker requested a review from ramondeklein February 13, 2025 01:48
cmd/globals.go Outdated Show resolved Hide resolved
Co-authored-by: Ramon de Klein <[email protected]>
@harshavardhana harshavardhana merged commit 089f833 into minio:master Feb 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants