Merge branch 'master' of github.com:mastertinner/s3-manager
This commit is contained in:
commit
2ff5114186
3 changed files with 47 additions and 32 deletions
12
README.md
12
README.md
|
@ -1,10 +1,16 @@
|
|||
# S3 Manager
|
||||
|
||||
Manage S3 buckets from any provider.
|
||||
A Web UI to written in Go to manage S3 buckets from any provider.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
* `S3_ACCESS_KEY_ID`: Your S3 access key ID
|
||||
* `S3_SECRET_ACCESS_KEY`: Your S3 secred access key
|
||||
* `S3_ACCESS_KEY_ID`: Required. Your S3 access key ID
|
||||
* `S3_SECRET_ACCESS_KEY`: Required. Your S3 secret access key
|
||||
* `S3_ENDPOINT`: Optional. In case you are using a different S3 provider than AWS. Defaults to `s3.amazonaws.com`
|
||||
* `V2_SIGNING`: Optional. In case your S3 provider still uses V2 Signing, set this to `true`
|
||||
|
||||
## Run locally
|
||||
|
||||
1. Set all environment variables
|
||||
1. Run `go build .`
|
||||
1. Run the binary and visit <http://localhost:8080>
|
||||
|
|
29
main.go
29
main.go
|
@ -4,42 +4,13 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/minio/minio-go"
|
||||
)
|
||||
|
||||
var minioClient *minio.Client
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if len(port) == 0 {
|
||||
port = "8080"
|
||||
}
|
||||
s3AccessKeyID := os.Getenv("S3_ACCESS_KEY_ID")
|
||||
if len(s3AccessKeyID) == 0 {
|
||||
log.Fatalln("Please set S3_ACCESS_KEY_ID")
|
||||
}
|
||||
|
||||
s3SecretAccessKey := os.Getenv("S3_SECRET_ACCESS_KEY")
|
||||
if len(s3SecretAccessKey) == 0 {
|
||||
log.Fatalln("Please set S3_SECRET_ACCESS_KEY")
|
||||
}
|
||||
|
||||
s3Endpoint := os.Getenv("S3_ENDPOINT")
|
||||
if len(s3Endpoint) == 0 {
|
||||
s3Endpoint = "s3.amazonaws.com"
|
||||
}
|
||||
|
||||
if os.Getenv("V2_SIGNING") == "true" {
|
||||
minioClient, err = minio.NewV2(s3Endpoint, s3AccessKeyID, s3SecretAccessKey, true)
|
||||
} else {
|
||||
minioClient, err = minio.New(s3Endpoint, s3AccessKeyID, s3SecretAccessKey, true)
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
router := NewRouter()
|
||||
|
||||
|
|
38
minio.go
Normal file
38
minio.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
minio "github.com/minio/minio-go"
|
||||
)
|
||||
|
||||
var minioClient *minio.Client
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
s3Endpoint := os.Getenv("S3_ENDPOINT")
|
||||
if len(s3Endpoint) == 0 {
|
||||
s3Endpoint = "s3.amazonaws.com"
|
||||
}
|
||||
|
||||
s3AccessKeyID := os.Getenv("S3_ACCESS_KEY_ID")
|
||||
if len(s3AccessKeyID) == 0 {
|
||||
log.Fatalln("Please set S3_ACCESS_KEY_ID")
|
||||
}
|
||||
|
||||
s3SecretAccessKey := os.Getenv("S3_SECRET_ACCESS_KEY")
|
||||
if len(s3SecretAccessKey) == 0 {
|
||||
log.Fatalln("Please set S3_SECRET_ACCESS_KEY")
|
||||
}
|
||||
|
||||
if os.Getenv("V2_SIGNING") == "true" {
|
||||
minioClient, err = minio.NewV2(s3Endpoint, s3AccessKeyID, s3SecretAccessKey, true)
|
||||
} else {
|
||||
minioClient, err = minio.New(s3Endpoint, s3AccessKeyID, s3SecretAccessKey, true)
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue