-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
ec95c58
commit 365fcca
Showing
3 changed files
with
73 additions
and
65 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,60 @@ | ||
# How to use hatchery | ||
|
||
To be written | ||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- Go 1.22 or later | ||
- Scheduled binary execution service (e.g., cron, AWS Lambda, Google Cloud Run) | ||
|
||
### Build your binary | ||
|
||
Write your own main.go. For example, the following code collects logs from Slack and stores them in Google Cloud Storage. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/secmon-as-code/hatchery" | ||
"github.com/secmon-as-code/hatchery/destination/gcs" | ||
"github.com/secmon-as-code/hatchery/pkg/types/secret" | ||
"github.com/secmon-as-code/hatchery/source/slack" | ||
) | ||
|
||
func main() { | ||
streams := []*hatchery.Stream{ | ||
hatchery.NewStream( | ||
// Source: Slack Audit API | ||
slack.New(secret.NewString(os.Getenv("SLACK_TOKEN"))), | ||
// Destination: Google Cloud Storage, bucket name is "mizutani-test" | ||
gcs.New("mizutani-test"), | ||
|
||
// Option: WithID sets the stream ID | ||
hatchery.WithID("slack-to-gcs"), | ||
), | ||
} | ||
|
||
// You can run CLI with args such as `go run main.go -i slack-to-gcs` | ||
if err := hatchery.New(streams).CLI(os.Args); err != nil { | ||
panic(err) | ||
} | ||
} | ||
``` | ||
|
||
Build your binary. | ||
|
||
```sh | ||
$ go build -o myhatchery main.go | ||
``` | ||
|
||
### Run your binary | ||
|
||
Run your binary. | ||
|
||
```sh | ||
$ env SLACK_TOKEN=your-slack-token ./myhatchery -s slack-to-gcs | ||
``` | ||
|
||
It will collect logs from Slack and store them in Google Cloud Storage. |