[#100] s3: Support creating of versioned bucket
Add "versioning" parameter handling in CreateBucket method Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
This commit is contained in:
parent
f5df03c718
commit
c6f7d51393
1 changed files with 20 additions and 0 deletions
|
@ -215,6 +215,26 @@ func (c *Client) CreateBucket(bucket string, params map[string]string) CreateBuc
|
||||||
return CreateBucketResponse{Success: false, Error: err.Error()}
|
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, createBucketSuccess, 1)
|
||||||
stats.Report(c.vu, createBucketDuration, metrics.D(time.Since(start)))
|
stats.Report(c.vu, createBucketDuration, metrics.D(time.Since(start)))
|
||||||
return CreateBucketResponse{Success: true}
|
return CreateBucketResponse{Success: true}
|
||||||
|
|
Loading…
Reference in a new issue