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:
|
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
10
main.go
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue