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: added Head command #730

Merged
merged 15 commits into from
Jul 26, 2024
Merged

feat: added Head command #730

merged 15 commits into from
Jul 26, 2024

Conversation

4o4x
Copy link
Contributor

@4o4x 4o4x commented Jul 3, 2024

This pull request adds the head command to the program. Closes #682.

The head command is designed to check if a file exists without downloading the object or bucket itself. It retrieves metadata from an object without returning the object itself. This operation is useful for users who are only interested in an object's metadata.

  • Implemented the head command functionality.
  • Added end-point tests to ensure the correctness of the head command implementation.

Usage:

Check if a bucket exists

s5cmd head s3://bucket-name

Check if a file exists and retrieve its metadata

s5cmd head s3://bucket-name/object

@4o4x 4o4x requested a review from a team as a code owner July 3, 2024 15:18
@4o4x 4o4x requested review from igungor and seruman and removed request for a team July 3, 2024 15:18
@4o4x 4o4x changed the title Head feature feat: added Head command Jul 4, 2024
Copy link
Member

@seruman seruman left a comment

Choose a reason for hiding this comment

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

besides the review comments, there're left over comments -mostly in tests-, could please take another look at them.

command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
e2e/run_test.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
storage/s3.go Outdated Show resolved Hide resolved
storage/s3.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
storage/s3.go Outdated Show resolved Hide resolved
storage/s3_test.go Outdated Show resolved Hide resolved
storage/url/url.go Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Show resolved Hide resolved
command/app.go Show resolved Hide resolved
command/head.go Show resolved Hide resolved
command/head.go Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
storage/url/url.go Show resolved Hide resolved
storage/s3.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
e2e/head_test.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
4o4x added 10 commits July 16, 2024 19:38
Enhancements to `head` command and bug fixes

- Added `version-id` and `raw` flags to the `head` command
- Fixed issue with metadata printing
- Added new tests
The code change corrects a typo in the storage class value in the S3 storage module. The variable `storageClassStr` was misspelled as "STANDART" instead of "STANDARD". This commit fixes the typo to ensure the correct storage class value is used.

Note: This suggested commit message follows the convention observed in the recent repository commits.
Support for displaying metadata in the command output.
The regex in the expected output of the head_test.go file has been updated to account for different orderings of key-value pairs in the metadata. This change ensures that the test passes regardless of the order in which the key-value pairs are printed.
seruman
seruman previously approved these changes Jul 17, 2024
@4o4x
Copy link
Contributor Author

4o4x commented Jul 23, 2024

Hello, we have decided with @ilkinulas that all outputs should be in JSON format, so some parts have been changed in this PR. I would really appreciate it if you could review it again.

The code change removes the unused code that was setting the relative path in the `Run` method of the `Head` struct.
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
command/head.go Outdated Show resolved Hide resolved
@ilkinulas ilkinulas merged commit b5e5143 into peak:master Jul 26, 2024
13 checks passed
@tooptoop4
Copy link

very interested in this. when is next release @ilkinulas @igungor @seruman ?

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.

Feature request - Check if file exists without ls or downloading the entire object
6 participants