-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 971195d
Showing
11 changed files
with
1,045 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ${{ matrix.platform }} | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
go-version: [1.11.x, 1.12.x, 1.13.x, 1.14.x] | ||
env: | ||
GO111MODULE: "on" | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
- name: Build | ||
run: go build -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/pipedream/pipedream | ||
/example/example | ||
/pipedream/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Christian Rocha | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
Pipe Dream | ||
========== | ||
|
||
<p> | ||
<a href="https://github.com/meowgorithm/pipedream/releases"><img src="https://img.shields.io/github/release/meowgorithm/pipedream.svg" alt="Latest Release"></a> | ||
<a href="https://pkg.go.dev/github.com/meowgorithm/pipedream?tab=doc"><img src="https://godoc.org/github.com/golang/gddo?status.svg" alt="GoDoc"></a> | ||
<a href="https://github.com/meowgorithm/pipedream/actions"><img src="https://github.com/meowgorithm/pipedream/workflows/build/badge.svg" alt="Build Status"></a> | ||
</p> | ||
|
||
Easy multipart uploads for Amazon S3, DigitalOcean Spaces and S3-compatible | ||
services. Available as a CLI and Go library. | ||
|
||
## CLI | ||
|
||
### Install It | ||
|
||
Download a build from the [releases][releases] page. macOS, Linux and Windows builds are available for various architectures. | ||
|
||
macOS users can also use Homebrew: | ||
|
||
``` | ||
brew install meowgorithm/homebrew-tap/pipedream | ||
``` | ||
|
||
Or you can just use `go get`: | ||
|
||
```bash | ||
go get github.com/meowgorithm/pipedream/pipedream | ||
``` | ||
|
||
[releases]: https://github.com/meowgorithm/pipedream/releases | ||
|
||
### Usage | ||
|
||
```bash | ||
# Set your secrets, region and endpoint in the environment | ||
export ACCESS_KEY="..." | ||
export SECRET_KEY="..." | ||
export ENDPOINT="sfo2.digitaloceanspaces.com" # for AWS set REGION | ||
|
||
# Pipe in data or redirect in a file | ||
pipedream --bucket images --path pets/puppy.jpg < puppy.jpg | ||
|
||
# Get fancy | ||
export now=$(date +"%Y-%m-%d_%H:%M:%S_%Z") | ||
cat /data/dump.rdb | gzip | pipedream -bucket backups -path dump-$(now).rdb.gz | ||
|
||
# For more info | ||
pipedream -h | ||
``` | ||
|
||
## Library | ||
|
||
The library uses an event based model, sending events through a channel. | ||
|
||
```go | ||
import "github.com/meowgorithm/pipedream" | ||
|
||
// Create a new multipart upload object | ||
m := pipedream.MultipartUpload{ | ||
AccessKey: os.Getenv("ACCESS_KEY"), | ||
SecretKey: os.Getenv("SECRET_KEY"), | ||
Endpoint: "sfo2.digitaloceanspaces.com", // you could use Region for AWS | ||
Bucket: "my-fave-bucket", | ||
} | ||
|
||
// Get an io.Reader, like an *os.File or os.Stdout | ||
f, err := os.Open("big-redis-dump.rdb") | ||
if err != nil { | ||
fmt.Printf("Rats: %v\n", err) | ||
os.Exit(1) | ||
} | ||
defer f.Close() | ||
|
||
// Send up the data. Pipdream returns a channel where you can listen for events | ||
ch := m.Send(f, "backups/dump.rdb") | ||
done := make(chan struct{}) | ||
|
||
// Listen for activity. For more detailed reporting, see the docs | ||
go func() { | ||
for { | ||
e := <-ch | ||
switch e.(type) { | ||
case pipedream.Complete: | ||
fmt.Println("It worked!") | ||
close(done) | ||
return | ||
case pipedream.Error: | ||
fmt.Println("Rats, it didn't work.") | ||
close(done) | ||
return | ||
} | ||
} | ||
}() | ||
|
||
<-done | ||
``` | ||
|
||
[Full source][example] of this example. For an example with more detailed | ||
reporting, see the source code in the [CLI][cli]. | ||
|
||
[example]: https://github.com/meowgorithm/pipedream/blob/master/example/main.go | ||
[cli]: https://github.com/meowgorithm/pipedream/tree/master/pipedream | ||
|
||
## Awknowledgements | ||
|
||
Thanks to to Apoorva Manjunath‘s [S3 multipart upload example](https://github.com/apoorvam/aws-s3-multipart-upload) | ||
for the S3 implementation details. | ||
|
||
## License | ||
|
||
[MIT](https://github.com/meowgorithm/pipedream/raw/master/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/meowgorithm/pipedream" | ||
) | ||
|
||
func main() { | ||
|
||
m := pipedream.MultipartUpload{ | ||
AccessKey: os.Getenv("ACCESS_KEY"), | ||
SecretKey: os.Getenv("SECRET_KEY"), | ||
Endpoint: "sfo2.digitaloceanspaces.com", // you could use Region for AWS | ||
Bucket: "my-fave-bucket", | ||
} | ||
|
||
// Get an io.Reader | ||
f, err := os.Open("big-redis-dump.rdb") | ||
if err != nil { | ||
fmt.Printf("Rats: %v\n", err) | ||
os.Exit(1) | ||
} | ||
defer f.Close() | ||
|
||
// Send it up! Pipdream returns a channel where you can listen for events. | ||
ch := m.Send(f, "backups/dump.rdb") | ||
done := make(chan struct{}) | ||
|
||
// Listen for activity. For more detailed reporting, see the docs. | ||
go func() { | ||
for { | ||
e := <-ch | ||
switch e.(type) { | ||
case pipedream.Complete: | ||
fmt.Println("It worked!") | ||
close(done) | ||
return | ||
case pipedream.Error: | ||
fmt.Println("Rats, it didn't work.") | ||
close(done) | ||
return | ||
} | ||
} | ||
}() | ||
|
||
<-done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module github.com/meowgorithm/pipedream | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/aws/aws-sdk-go v1.33.7 | ||
github.com/dustin/go-humanize v1.0.0 | ||
github.com/meowgorithm/babyenv v1.3.0 | ||
github.com/muesli/reflow v0.1.0 | ||
github.com/muesli/termenv v0.7.0 | ||
github.com/spf13/cobra v1.0.0 | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
golang.org/x/sys v0.0.0-20200806125547-5acd03effb82 // indirect | ||
) |
Oops, something went wrong.