Create S3 buicket if not exists
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Kekskurse 2022-01-15 01:28:02 +01:00
parent 7b1e505e95
commit f05098621e
Signed by: kekskurse
GPG key ID: 728ACCB59341E7E4
2 changed files with 12 additions and 3 deletions

View file

@ -24,5 +24,6 @@ steps:
key: key:
from_secret: ssh_key from_secret: ssh_key
script: script:
- echo hello - cd ~/kuvia-beta;sudo docker-compowe down kuvia
- echo world - sudo docker pull kekskurse/kuvia
- cd ~/kuvia-beta;sudo docker-compowe up -d kuvia

10
main.go
View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"context"
"database/sql" "database/sql"
"embed" "embed"
"errors" "errors"
@ -88,7 +89,14 @@ func s3Connect() {
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("Cant create s3 client") 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 s3 = minioClient