Create S3 buicket if not exists
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7b1e505e95
commit
f05098621e
2 changed files with 12 additions and 3 deletions
|
@ -24,5 +24,6 @@ steps:
|
|||
key:
|
||||
from_secret: ssh_key
|
||||
script:
|
||||
- echo hello
|
||||
- echo world
|
||||
- cd ~/kuvia-beta;sudo docker-compowe down kuvia
|
||||
- sudo docker pull kekskurse/kuvia
|
||||
- cd ~/kuvia-beta;sudo docker-compowe up -d kuvia
|
10
main.go
10
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"embed"
|
||||
"errors"
|
||||
|
@ -88,7 +89,14 @@ func s3Connect() {
|
|||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Cant create s3 client")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
bucketexists, err := minioClient.BucketExists(ctx, os.Getenv("S3_BUCKET"))
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Cant check S3 Bucket exists")
|
||||
}
|
||||
if bucketexists == false {
|
||||
minioClient.MakeBucket(ctx, os.Getenv("S3_BUCKET"), minio.MakeBucketOptions{})
|
||||
}
|
||||
|
||||
s3 = minioClient
|
||||
|
||||
|
|
Loading…
Reference in a new issue