diff --git a/internal/s3/client.go b/internal/s3/client.go index 0765807..b4824b0 100644 --- a/internal/s3/client.go +++ b/internal/s3/client.go @@ -215,6 +215,26 @@ func (c *Client) CreateBucket(bucket string, params map[string]string) CreateBuc return CreateBucketResponse{Success: false, Error: err.Error()} } + var versioning bool + if strVersioned, ok := params["versioning"]; ok { + if versioning, err = strconv.ParseBool(strVersioned); err != nil { + stats.Report(c.vu, createBucketFails, 1) + return CreateBucketResponse{Success: false, Error: err.Error()} + } + } + if versioning { + _, err = c.cli.PutBucketVersioning(context.TODO(), &s3.PutBucketVersioningInput{ + Bucket: aws.String(bucket), + VersioningConfiguration: &types.VersioningConfiguration{ + Status: types.BucketVersioningStatusEnabled, + }, + }) + if err != nil { + stats.Report(c.vu, createBucketFails, 1) + return CreateBucketResponse{Success: false, Error: err.Error()} + } + } + stats.Report(c.vu, createBucketSuccess, 1) stats.Report(c.vu, createBucketDuration, metrics.D(time.Since(start))) return CreateBucketResponse{Success: true}