Skip to content

Commit

Permalink
fix(minio): set life cycle config on existing bucket (#25)
Browse files Browse the repository at this point in the history
Because

- life cycle rule config should be set on existing buckets

This commit

- set life cycle config on existing buckets
  • Loading branch information
joremysh authored Oct 28, 2024
1 parent 6659d46 commit 3b853d0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions minio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ func NewMinioClientAndInitBucket(ctx context.Context, cfg *Config, logger *zap.L
}
if exists {
logger.Info("Bucket already exists", zap.String("bucket", cfg.BucketName))
return &minio{client: client, bucket: cfg.BucketName}, nil
} else {
if err = client.MakeBucket(ctx, cfg.BucketName, miniogo.MakeBucketOptions{
Region: Location,
}); err != nil {
logger.Error("creating Bucket failed", zap.Error(err))
return nil, err
}
logger.Info("Successfully created bucket", zap.String("bucket", cfg.BucketName))
}

if err = client.MakeBucket(ctx, cfg.BucketName, miniogo.MakeBucketOptions{
Region: Location,
}); err != nil {
logger.Error("creating Bucket failed", zap.Error(err))
return nil, err
}
logger.Info("Successfully created bucket", zap.String("bucket", cfg.BucketName))

lccfg := lifecycle.NewConfiguration()
lccfg.Rules = []lifecycle.Rule{
{
Expand Down

0 comments on commit 3b853d0

Please sign in to comment.