Ajouter MediaClient.Seed()
Retirer MediaClient.foo()
This commit is contained in:
parent
5cef3f47ca
commit
3891ea36ca
1 changed files with 26 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
package media
|
package media
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.agecem.com/agecem/agecem-org/config"
|
"git.agecem.com/agecem/agecem-org/config"
|
||||||
|
@ -49,6 +50,29 @@ type MediaClient struct {
|
||||||
MinioClient minio.Client
|
MinioClient minio.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MediaClient) foo() string {
|
func (m *MediaClient) Seed() ([]string, error) {
|
||||||
return "bar"
|
var cfg config.Config
|
||||||
|
if err := viper.Unmarshal(&cfg); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var new_buckets []string
|
||||||
|
|
||||||
|
for _, bucket := range cfg.Server.Documents.Buckets {
|
||||||
|
exists, err := m.MinioClient.BucketExists(context.Background(), bucket)
|
||||||
|
if err != nil {
|
||||||
|
return new_buckets, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = m.MinioClient.MakeBucket(context.Background(), bucket, minio.MakeBucketOptions{}); err != nil {
|
||||||
|
return new_buckets, err
|
||||||
|
}
|
||||||
|
new_buckets = append(new_buckets, bucket)
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_buckets, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue