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

Method getBucketLocation

bucket-cache.go:43–75  ·  view source on GitHub ↗

getBucketLocation - Get location for the bucketName from location map cache, if not fetch freshly by making a new request.

(ctx context.Context, bucketName string)

Source from the content-addressed store, hash-verified

41// getBucketLocation - Get location for the bucketName from location map cache, if not
42// fetch freshly by making a new request.
43func (c *Client) getBucketLocation(ctx context.Context, bucketName string) (string, error) {
44 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
45 return "", err
46 }
47
48 // Region set then no need to fetch bucket location.
49 if c.region != "" {
50 return c.region, nil
51 }
52
53 if location, ok := c.bucketLocCache.Get(bucketName); ok {
54 return location, nil
55 }
56
57 // Initialize a new request.
58 req, err := c.getBucketLocationRequest(ctx, bucketName)
59 if err != nil {
60 return "", err
61 }
62
63 // Initiate the request.
64 resp, err := c.do(req)
65 defer closeResponse(resp)
66 if err != nil {
67 return "", err
68 }
69 location, err := processBucketLocationResponse(resp, bucketName)
70 if err != nil {
71 return "", err
72 }
73 c.bucketLocCache.Set(bucketName, location)
74 return location, nil
75}
76
77// processes the getBucketLocation http response from the server.
78func processBucketLocationResponse(resp *http.Response, bucketName string) (bucketLocation string, err error) {

Callers 4

HealthCheckMethod · 0.95
newRequestMethod · 0.95
PresignedPostPolicyMethod · 0.95
GetBucketLocationMethod · 0.95

Calls 7

doMethod · 0.95
CheckValidBucketNameFunction · 0.92
closeResponseFunction · 0.70
GetMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected