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

command: add pipe command (#182) #587

Merged
merged 39 commits into from
Jul 27, 2023
Merged

Conversation

ahmethakanbesel
Copy link
Contributor

@ahmethakanbesel ahmethakanbesel commented Jul 6, 2023

Resolves #182 and #522
Added pipe command to upload stdin output to a bucket.

Example usage:
echo "content" | s5cmd pipe s3://bucket/file.txt

@ahmethakanbesel ahmethakanbesel requested a review from a team as a code owner July 6, 2023 07:46
@ahmethakanbesel ahmethakanbesel requested review from igungor and seruman and removed request for a team July 6, 2023 07:46
storage/stdin.go Outdated Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
@hsource
Copy link

hsource commented Jul 7, 2023

I tested this in production for uploading a 500 GB file that was the output of tar and it seemed to work well! Just wanted to add my 2 cents here.

I did this by

  1. Forking the branch and running go install github.com/wanderlog/s5cmd/[email protected] to install it
  2. Running this command:
tar -cf - "$INPUT" | zstd -1 --stdout | \
  ~/go/bin/s5cmd --endpoint-url "$S3_ENDPOINT" --credentials-file "$S5CMD_CREDENTIALS_FILE" \
    pipe --part-size "$PART_SIZE_MB" "$S3_DESTINATION"

Verifying the command completed successfully

command/pipe.go Outdated Show resolved Hide resolved
@seruman
Copy link
Member

seruman commented Jul 11, 2023

I think with refactoring cp command, we might able to use some of the code for stuff like common flags, content type guessing, override logic but not exactly sure if it worths, what do you think? @ahmethakanbesel @igungor

command/pipe.go Outdated Show resolved Hide resolved
@ahmethakanbesel
Copy link
Contributor Author

ahmethakanbesel commented Jul 11, 2023

I think with refactoring cp command, we might able to use some of the code for stuff like common flags, content type guessing, override logic but not exactly sure if it worths, what do you think? @ahmethakanbesel @igungor

cp has the NewSharedFlags function, which defines 18 different common flags for cp and sync. pipe uses 13 of them. We can reduce the number of shared flags to use them all in cp, sync and pipe, but it can affect the user experience.

We can have a common ShouldOverride function. It may take a list of available flags or a parameter to determine called by cp or pipe.

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.

@ahmethakanbesel Can you update the changelog please?

@ahmethakanbesel
Copy link
Contributor Author

@ahmethakanbesel Can you update the changelog please?

I updated the changelog.

command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
command/pipe.go Show resolved Hide resolved
e2e/pipe_test.go Outdated Show resolved Hide resolved
command/pipe.go Outdated Show resolved Hide resolved
@seruman
Copy link
Member

seruman commented Jul 27, 2023

@ahmethakanbesel There's a conflict on CHANGELOG.

seruman
seruman previously approved these changes Jul 27, 2023
@igungor
Copy link
Member

igungor commented Jul 27, 2023

🎖️

@seruman seruman merged commit 18145bd into peak:master Jul 27, 2023
@mlissner
Copy link

So cool, thank you all! I've been waiting for this!

igungor added a commit that referenced this pull request Jul 27, 2023
@ahmethakanbesel ahmethakanbesel deleted the stdin-pipe branch July 29, 2023 12:39
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.

Add option to stdin to cp
5 participants