removed s3 bucket from config
This commit is contained in:
parent
8725def3a1
commit
686630b2df
1
.env
1
.env
@ -2,7 +2,6 @@
|
|||||||
S3_ENDPOINT=localhost:9000
|
S3_ENDPOINT=localhost:9000
|
||||||
S3_ACCESS_KEY=testo
|
S3_ACCESS_KEY=testo
|
||||||
S3_SECRET_KEY=testotesto
|
S3_SECRET_KEY=testotesto
|
||||||
S3_BUCKET=dev
|
|
||||||
S3_DISABLE_SSL=true
|
S3_DISABLE_SSL=true
|
||||||
ADDRESS=:8080
|
ADDRESS=:8080
|
||||||
VERBOSE=true
|
VERBOSE=true
|
||||||
|
@ -12,7 +12,6 @@ type args struct {
|
|||||||
S3Endpoint string `arg:"--s3-endpoint,required,env:S3_ENDPOINT" help:"host[:port]" placeholder:"ENDPOINT"`
|
S3Endpoint string `arg:"--s3-endpoint,required,env:S3_ENDPOINT" help:"host[:port]" placeholder:"ENDPOINT"`
|
||||||
S3AccessKey string `arg:"--s3-access-key,required,env:S3_ACCESS_KEY" placeholder:"ACCESS_KEY"`
|
S3AccessKey string `arg:"--s3-access-key,required,env:S3_ACCESS_KEY" placeholder:"ACCESS_KEY"`
|
||||||
S3SecretKey string `arg:"--s3-secret-key,required,env:S3_SECRET_KEY" placeholder:"SECRET_KEY"`
|
S3SecretKey string `arg:"--s3-secret-key,required,env:S3_SECRET_KEY" placeholder:"SECRET_KEY"`
|
||||||
S3Bucket string `arg:"--s3-bucket,required,env:S3_BUCKET" placeholder:"BUCKET"`
|
|
||||||
S3DisableSSL bool `arg:"--s3-disable-ssl,env:S3_DISABLE_SSL" default:"false"`
|
S3DisableSSL bool `arg:"--s3-disable-ssl,env:S3_DISABLE_SSL" default:"false"`
|
||||||
Address string `arg:"--address,env:ADDRESS" default:":3000" help:"what address to listen on" placeholder:"ADDRESS"`
|
Address string `arg:"--address,env:ADDRESS" default:":3000" help:"what address to listen on" placeholder:"ADDRESS"`
|
||||||
CacheTTL int64 `arg:"--cache-ttl,env:CACHE_TTL" help:"Time in seconds" default:"30" placeholder:"TTL"`
|
CacheTTL int64 `arg:"--cache-ttl,env:CACHE_TTL" help:"Time in seconds" default:"30" placeholder:"TTL"`
|
||||||
@ -35,7 +34,6 @@ func main() {
|
|||||||
S3SSL: !args.S3DisableSSL,
|
S3SSL: !args.S3DisableSSL,
|
||||||
S3AccessKey: args.S3AccessKey,
|
S3AccessKey: args.S3AccessKey,
|
||||||
S3SecretKey: args.S3SecretKey,
|
S3SecretKey: args.S3SecretKey,
|
||||||
S3Bucket: args.S3Bucket,
|
|
||||||
DSN: args.DBConnection,
|
DSN: args.DBConnection,
|
||||||
CacheTTL: time.Duration(args.CacheTTL) * time.Second,
|
CacheTTL: time.Duration(args.CacheTTL) * time.Second,
|
||||||
CacheCleanup: time.Duration(args.CacheCleanup) * time.Second,
|
CacheCleanup: time.Duration(args.CacheCleanup) * time.Second,
|
||||||
|
@ -2,7 +2,6 @@ package s3browser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
@ -17,26 +16,10 @@ import (
|
|||||||
|
|
||||||
// setupS3Client connect the s3Client
|
// setupS3Client connect the s3Client
|
||||||
func setupS3Client(config types.AppConfig) (*minio.Client, error) {
|
func setupS3Client(config types.AppConfig) (*minio.Client, error) {
|
||||||
minioClient, err := minio.New(config.S3Endoint, &minio.Options{
|
return minio.New(config.S3Endoint, &minio.Options{
|
||||||
Creds: credentials.NewStaticV4(config.S3AccessKey, config.S3SecretKey, ""),
|
Creds: credentials.NewStaticV4(config.S3AccessKey, config.S3SecretKey, ""),
|
||||||
Secure: config.S3SSL,
|
Secure: config.S3SSL,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
exists, err := minioClient.BucketExists(context.Background(), config.S3Bucket)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !exists {
|
|
||||||
return nil, fmt.Errorf("Bucket '%s' does not exist", config.S3Bucket)
|
|
||||||
}
|
|
||||||
|
|
||||||
return minioClient, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start starts the app
|
// Start starts the app
|
||||||
|
@ -12,7 +12,6 @@ type AppConfig struct {
|
|||||||
S3AccessKey string
|
S3AccessKey string
|
||||||
S3SecretKey string
|
S3SecretKey string
|
||||||
S3SSL bool
|
S3SSL bool
|
||||||
S3Bucket string
|
|
||||||
DSN string
|
DSN string
|
||||||
CacheTTL time.Duration
|
CacheTTL time.Duration
|
||||||
CacheCleanup time.Duration
|
CacheCleanup time.Duration
|
||||||
|
Loading…
Reference in New Issue
Block a user