MCPcopy
hub / github.com/minio/minio-go / RemoveBucketWithOptions

Method RemoveBucketWithOptions

api-remove.go:59–90  ·  view source on GitHub ↗

RemoveBucketWithOptions deletes the bucket name. All objects (including all object versions and delete markers) in the bucket will be deleted forcibly if bucket options set ForceDelete to 'true'.

(ctx context.Context, bucketName string, opts RemoveBucketOptions)

Source from the content-addressed store, hash-verified

57// in the bucket will be deleted forcibly if bucket options set
58// ForceDelete to 'true'.
59func (c *Client) RemoveBucketWithOptions(ctx context.Context, bucketName string, opts RemoveBucketOptions) error {
60 // Input validation.
61 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
62 return err
63 }
64
65 // Build headers.
66 headers := make(http.Header)
67 if opts.ForceDelete {
68 headers.Set(minIOForceDelete, "true")
69 }
70
71 // Execute DELETE on bucket.
72 resp, err := c.executeMethod(ctx, http.MethodDelete, requestMetadata{
73 bucketName: bucketName,
74 contentSHA256Hex: emptySHA256Hex,
75 customHeader: headers,
76 })
77 defer closeResponse(resp)
78 if err != nil {
79 return err
80 }
81 if resp != nil {
82 if resp.StatusCode != http.StatusNoContent {
83 return httpRespToErrorResponse(resp, bucketName, "")
84 }
85 }
86
87 // Remove the location from cache on a successful delete.
88 c.bucketLocCache.Delete(bucketName)
89 return nil
90}
91
92// RemoveBucket deletes the bucket name.
93//

Callers

nothing calls this directly

Calls 6

executeMethodMethod · 0.95
CheckValidBucketNameFunction · 0.92
httpRespToErrorResponseFunction · 0.85
DeleteMethod · 0.80
closeResponseFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected