id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
148,600
minio/minio-go
api-presigned.go
PresignedGetObject
func (c Client) PresignedGetObject(bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) { if err = s3utils.CheckValidObjectName(objectName); err != nil { return nil, err } return c.presignURL("GET", bucketName, objectName, expires, reqParams) }
go
func (c Client) PresignedGetObject(bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) { if err = s3utils.CheckValidObjectName(objectName); err != nil { return nil, err } return c.presignURL("GET", bucketName, objectName, expires, reqParams) }
[ "func", "(", "c", "Client", ")", "PresignedGetObject", "(", "bucketName", "string", ",", "objectName", "string", ",", "expires", "time", ".", "Duration", ",", "reqParams", "url", ".", "Values", ")", "(", "u", "*", "url", ".", "URL", ",", "err", "error", ")", "{", "if", "err", "=", "s3utils", ".", "CheckValidObjectName", "(", "objectName", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "c", ".", "presignURL", "(", "\"", "\"", ",", "bucketName", ",", "objectName", ",", "expires", ",", "reqParams", ")", "\n", "}" ]
// PresignedGetObject - Returns a presigned URL to access an object // data without credentials. URL can have a maximum expiry of // upto 7days or a minimum of 1sec. Additionally you can override // a set of response headers using the query parameters.
[ "PresignedGetObject", "-", "Returns", "a", "presigned", "URL", "to", "access", "an", "object", "data", "without", "credentials", ".", "URL", "can", "have", "a", "maximum", "expiry", "of", "upto", "7days", "or", "a", "minimum", "of", "1sec", ".", "Additionally", "you", "can", "override", "a", "set", "of", "response", "headers", "using", "the", "query", "parameters", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-presigned.go#L67-L72
148,601
minio/minio-go
api-presigned.go
Presign
func (c Client) Presign(method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) { return c.presignURL(method, bucketName, objectName, expires, reqParams) }
go
func (c Client) Presign(method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) { return c.presignURL(method, bucketName, objectName, expires, reqParams) }
[ "func", "(", "c", "Client", ")", "Presign", "(", "method", "string", ",", "bucketName", "string", ",", "objectName", "string", ",", "expires", "time", ".", "Duration", ",", "reqParams", "url", ".", "Values", ")", "(", "u", "*", "url", ".", "URL", ",", "err", "error", ")", "{", "return", "c", ".", "presignURL", "(", "method", ",", "bucketName", ",", "objectName", ",", "expires", ",", "reqParams", ")", "\n", "}" ]
// Presign - returns a presigned URL for any http method of your choice // along with custom request params. URL can have a maximum expiry of // upto 7days or a minimum of 1sec.
[ "Presign", "-", "returns", "a", "presigned", "URL", "for", "any", "http", "method", "of", "your", "choice", "along", "with", "custom", "request", "params", ".", "URL", "can", "have", "a", "maximum", "expiry", "of", "upto", "7days", "or", "a", "minimum", "of", "1sec", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-presigned.go#L98-L100
148,602
minio/minio-go
pkg/encrypt/server-side.go
NewSSEKMS
func NewSSEKMS(keyID string, context interface{}) (ServerSide, error) { if context == nil { return kms{key: keyID, hasContext: false}, nil } serializedContext, err := json.Marshal(context) if err != nil { return nil, err } return kms{key: keyID, context: serializedContext, hasContext: true}, nil }
go
func NewSSEKMS(keyID string, context interface{}) (ServerSide, error) { if context == nil { return kms{key: keyID, hasContext: false}, nil } serializedContext, err := json.Marshal(context) if err != nil { return nil, err } return kms{key: keyID, context: serializedContext, hasContext: true}, nil }
[ "func", "NewSSEKMS", "(", "keyID", "string", ",", "context", "interface", "{", "}", ")", "(", "ServerSide", ",", "error", ")", "{", "if", "context", "==", "nil", "{", "return", "kms", "{", "key", ":", "keyID", ",", "hasContext", ":", "false", "}", ",", "nil", "\n", "}", "\n", "serializedContext", ",", "err", ":=", "json", ".", "Marshal", "(", "context", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "kms", "{", "key", ":", "keyID", ",", "context", ":", "serializedContext", ",", "hasContext", ":", "true", "}", ",", "nil", "\n", "}" ]
// NewSSEKMS returns a new server-side-encryption using SSE-KMS and the provided Key Id and context.
[ "NewSSEKMS", "returns", "a", "new", "server", "-", "side", "-", "encryption", "using", "SSE", "-", "KMS", "and", "the", "provided", "Key", "Id", "and", "context", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/encrypt/server-side.go#L100-L109
148,603
minio/minio-go
pkg/encrypt/server-side.go
NewSSEC
func NewSSEC(key []byte) (ServerSide, error) { if len(key) != 32 { return nil, errors.New("encrypt: SSE-C key must be 256 bit long") } sse := ssec{} copy(sse[:], key) return sse, nil }
go
func NewSSEC(key []byte) (ServerSide, error) { if len(key) != 32 { return nil, errors.New("encrypt: SSE-C key must be 256 bit long") } sse := ssec{} copy(sse[:], key) return sse, nil }
[ "func", "NewSSEC", "(", "key", "[", "]", "byte", ")", "(", "ServerSide", ",", "error", ")", "{", "if", "len", "(", "key", ")", "!=", "32", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "sse", ":=", "ssec", "{", "}", "\n", "copy", "(", "sse", "[", ":", "]", ",", "key", ")", "\n", "return", "sse", ",", "nil", "\n", "}" ]
// NewSSEC returns a new server-side-encryption using SSE-C and the provided key. // The key must be 32 bytes long.
[ "NewSSEC", "returns", "a", "new", "server", "-", "side", "-", "encryption", "using", "SSE", "-", "C", "and", "the", "provided", "key", ".", "The", "key", "must", "be", "32", "bytes", "long", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/encrypt/server-side.go#L113-L120
148,604
minio/minio-go
pkg/policy/bucket-policy-condition.go
Add
func (ckm ConditionKeyMap) Add(key string, value set.StringSet) { if v, ok := ckm[key]; ok { ckm[key] = v.Union(value) } else { ckm[key] = set.CopyStringSet(value) } }
go
func (ckm ConditionKeyMap) Add(key string, value set.StringSet) { if v, ok := ckm[key]; ok { ckm[key] = v.Union(value) } else { ckm[key] = set.CopyStringSet(value) } }
[ "func", "(", "ckm", "ConditionKeyMap", ")", "Add", "(", "key", "string", ",", "value", "set", ".", "StringSet", ")", "{", "if", "v", ",", "ok", ":=", "ckm", "[", "key", "]", ";", "ok", "{", "ckm", "[", "key", "]", "=", "v", ".", "Union", "(", "value", ")", "\n", "}", "else", "{", "ckm", "[", "key", "]", "=", "set", ".", "CopyStringSet", "(", "value", ")", "\n", "}", "\n", "}" ]
// Add - adds key and value. The value is appended If key already exists.
[ "Add", "-", "adds", "key", "and", "value", ".", "The", "value", "is", "appended", "If", "key", "already", "exists", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L26-L32
148,605
minio/minio-go
pkg/policy/bucket-policy-condition.go
Remove
func (ckm ConditionKeyMap) Remove(key string, value set.StringSet) { if v, ok := ckm[key]; ok { if value != nil { ckm[key] = v.Difference(value) } if ckm[key].IsEmpty() { delete(ckm, key) } } }
go
func (ckm ConditionKeyMap) Remove(key string, value set.StringSet) { if v, ok := ckm[key]; ok { if value != nil { ckm[key] = v.Difference(value) } if ckm[key].IsEmpty() { delete(ckm, key) } } }
[ "func", "(", "ckm", "ConditionKeyMap", ")", "Remove", "(", "key", "string", ",", "value", "set", ".", "StringSet", ")", "{", "if", "v", ",", "ok", ":=", "ckm", "[", "key", "]", ";", "ok", "{", "if", "value", "!=", "nil", "{", "ckm", "[", "key", "]", "=", "v", ".", "Difference", "(", "value", ")", "\n", "}", "\n\n", "if", "ckm", "[", "key", "]", ".", "IsEmpty", "(", ")", "{", "delete", "(", "ckm", ",", "key", ")", "\n", "}", "\n", "}", "\n", "}" ]
// Remove - removes value of given key. If key has empty after removal, the key is also removed.
[ "Remove", "-", "removes", "value", "of", "given", "key", ".", "If", "key", "has", "empty", "after", "removal", "the", "key", "is", "also", "removed", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L35-L45
148,606
minio/minio-go
pkg/policy/bucket-policy-condition.go
RemoveKey
func (ckm ConditionKeyMap) RemoveKey(key string) { if _, ok := ckm[key]; ok { delete(ckm, key) } }
go
func (ckm ConditionKeyMap) RemoveKey(key string) { if _, ok := ckm[key]; ok { delete(ckm, key) } }
[ "func", "(", "ckm", "ConditionKeyMap", ")", "RemoveKey", "(", "key", "string", ")", "{", "if", "_", ",", "ok", ":=", "ckm", "[", "key", "]", ";", "ok", "{", "delete", "(", "ckm", ",", "key", ")", "\n", "}", "\n", "}" ]
// RemoveKey - removes key and its value.
[ "RemoveKey", "-", "removes", "key", "and", "its", "value", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L48-L52
148,607
minio/minio-go
pkg/policy/bucket-policy-condition.go
CopyConditionKeyMap
func CopyConditionKeyMap(condKeyMap ConditionKeyMap) ConditionKeyMap { out := make(ConditionKeyMap) for k, v := range condKeyMap { out[k] = set.CopyStringSet(v) } return out }
go
func CopyConditionKeyMap(condKeyMap ConditionKeyMap) ConditionKeyMap { out := make(ConditionKeyMap) for k, v := range condKeyMap { out[k] = set.CopyStringSet(v) } return out }
[ "func", "CopyConditionKeyMap", "(", "condKeyMap", "ConditionKeyMap", ")", "ConditionKeyMap", "{", "out", ":=", "make", "(", "ConditionKeyMap", ")", "\n\n", "for", "k", ",", "v", ":=", "range", "condKeyMap", "{", "out", "[", "k", "]", "=", "set", ".", "CopyStringSet", "(", "v", ")", "\n", "}", "\n\n", "return", "out", "\n", "}" ]
// CopyConditionKeyMap - returns new copy of given ConditionKeyMap.
[ "CopyConditionKeyMap", "-", "returns", "new", "copy", "of", "given", "ConditionKeyMap", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L55-L63
148,608
minio/minio-go
pkg/policy/bucket-policy-condition.go
Add
func (cond ConditionMap) Add(condKey string, condKeyMap ConditionKeyMap) { if v, ok := cond[condKey]; ok { cond[condKey] = mergeConditionKeyMap(v, condKeyMap) } else { cond[condKey] = CopyConditionKeyMap(condKeyMap) } }
go
func (cond ConditionMap) Add(condKey string, condKeyMap ConditionKeyMap) { if v, ok := cond[condKey]; ok { cond[condKey] = mergeConditionKeyMap(v, condKeyMap) } else { cond[condKey] = CopyConditionKeyMap(condKeyMap) } }
[ "func", "(", "cond", "ConditionMap", ")", "Add", "(", "condKey", "string", ",", "condKeyMap", "ConditionKeyMap", ")", "{", "if", "v", ",", "ok", ":=", "cond", "[", "condKey", "]", ";", "ok", "{", "cond", "[", "condKey", "]", "=", "mergeConditionKeyMap", "(", "v", ",", "condKeyMap", ")", "\n", "}", "else", "{", "cond", "[", "condKey", "]", "=", "CopyConditionKeyMap", "(", "condKeyMap", ")", "\n", "}", "\n", "}" ]
// Add - adds condition key and condition value. The value is appended if key already exists.
[ "Add", "-", "adds", "condition", "key", "and", "condition", "value", ".", "The", "value", "is", "appended", "if", "key", "already", "exists", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L84-L90
148,609
minio/minio-go
pkg/policy/bucket-policy-condition.go
Remove
func (cond ConditionMap) Remove(condKey string) { if _, ok := cond[condKey]; ok { delete(cond, condKey) } }
go
func (cond ConditionMap) Remove(condKey string) { if _, ok := cond[condKey]; ok { delete(cond, condKey) } }
[ "func", "(", "cond", "ConditionMap", ")", "Remove", "(", "condKey", "string", ")", "{", "if", "_", ",", "ok", ":=", "cond", "[", "condKey", "]", ";", "ok", "{", "delete", "(", "cond", ",", "condKey", ")", "\n", "}", "\n", "}" ]
// Remove - removes condition key and its value.
[ "Remove", "-", "removes", "condition", "key", "and", "its", "value", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L93-L97
148,610
minio/minio-go
pkg/s3utils/utils.go
IsValidDomain
func IsValidDomain(host string) bool { // See RFC 1035, RFC 3696. host = strings.TrimSpace(host) if len(host) == 0 || len(host) > 255 { return false } // host cannot start or end with "-" if host[len(host)-1:] == "-" || host[:1] == "-" { return false } // host cannot start or end with "_" if host[len(host)-1:] == "_" || host[:1] == "_" { return false } // host cannot start or end with a "." if host[len(host)-1:] == "." || host[:1] == "." { return false } // All non alphanumeric characters are invalid. if strings.ContainsAny(host, "`~!@#$%^&*()+={}[]|\\\"';:><?/") { return false } // No need to regexp match, since the list is non-exhaustive. // We let it valid and fail later. return true }
go
func IsValidDomain(host string) bool { // See RFC 1035, RFC 3696. host = strings.TrimSpace(host) if len(host) == 0 || len(host) > 255 { return false } // host cannot start or end with "-" if host[len(host)-1:] == "-" || host[:1] == "-" { return false } // host cannot start or end with "_" if host[len(host)-1:] == "_" || host[:1] == "_" { return false } // host cannot start or end with a "." if host[len(host)-1:] == "." || host[:1] == "." { return false } // All non alphanumeric characters are invalid. if strings.ContainsAny(host, "`~!@#$%^&*()+={}[]|\\\"';:><?/") { return false } // No need to regexp match, since the list is non-exhaustive. // We let it valid and fail later. return true }
[ "func", "IsValidDomain", "(", "host", "string", ")", "bool", "{", "// See RFC 1035, RFC 3696.", "host", "=", "strings", ".", "TrimSpace", "(", "host", ")", "\n", "if", "len", "(", "host", ")", "==", "0", "||", "len", "(", "host", ")", ">", "255", "{", "return", "false", "\n", "}", "\n", "// host cannot start or end with \"-\"", "if", "host", "[", "len", "(", "host", ")", "-", "1", ":", "]", "==", "\"", "\"", "||", "host", "[", ":", "1", "]", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "// host cannot start or end with \"_\"", "if", "host", "[", "len", "(", "host", ")", "-", "1", ":", "]", "==", "\"", "\"", "||", "host", "[", ":", "1", "]", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "// host cannot start or end with a \".\"", "if", "host", "[", "len", "(", "host", ")", "-", "1", ":", "]", "==", "\"", "\"", "||", "host", "[", ":", "1", "]", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "// All non alphanumeric characters are invalid.", "if", "strings", ".", "ContainsAny", "(", "host", ",", "\"", "\\\\", "\\\"", "\"", ")", "{", "return", "false", "\n", "}", "\n", "// No need to regexp match, since the list is non-exhaustive.", "// We let it valid and fail later.", "return", "true", "\n", "}" ]
// IsValidDomain validates if input string is a valid domain name.
[ "IsValidDomain", "validates", "if", "input", "string", "is", "a", "valid", "domain", "name", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L36-L61
148,611
minio/minio-go
pkg/s3utils/utils.go
IsVirtualHostSupported
func IsVirtualHostSupported(endpointURL url.URL, bucketName string) bool { if endpointURL == sentinelURL { return false } // bucketName can be valid but '.' in the hostname will fail SSL // certificate validation. So do not use host-style for such buckets. if endpointURL.Scheme == "https" && strings.Contains(bucketName, ".") { return false } // Return true for all other cases return IsAmazonEndpoint(endpointURL) || IsGoogleEndpoint(endpointURL) }
go
func IsVirtualHostSupported(endpointURL url.URL, bucketName string) bool { if endpointURL == sentinelURL { return false } // bucketName can be valid but '.' in the hostname will fail SSL // certificate validation. So do not use host-style for such buckets. if endpointURL.Scheme == "https" && strings.Contains(bucketName, ".") { return false } // Return true for all other cases return IsAmazonEndpoint(endpointURL) || IsGoogleEndpoint(endpointURL) }
[ "func", "IsVirtualHostSupported", "(", "endpointURL", "url", ".", "URL", ",", "bucketName", "string", ")", "bool", "{", "if", "endpointURL", "==", "sentinelURL", "{", "return", "false", "\n", "}", "\n", "// bucketName can be valid but '.' in the hostname will fail SSL", "// certificate validation. So do not use host-style for such buckets.", "if", "endpointURL", ".", "Scheme", "==", "\"", "\"", "&&", "strings", ".", "Contains", "(", "bucketName", ",", "\"", "\"", ")", "{", "return", "false", "\n", "}", "\n", "// Return true for all other cases", "return", "IsAmazonEndpoint", "(", "endpointURL", ")", "||", "IsGoogleEndpoint", "(", "endpointURL", ")", "\n", "}" ]
// IsVirtualHostSupported - verifies if bucketName can be part of // virtual host. Currently only Amazon S3 and Google Cloud Storage // would support this.
[ "IsVirtualHostSupported", "-", "verifies", "if", "bucketName", "can", "be", "part", "of", "virtual", "host", ".", "Currently", "only", "Amazon", "S3", "and", "Google", "Cloud", "Storage", "would", "support", "this", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L71-L82
148,612
minio/minio-go
pkg/s3utils/utils.go
GetRegionFromURL
func GetRegionFromURL(endpointURL url.URL) string { if endpointURL == sentinelURL { return "" } if endpointURL.Host == "s3-external-1.amazonaws.com" { return "" } if IsAmazonGovCloudEndpoint(endpointURL) { return "us-gov-west-1" } parts := amazonS3HostDualStack.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } parts = amazonS3HostHyphen.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } parts = amazonS3ChinaHost.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } parts = amazonS3HostDot.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } return "" }
go
func GetRegionFromURL(endpointURL url.URL) string { if endpointURL == sentinelURL { return "" } if endpointURL.Host == "s3-external-1.amazonaws.com" { return "" } if IsAmazonGovCloudEndpoint(endpointURL) { return "us-gov-west-1" } parts := amazonS3HostDualStack.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } parts = amazonS3HostHyphen.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } parts = amazonS3ChinaHost.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } parts = amazonS3HostDot.FindStringSubmatch(endpointURL.Host) if len(parts) > 1 { return parts[1] } return "" }
[ "func", "GetRegionFromURL", "(", "endpointURL", "url", ".", "URL", ")", "string", "{", "if", "endpointURL", "==", "sentinelURL", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "endpointURL", ".", "Host", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "IsAmazonGovCloudEndpoint", "(", "endpointURL", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "parts", ":=", "amazonS3HostDualStack", ".", "FindStringSubmatch", "(", "endpointURL", ".", "Host", ")", "\n", "if", "len", "(", "parts", ")", ">", "1", "{", "return", "parts", "[", "1", "]", "\n", "}", "\n", "parts", "=", "amazonS3HostHyphen", ".", "FindStringSubmatch", "(", "endpointURL", ".", "Host", ")", "\n", "if", "len", "(", "parts", ")", ">", "1", "{", "return", "parts", "[", "1", "]", "\n", "}", "\n", "parts", "=", "amazonS3ChinaHost", ".", "FindStringSubmatch", "(", "endpointURL", ".", "Host", ")", "\n", "if", "len", "(", "parts", ")", ">", "1", "{", "return", "parts", "[", "1", "]", "\n", "}", "\n", "parts", "=", "amazonS3HostDot", ".", "FindStringSubmatch", "(", "endpointURL", ".", "Host", ")", "\n", "if", "len", "(", "parts", ")", ">", "1", "{", "return", "parts", "[", "1", "]", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// GetRegionFromURL - returns a region from url host.
[ "GetRegionFromURL", "-", "returns", "a", "region", "from", "url", "host", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L99-L126
148,613
minio/minio-go
pkg/s3utils/utils.go
IsAmazonEndpoint
func IsAmazonEndpoint(endpointURL url.URL) bool { if endpointURL.Host == "s3-external-1.amazonaws.com" || endpointURL.Host == "s3.amazonaws.com" { return true } return GetRegionFromURL(endpointURL) != "" }
go
func IsAmazonEndpoint(endpointURL url.URL) bool { if endpointURL.Host == "s3-external-1.amazonaws.com" || endpointURL.Host == "s3.amazonaws.com" { return true } return GetRegionFromURL(endpointURL) != "" }
[ "func", "IsAmazonEndpoint", "(", "endpointURL", "url", ".", "URL", ")", "bool", "{", "if", "endpointURL", ".", "Host", "==", "\"", "\"", "||", "endpointURL", ".", "Host", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "return", "GetRegionFromURL", "(", "endpointURL", ")", "!=", "\"", "\"", "\n", "}" ]
// IsAmazonEndpoint - Match if it is exactly Amazon S3 endpoint.
[ "IsAmazonEndpoint", "-", "Match", "if", "it", "is", "exactly", "Amazon", "S3", "endpoint", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L129-L134
148,614
minio/minio-go
pkg/s3utils/utils.go
IsAmazonGovCloudEndpoint
func IsAmazonGovCloudEndpoint(endpointURL url.URL) bool { if endpointURL == sentinelURL { return false } return (endpointURL.Host == "s3-us-gov-west-1.amazonaws.com" || IsAmazonFIPSGovCloudEndpoint(endpointURL)) }
go
func IsAmazonGovCloudEndpoint(endpointURL url.URL) bool { if endpointURL == sentinelURL { return false } return (endpointURL.Host == "s3-us-gov-west-1.amazonaws.com" || IsAmazonFIPSGovCloudEndpoint(endpointURL)) }
[ "func", "IsAmazonGovCloudEndpoint", "(", "endpointURL", "url", ".", "URL", ")", "bool", "{", "if", "endpointURL", "==", "sentinelURL", "{", "return", "false", "\n", "}", "\n", "return", "(", "endpointURL", ".", "Host", "==", "\"", "\"", "||", "IsAmazonFIPSGovCloudEndpoint", "(", "endpointURL", ")", ")", "\n", "}" ]
// IsAmazonGovCloudEndpoint - Match if it is exactly Amazon S3 GovCloud endpoint.
[ "IsAmazonGovCloudEndpoint", "-", "Match", "if", "it", "is", "exactly", "Amazon", "S3", "GovCloud", "endpoint", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L137-L143
148,615
minio/minio-go
pkg/s3utils/utils.go
IsGoogleEndpoint
func IsGoogleEndpoint(endpointURL url.URL) bool { if endpointURL == sentinelURL { return false } return endpointURL.Host == "storage.googleapis.com" }
go
func IsGoogleEndpoint(endpointURL url.URL) bool { if endpointURL == sentinelURL { return false } return endpointURL.Host == "storage.googleapis.com" }
[ "func", "IsGoogleEndpoint", "(", "endpointURL", "url", ".", "URL", ")", "bool", "{", "if", "endpointURL", "==", "sentinelURL", "{", "return", "false", "\n", "}", "\n", "return", "endpointURL", ".", "Host", "==", "\"", "\"", "\n", "}" ]
// IsGoogleEndpoint - Match if it is exactly Google cloud storage endpoint.
[ "IsGoogleEndpoint", "-", "Match", "if", "it", "is", "exactly", "Google", "cloud", "storage", "endpoint", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L183-L188
148,616
minio/minio-go
pkg/s3utils/utils.go
checkBucketNameCommon
func checkBucketNameCommon(bucketName string, strict bool) (err error) { if strings.TrimSpace(bucketName) == "" { return errors.New("Bucket name cannot be empty") } if len(bucketName) < 3 { return errors.New("Bucket name cannot be smaller than 3 characters") } if len(bucketName) > 63 { return errors.New("Bucket name cannot be greater than 63 characters") } if ipAddress.MatchString(bucketName) { return errors.New("Bucket name cannot be an ip address") } if strings.Contains(bucketName, "..") || strings.Contains(bucketName, ".-") || strings.Contains(bucketName, "-.") { return errors.New("Bucket name contains invalid characters") } if strict { if !validBucketNameStrict.MatchString(bucketName) { err = errors.New("Bucket name contains invalid characters") } return err } if !validBucketName.MatchString(bucketName) { err = errors.New("Bucket name contains invalid characters") } return err }
go
func checkBucketNameCommon(bucketName string, strict bool) (err error) { if strings.TrimSpace(bucketName) == "" { return errors.New("Bucket name cannot be empty") } if len(bucketName) < 3 { return errors.New("Bucket name cannot be smaller than 3 characters") } if len(bucketName) > 63 { return errors.New("Bucket name cannot be greater than 63 characters") } if ipAddress.MatchString(bucketName) { return errors.New("Bucket name cannot be an ip address") } if strings.Contains(bucketName, "..") || strings.Contains(bucketName, ".-") || strings.Contains(bucketName, "-.") { return errors.New("Bucket name contains invalid characters") } if strict { if !validBucketNameStrict.MatchString(bucketName) { err = errors.New("Bucket name contains invalid characters") } return err } if !validBucketName.MatchString(bucketName) { err = errors.New("Bucket name contains invalid characters") } return err }
[ "func", "checkBucketNameCommon", "(", "bucketName", "string", ",", "strict", "bool", ")", "(", "err", "error", ")", "{", "if", "strings", ".", "TrimSpace", "(", "bucketName", ")", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "bucketName", ")", "<", "3", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "bucketName", ")", ">", "63", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "ipAddress", ".", "MatchString", "(", "bucketName", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "strings", ".", "Contains", "(", "bucketName", ",", "\"", "\"", ")", "||", "strings", ".", "Contains", "(", "bucketName", ",", "\"", "\"", ")", "||", "strings", ".", "Contains", "(", "bucketName", ",", "\"", "\"", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "strict", "{", "if", "!", "validBucketNameStrict", ".", "MatchString", "(", "bucketName", ")", "{", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "if", "!", "validBucketName", ".", "MatchString", "(", "bucketName", ")", "{", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// Common checker for both stricter and basic validation.
[ "Common", "checker", "for", "both", "stricter", "and", "basic", "validation", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L272-L298
148,617
minio/minio-go
core.go
NewCore
func NewCore(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Core, error) { var s3Client Core client, err := NewV4(endpoint, accessKeyID, secretAccessKey, secure) if err != nil { return nil, err } s3Client.Client = client return &s3Client, nil }
go
func NewCore(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Core, error) { var s3Client Core client, err := NewV4(endpoint, accessKeyID, secretAccessKey, secure) if err != nil { return nil, err } s3Client.Client = client return &s3Client, nil }
[ "func", "NewCore", "(", "endpoint", "string", ",", "accessKeyID", ",", "secretAccessKey", "string", ",", "secure", "bool", ")", "(", "*", "Core", ",", "error", ")", "{", "var", "s3Client", "Core", "\n", "client", ",", "err", ":=", "NewV4", "(", "endpoint", ",", "accessKeyID", ",", "secretAccessKey", ",", "secure", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "s3Client", ".", "Client", "=", "client", "\n", "return", "&", "s3Client", ",", "nil", "\n", "}" ]
// NewCore - Returns new initialized a Core client, this CoreClient should be // only used under special conditions such as need to access lower primitives // and being able to use them to write your own wrappers.
[ "NewCore", "-", "Returns", "new", "initialized", "a", "Core", "client", "this", "CoreClient", "should", "be", "only", "used", "under", "special", "conditions", "such", "as", "need", "to", "access", "lower", "primitives", "and", "being", "able", "to", "use", "them", "to", "write", "your", "own", "wrappers", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L36-L44
148,618
minio/minio-go
core.go
ListObjects
func (c Core) ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (result ListBucketResult, err error) { return c.listObjectsQuery(bucket, prefix, marker, delimiter, maxKeys) }
go
func (c Core) ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (result ListBucketResult, err error) { return c.listObjectsQuery(bucket, prefix, marker, delimiter, maxKeys) }
[ "func", "(", "c", "Core", ")", "ListObjects", "(", "bucket", ",", "prefix", ",", "marker", ",", "delimiter", "string", ",", "maxKeys", "int", ")", "(", "result", "ListBucketResult", ",", "err", "error", ")", "{", "return", "c", ".", "listObjectsQuery", "(", "bucket", ",", "prefix", ",", "marker", ",", "delimiter", ",", "maxKeys", ")", "\n", "}" ]
// ListObjects - List all the objects at a prefix, optionally with marker and delimiter // you can further filter the results.
[ "ListObjects", "-", "List", "all", "the", "objects", "at", "a", "prefix", "optionally", "with", "marker", "and", "delimiter", "you", "can", "further", "filter", "the", "results", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L48-L50
148,619
minio/minio-go
core.go
CopyObject
func (c Core) CopyObject(sourceBucket, sourceObject, destBucket, destObject string, metadata map[string]string) (ObjectInfo, error) { return c.copyObjectDo(context.Background(), sourceBucket, sourceObject, destBucket, destObject, metadata) }
go
func (c Core) CopyObject(sourceBucket, sourceObject, destBucket, destObject string, metadata map[string]string) (ObjectInfo, error) { return c.copyObjectDo(context.Background(), sourceBucket, sourceObject, destBucket, destObject, metadata) }
[ "func", "(", "c", "Core", ")", "CopyObject", "(", "sourceBucket", ",", "sourceObject", ",", "destBucket", ",", "destObject", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "(", "ObjectInfo", ",", "error", ")", "{", "return", "c", ".", "copyObjectDo", "(", "context", ".", "Background", "(", ")", ",", "sourceBucket", ",", "sourceObject", ",", "destBucket", ",", "destObject", ",", "metadata", ")", "\n", "}" ]
// CopyObject - copies an object from source object to destination object on server side.
[ "CopyObject", "-", "copies", "an", "object", "from", "source", "object", "to", "destination", "object", "on", "server", "side", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L59-L61
148,620
minio/minio-go
core.go
PutObject
func (c Core) PutObject(bucket, object string, data io.Reader, size int64, md5Base64, sha256Hex string, metadata map[string]string, sse encrypt.ServerSide) (ObjectInfo, error) { opts := PutObjectOptions{} m := make(map[string]string) for k, v := range metadata { if strings.ToLower(k) == "content-encoding" { opts.ContentEncoding = v } else if strings.ToLower(k) == "content-disposition" { opts.ContentDisposition = v } else if strings.ToLower(k) == "content-language" { opts.ContentLanguage = v } else if strings.ToLower(k) == "content-type" { opts.ContentType = v } else if strings.ToLower(k) == "cache-control" { opts.CacheControl = v } else if strings.ToLower(k) == strings.ToLower(amzWebsiteRedirectLocation) { opts.WebsiteRedirectLocation = v } else { m[k] = metadata[k] } } opts.UserMetadata = m opts.ServerSideEncryption = sse return c.putObjectDo(context.Background(), bucket, object, data, md5Base64, sha256Hex, size, opts) }
go
func (c Core) PutObject(bucket, object string, data io.Reader, size int64, md5Base64, sha256Hex string, metadata map[string]string, sse encrypt.ServerSide) (ObjectInfo, error) { opts := PutObjectOptions{} m := make(map[string]string) for k, v := range metadata { if strings.ToLower(k) == "content-encoding" { opts.ContentEncoding = v } else if strings.ToLower(k) == "content-disposition" { opts.ContentDisposition = v } else if strings.ToLower(k) == "content-language" { opts.ContentLanguage = v } else if strings.ToLower(k) == "content-type" { opts.ContentType = v } else if strings.ToLower(k) == "cache-control" { opts.CacheControl = v } else if strings.ToLower(k) == strings.ToLower(amzWebsiteRedirectLocation) { opts.WebsiteRedirectLocation = v } else { m[k] = metadata[k] } } opts.UserMetadata = m opts.ServerSideEncryption = sse return c.putObjectDo(context.Background(), bucket, object, data, md5Base64, sha256Hex, size, opts) }
[ "func", "(", "c", "Core", ")", "PutObject", "(", "bucket", ",", "object", "string", ",", "data", "io", ".", "Reader", ",", "size", "int64", ",", "md5Base64", ",", "sha256Hex", "string", ",", "metadata", "map", "[", "string", "]", "string", ",", "sse", "encrypt", ".", "ServerSide", ")", "(", "ObjectInfo", ",", "error", ")", "{", "opts", ":=", "PutObjectOptions", "{", "}", "\n", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "k", ",", "v", ":=", "range", "metadata", "{", "if", "strings", ".", "ToLower", "(", "k", ")", "==", "\"", "\"", "{", "opts", ".", "ContentEncoding", "=", "v", "\n", "}", "else", "if", "strings", ".", "ToLower", "(", "k", ")", "==", "\"", "\"", "{", "opts", ".", "ContentDisposition", "=", "v", "\n", "}", "else", "if", "strings", ".", "ToLower", "(", "k", ")", "==", "\"", "\"", "{", "opts", ".", "ContentLanguage", "=", "v", "\n", "}", "else", "if", "strings", ".", "ToLower", "(", "k", ")", "==", "\"", "\"", "{", "opts", ".", "ContentType", "=", "v", "\n", "}", "else", "if", "strings", ".", "ToLower", "(", "k", ")", "==", "\"", "\"", "{", "opts", ".", "CacheControl", "=", "v", "\n", "}", "else", "if", "strings", ".", "ToLower", "(", "k", ")", "==", "strings", ".", "ToLower", "(", "amzWebsiteRedirectLocation", ")", "{", "opts", ".", "WebsiteRedirectLocation", "=", "v", "\n", "}", "else", "{", "m", "[", "k", "]", "=", "metadata", "[", "k", "]", "\n", "}", "\n", "}", "\n", "opts", ".", "UserMetadata", "=", "m", "\n", "opts", ".", "ServerSideEncryption", "=", "sse", "\n", "return", "c", ".", "putObjectDo", "(", "context", ".", "Background", "(", ")", ",", "bucket", ",", "object", ",", "data", ",", "md5Base64", ",", "sha256Hex", ",", "size", ",", "opts", ")", "\n", "}" ]
// PutObject - Upload object. Uploads using single PUT call.
[ "PutObject", "-", "Upload", "object", ".", "Uploads", "using", "single", "PUT", "call", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L73-L96
148,621
minio/minio-go
core.go
NewMultipartUpload
func (c Core) NewMultipartUpload(bucket, object string, opts PutObjectOptions) (uploadID string, err error) { result, err := c.initiateMultipartUpload(context.Background(), bucket, object, opts) return result.UploadID, err }
go
func (c Core) NewMultipartUpload(bucket, object string, opts PutObjectOptions) (uploadID string, err error) { result, err := c.initiateMultipartUpload(context.Background(), bucket, object, opts) return result.UploadID, err }
[ "func", "(", "c", "Core", ")", "NewMultipartUpload", "(", "bucket", ",", "object", "string", ",", "opts", "PutObjectOptions", ")", "(", "uploadID", "string", ",", "err", "error", ")", "{", "result", ",", "err", ":=", "c", ".", "initiateMultipartUpload", "(", "context", ".", "Background", "(", ")", ",", "bucket", ",", "object", ",", "opts", ")", "\n", "return", "result", ".", "UploadID", ",", "err", "\n", "}" ]
// NewMultipartUpload - Initiates new multipart upload and returns the new uploadID.
[ "NewMultipartUpload", "-", "Initiates", "new", "multipart", "upload", "and", "returns", "the", "new", "uploadID", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L99-L102
148,622
minio/minio-go
core.go
ListMultipartUploads
func (c Core) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartUploadsResult, err error) { return c.listMultipartUploadsQuery(bucket, keyMarker, uploadIDMarker, prefix, delimiter, maxUploads) }
go
func (c Core) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartUploadsResult, err error) { return c.listMultipartUploadsQuery(bucket, keyMarker, uploadIDMarker, prefix, delimiter, maxUploads) }
[ "func", "(", "c", "Core", ")", "ListMultipartUploads", "(", "bucket", ",", "prefix", ",", "keyMarker", ",", "uploadIDMarker", ",", "delimiter", "string", ",", "maxUploads", "int", ")", "(", "result", "ListMultipartUploadsResult", ",", "err", "error", ")", "{", "return", "c", ".", "listMultipartUploadsQuery", "(", "bucket", ",", "keyMarker", ",", "uploadIDMarker", ",", "prefix", ",", "delimiter", ",", "maxUploads", ")", "\n", "}" ]
// ListMultipartUploads - List incomplete uploads.
[ "ListMultipartUploads", "-", "List", "incomplete", "uploads", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L105-L107
148,623
minio/minio-go
core.go
PutObjectPart
func (c Core) PutObjectPart(bucket, object, uploadID string, partID int, data io.Reader, size int64, md5Base64, sha256Hex string, sse encrypt.ServerSide) (ObjectPart, error) { return c.uploadPart(context.Background(), bucket, object, uploadID, data, partID, md5Base64, sha256Hex, size, sse) }
go
func (c Core) PutObjectPart(bucket, object, uploadID string, partID int, data io.Reader, size int64, md5Base64, sha256Hex string, sse encrypt.ServerSide) (ObjectPart, error) { return c.uploadPart(context.Background(), bucket, object, uploadID, data, partID, md5Base64, sha256Hex, size, sse) }
[ "func", "(", "c", "Core", ")", "PutObjectPart", "(", "bucket", ",", "object", ",", "uploadID", "string", ",", "partID", "int", ",", "data", "io", ".", "Reader", ",", "size", "int64", ",", "md5Base64", ",", "sha256Hex", "string", ",", "sse", "encrypt", ".", "ServerSide", ")", "(", "ObjectPart", ",", "error", ")", "{", "return", "c", ".", "uploadPart", "(", "context", ".", "Background", "(", ")", ",", "bucket", ",", "object", ",", "uploadID", ",", "data", ",", "partID", ",", "md5Base64", ",", "sha256Hex", ",", "size", ",", "sse", ")", "\n", "}" ]
// PutObjectPart - Upload an object part.
[ "PutObjectPart", "-", "Upload", "an", "object", "part", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L110-L112
148,624
minio/minio-go
core.go
ListObjectParts
func (c Core) ListObjectParts(bucket, object, uploadID string, partNumberMarker int, maxParts int) (result ListObjectPartsResult, err error) { return c.listObjectPartsQuery(bucket, object, uploadID, partNumberMarker, maxParts) }
go
func (c Core) ListObjectParts(bucket, object, uploadID string, partNumberMarker int, maxParts int) (result ListObjectPartsResult, err error) { return c.listObjectPartsQuery(bucket, object, uploadID, partNumberMarker, maxParts) }
[ "func", "(", "c", "Core", ")", "ListObjectParts", "(", "bucket", ",", "object", ",", "uploadID", "string", ",", "partNumberMarker", "int", ",", "maxParts", "int", ")", "(", "result", "ListObjectPartsResult", ",", "err", "error", ")", "{", "return", "c", ".", "listObjectPartsQuery", "(", "bucket", ",", "object", ",", "uploadID", ",", "partNumberMarker", ",", "maxParts", ")", "\n", "}" ]
// ListObjectParts - List uploaded parts of an incomplete upload.x
[ "ListObjectParts", "-", "List", "uploaded", "parts", "of", "an", "incomplete", "upload", ".", "x" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L115-L117
148,625
minio/minio-go
core.go
CompleteMultipartUpload
func (c Core) CompleteMultipartUpload(bucket, object, uploadID string, parts []CompletePart) (string, error) { res, err := c.completeMultipartUpload(context.Background(), bucket, object, uploadID, completeMultipartUpload{ Parts: parts, }) return res.ETag, err }
go
func (c Core) CompleteMultipartUpload(bucket, object, uploadID string, parts []CompletePart) (string, error) { res, err := c.completeMultipartUpload(context.Background(), bucket, object, uploadID, completeMultipartUpload{ Parts: parts, }) return res.ETag, err }
[ "func", "(", "c", "Core", ")", "CompleteMultipartUpload", "(", "bucket", ",", "object", ",", "uploadID", "string", ",", "parts", "[", "]", "CompletePart", ")", "(", "string", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "completeMultipartUpload", "(", "context", ".", "Background", "(", ")", ",", "bucket", ",", "object", ",", "uploadID", ",", "completeMultipartUpload", "{", "Parts", ":", "parts", ",", "}", ")", "\n", "return", "res", ".", "ETag", ",", "err", "\n", "}" ]
// CompleteMultipartUpload - Concatenate uploaded parts and commit to an object.
[ "CompleteMultipartUpload", "-", "Concatenate", "uploaded", "parts", "and", "commit", "to", "an", "object", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L120-L125
148,626
minio/minio-go
core.go
AbortMultipartUpload
func (c Core) AbortMultipartUpload(bucket, object, uploadID string) error { return c.abortMultipartUpload(context.Background(), bucket, object, uploadID) }
go
func (c Core) AbortMultipartUpload(bucket, object, uploadID string) error { return c.abortMultipartUpload(context.Background(), bucket, object, uploadID) }
[ "func", "(", "c", "Core", ")", "AbortMultipartUpload", "(", "bucket", ",", "object", ",", "uploadID", "string", ")", "error", "{", "return", "c", ".", "abortMultipartUpload", "(", "context", ".", "Background", "(", ")", ",", "bucket", ",", "object", ",", "uploadID", ")", "\n", "}" ]
// AbortMultipartUpload - Abort an incomplete upload.
[ "AbortMultipartUpload", "-", "Abort", "an", "incomplete", "upload", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L128-L130
148,627
minio/minio-go
core.go
GetBucketPolicy
func (c Core) GetBucketPolicy(bucket string) (string, error) { return c.getBucketPolicy(bucket) }
go
func (c Core) GetBucketPolicy(bucket string) (string, error) { return c.getBucketPolicy(bucket) }
[ "func", "(", "c", "Core", ")", "GetBucketPolicy", "(", "bucket", "string", ")", "(", "string", ",", "error", ")", "{", "return", "c", ".", "getBucketPolicy", "(", "bucket", ")", "\n", "}" ]
// GetBucketPolicy - fetches bucket access policy for a given bucket.
[ "GetBucketPolicy", "-", "fetches", "bucket", "access", "policy", "for", "a", "given", "bucket", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L133-L135
148,628
minio/minio-go
core.go
PutBucketPolicy
func (c Core) PutBucketPolicy(bucket, bucketPolicy string) error { return c.putBucketPolicy(bucket, bucketPolicy) }
go
func (c Core) PutBucketPolicy(bucket, bucketPolicy string) error { return c.putBucketPolicy(bucket, bucketPolicy) }
[ "func", "(", "c", "Core", ")", "PutBucketPolicy", "(", "bucket", ",", "bucketPolicy", "string", ")", "error", "{", "return", "c", ".", "putBucketPolicy", "(", "bucket", ",", "bucketPolicy", ")", "\n", "}" ]
// PutBucketPolicy - applies a new bucket access policy for a given bucket.
[ "PutBucketPolicy", "-", "applies", "a", "new", "bucket", "access", "policy", "for", "a", "given", "bucket", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L138-L140
148,629
minio/minio-go
core.go
GetObject
func (c Core) GetObject(bucketName, objectName string, opts GetObjectOptions) (io.ReadCloser, ObjectInfo, error) { return c.getObject(context.Background(), bucketName, objectName, opts) }
go
func (c Core) GetObject(bucketName, objectName string, opts GetObjectOptions) (io.ReadCloser, ObjectInfo, error) { return c.getObject(context.Background(), bucketName, objectName, opts) }
[ "func", "(", "c", "Core", ")", "GetObject", "(", "bucketName", ",", "objectName", "string", ",", "opts", "GetObjectOptions", ")", "(", "io", ".", "ReadCloser", ",", "ObjectInfo", ",", "error", ")", "{", "return", "c", ".", "getObject", "(", "context", ".", "Background", "(", ")", ",", "bucketName", ",", "objectName", ",", "opts", ")", "\n", "}" ]
// GetObject is a lower level API implemented to support reading // partial objects and also downloading objects with special conditions // matching etag, modtime etc.
[ "GetObject", "is", "a", "lower", "level", "API", "implemented", "to", "support", "reading", "partial", "objects", "and", "also", "downloading", "objects", "with", "special", "conditions", "matching", "etag", "modtime", "etc", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L145-L147
148,630
minio/minio-go
core.go
StatObject
func (c Core) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) { return c.statObject(context.Background(), bucketName, objectName, opts) }
go
func (c Core) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) { return c.statObject(context.Background(), bucketName, objectName, opts) }
[ "func", "(", "c", "Core", ")", "StatObject", "(", "bucketName", ",", "objectName", "string", ",", "opts", "StatObjectOptions", ")", "(", "ObjectInfo", ",", "error", ")", "{", "return", "c", ".", "statObject", "(", "context", ".", "Background", "(", ")", ",", "bucketName", ",", "objectName", ",", "opts", ")", "\n", "}" ]
// StatObject is a lower level API implemented to support special // conditions matching etag, modtime on a request.
[ "StatObject", "is", "a", "lower", "level", "API", "implemented", "to", "support", "special", "conditions", "matching", "etag", "modtime", "on", "a", "request", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L151-L153
148,631
minio/minio-go
pkg/credentials/file_aws_credentials.go
NewFileAWSCredentials
func NewFileAWSCredentials(filename string, profile string) *Credentials { return New(&FileAWSCredentials{ filename: filename, profile: profile, }) }
go
func NewFileAWSCredentials(filename string, profile string) *Credentials { return New(&FileAWSCredentials{ filename: filename, profile: profile, }) }
[ "func", "NewFileAWSCredentials", "(", "filename", "string", ",", "profile", "string", ")", "*", "Credentials", "{", "return", "New", "(", "&", "FileAWSCredentials", "{", "filename", ":", "filename", ",", "profile", ":", "profile", ",", "}", ")", "\n", "}" ]
// NewFileAWSCredentials returns a pointer to a new Credentials object // wrapping the Profile file provider.
[ "NewFileAWSCredentials", "returns", "a", "pointer", "to", "a", "new", "Credentials", "object", "wrapping", "the", "Profile", "file", "provider", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/file_aws_credentials.go#L52-L57
148,632
minio/minio-go
pkg/s3signer/request-signature-v4.go
GetCredential
func GetCredential(accessKeyID, location string, t time.Time) string { scope := getScope(location, t) return accessKeyID + "/" + scope }
go
func GetCredential(accessKeyID, location string, t time.Time) string { scope := getScope(location, t) return accessKeyID + "/" + scope }
[ "func", "GetCredential", "(", "accessKeyID", ",", "location", "string", ",", "t", "time", ".", "Time", ")", "string", "{", "scope", ":=", "getScope", "(", "location", ",", "t", ")", "\n", "return", "accessKeyID", "+", "\"", "\"", "+", "scope", "\n", "}" ]
// GetCredential generate a credential string.
[ "GetCredential", "generate", "a", "credential", "string", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L108-L111
148,633
minio/minio-go
pkg/s3signer/request-signature-v4.go
getHashedPayload
func getHashedPayload(req http.Request) string { hashedPayload := req.Header.Get("X-Amz-Content-Sha256") if hashedPayload == "" { // Presign does not have a payload, use S3 recommended value. hashedPayload = unsignedPayload } return hashedPayload }
go
func getHashedPayload(req http.Request) string { hashedPayload := req.Header.Get("X-Amz-Content-Sha256") if hashedPayload == "" { // Presign does not have a payload, use S3 recommended value. hashedPayload = unsignedPayload } return hashedPayload }
[ "func", "getHashedPayload", "(", "req", "http", ".", "Request", ")", "string", "{", "hashedPayload", ":=", "req", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "hashedPayload", "==", "\"", "\"", "{", "// Presign does not have a payload, use S3 recommended value.", "hashedPayload", "=", "unsignedPayload", "\n", "}", "\n", "return", "hashedPayload", "\n", "}" ]
// getHashedPayload get the hexadecimal value of the SHA256 hash of // the request payload.
[ "getHashedPayload", "get", "the", "hexadecimal", "value", "of", "the", "SHA256", "hash", "of", "the", "request", "payload", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L115-L122
148,634
minio/minio-go
pkg/s3signer/request-signature-v4.go
getCanonicalHeaders
func getCanonicalHeaders(req http.Request, ignoredHeaders map[string]bool) string { var headers []string vals := make(map[string][]string) for k, vv := range req.Header { if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { continue // ignored header } headers = append(headers, strings.ToLower(k)) vals[strings.ToLower(k)] = vv } headers = append(headers, "host") sort.Strings(headers) var buf bytes.Buffer // Save all the headers in canonical form <header>:<value> newline // separated for each header. for _, k := range headers { buf.WriteString(k) buf.WriteByte(':') switch { case k == "host": buf.WriteString(getHostAddr(&req)) fallthrough default: for idx, v := range vals[k] { if idx > 0 { buf.WriteByte(',') } buf.WriteString(signV4TrimAll(v)) } buf.WriteByte('\n') } } return buf.String() }
go
func getCanonicalHeaders(req http.Request, ignoredHeaders map[string]bool) string { var headers []string vals := make(map[string][]string) for k, vv := range req.Header { if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { continue // ignored header } headers = append(headers, strings.ToLower(k)) vals[strings.ToLower(k)] = vv } headers = append(headers, "host") sort.Strings(headers) var buf bytes.Buffer // Save all the headers in canonical form <header>:<value> newline // separated for each header. for _, k := range headers { buf.WriteString(k) buf.WriteByte(':') switch { case k == "host": buf.WriteString(getHostAddr(&req)) fallthrough default: for idx, v := range vals[k] { if idx > 0 { buf.WriteByte(',') } buf.WriteString(signV4TrimAll(v)) } buf.WriteByte('\n') } } return buf.String() }
[ "func", "getCanonicalHeaders", "(", "req", "http", ".", "Request", ",", "ignoredHeaders", "map", "[", "string", "]", "bool", ")", "string", "{", "var", "headers", "[", "]", "string", "\n", "vals", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "string", ")", "\n", "for", "k", ",", "vv", ":=", "range", "req", ".", "Header", "{", "if", "_", ",", "ok", ":=", "ignoredHeaders", "[", "http", ".", "CanonicalHeaderKey", "(", "k", ")", "]", ";", "ok", "{", "continue", "// ignored header", "\n", "}", "\n", "headers", "=", "append", "(", "headers", ",", "strings", ".", "ToLower", "(", "k", ")", ")", "\n", "vals", "[", "strings", ".", "ToLower", "(", "k", ")", "]", "=", "vv", "\n", "}", "\n", "headers", "=", "append", "(", "headers", ",", "\"", "\"", ")", "\n", "sort", ".", "Strings", "(", "headers", ")", "\n\n", "var", "buf", "bytes", ".", "Buffer", "\n", "// Save all the headers in canonical form <header>:<value> newline", "// separated for each header.", "for", "_", ",", "k", ":=", "range", "headers", "{", "buf", ".", "WriteString", "(", "k", ")", "\n", "buf", ".", "WriteByte", "(", "':'", ")", "\n", "switch", "{", "case", "k", "==", "\"", "\"", ":", "buf", ".", "WriteString", "(", "getHostAddr", "(", "&", "req", ")", ")", "\n", "fallthrough", "\n", "default", ":", "for", "idx", ",", "v", ":=", "range", "vals", "[", "k", "]", "{", "if", "idx", ">", "0", "{", "buf", ".", "WriteByte", "(", "','", ")", "\n", "}", "\n", "buf", ".", "WriteString", "(", "signV4TrimAll", "(", "v", ")", ")", "\n", "}", "\n", "buf", ".", "WriteByte", "(", "'\\n'", ")", "\n", "}", "\n", "}", "\n", "return", "buf", ".", "String", "(", ")", "\n", "}" ]
// getCanonicalHeaders generate a list of request headers for // signature.
[ "getCanonicalHeaders", "generate", "a", "list", "of", "request", "headers", "for", "signature", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L126-L160
148,635
minio/minio-go
pkg/s3signer/request-signature-v4.go
getSignedHeaders
func getSignedHeaders(req http.Request, ignoredHeaders map[string]bool) string { var headers []string for k := range req.Header { if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { continue // Ignored header found continue. } headers = append(headers, strings.ToLower(k)) } headers = append(headers, "host") sort.Strings(headers) return strings.Join(headers, ";") }
go
func getSignedHeaders(req http.Request, ignoredHeaders map[string]bool) string { var headers []string for k := range req.Header { if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { continue // Ignored header found continue. } headers = append(headers, strings.ToLower(k)) } headers = append(headers, "host") sort.Strings(headers) return strings.Join(headers, ";") }
[ "func", "getSignedHeaders", "(", "req", "http", ".", "Request", ",", "ignoredHeaders", "map", "[", "string", "]", "bool", ")", "string", "{", "var", "headers", "[", "]", "string", "\n", "for", "k", ":=", "range", "req", ".", "Header", "{", "if", "_", ",", "ok", ":=", "ignoredHeaders", "[", "http", ".", "CanonicalHeaderKey", "(", "k", ")", "]", ";", "ok", "{", "continue", "// Ignored header found continue.", "\n", "}", "\n", "headers", "=", "append", "(", "headers", ",", "strings", ".", "ToLower", "(", "k", ")", ")", "\n", "}", "\n", "headers", "=", "append", "(", "headers", ",", "\"", "\"", ")", "\n", "sort", ".", "Strings", "(", "headers", ")", "\n", "return", "strings", ".", "Join", "(", "headers", ",", "\"", "\"", ")", "\n", "}" ]
// getSignedHeaders generate all signed request headers. // i.e lexically sorted, semicolon-separated list of lowercase // request header names.
[ "getSignedHeaders", "generate", "all", "signed", "request", "headers", ".", "i", ".", "e", "lexically", "sorted", "semicolon", "-", "separated", "list", "of", "lowercase", "request", "header", "names", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L165-L176
148,636
minio/minio-go
pkg/s3signer/request-signature-v4.go
PostPresignSignatureV4
func PostPresignSignatureV4(policyBase64 string, t time.Time, secretAccessKey, location string) string { // Get signining key. signingkey := getSigningKey(secretAccessKey, location, t) // Calculate signature. signature := getSignature(signingkey, policyBase64) return signature }
go
func PostPresignSignatureV4(policyBase64 string, t time.Time, secretAccessKey, location string) string { // Get signining key. signingkey := getSigningKey(secretAccessKey, location, t) // Calculate signature. signature := getSignature(signingkey, policyBase64) return signature }
[ "func", "PostPresignSignatureV4", "(", "policyBase64", "string", ",", "t", "time", ".", "Time", ",", "secretAccessKey", ",", "location", "string", ")", "string", "{", "// Get signining key.", "signingkey", ":=", "getSigningKey", "(", "secretAccessKey", ",", "location", ",", "t", ")", "\n", "// Calculate signature.", "signature", ":=", "getSignature", "(", "signingkey", ",", "policyBase64", ")", "\n", "return", "signature", "\n", "}" ]
// PostPresignSignatureV4 - presigned signature for PostPolicy // requests.
[ "PostPresignSignatureV4", "-", "presigned", "signature", "for", "PostPolicy", "requests", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L258-L264
148,637
minio/minio-go
utils.go
sum256Hex
func sum256Hex(data []byte) string { hash := sha256.New() hash.Write(data) return hex.EncodeToString(hash.Sum(nil)) }
go
func sum256Hex(data []byte) string { hash := sha256.New() hash.Write(data) return hex.EncodeToString(hash.Sum(nil)) }
[ "func", "sum256Hex", "(", "data", "[", "]", "byte", ")", "string", "{", "hash", ":=", "sha256", ".", "New", "(", ")", "\n", "hash", ".", "Write", "(", "data", ")", "\n", "return", "hex", ".", "EncodeToString", "(", "hash", ".", "Sum", "(", "nil", ")", ")", "\n", "}" ]
// sum256 calculate sha256sum for an input byte array, returns hex encoded.
[ "sum256", "calculate", "sha256sum", "for", "an", "input", "byte", "array", "returns", "hex", "encoded", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L45-L49
148,638
minio/minio-go
utils.go
sumMD5Base64
func sumMD5Base64(data []byte) string { hash := md5.New() hash.Write(data) return base64.StdEncoding.EncodeToString(hash.Sum(nil)) }
go
func sumMD5Base64(data []byte) string { hash := md5.New() hash.Write(data) return base64.StdEncoding.EncodeToString(hash.Sum(nil)) }
[ "func", "sumMD5Base64", "(", "data", "[", "]", "byte", ")", "string", "{", "hash", ":=", "md5", ".", "New", "(", ")", "\n", "hash", ".", "Write", "(", "data", ")", "\n", "return", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "hash", ".", "Sum", "(", "nil", ")", ")", "\n", "}" ]
// sumMD5Base64 calculate md5sum for an input byte array, returns base64 encoded.
[ "sumMD5Base64", "calculate", "md5sum", "for", "an", "input", "byte", "array", "returns", "base64", "encoded", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L52-L56
148,639
minio/minio-go
utils.go
getEndpointURL
func getEndpointURL(endpoint string, secure bool) (*url.URL, error) { if strings.Contains(endpoint, ":") { host, _, err := net.SplitHostPort(endpoint) if err != nil { return nil, err } if !s3utils.IsValidIP(host) && !s3utils.IsValidDomain(host) { msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards." return nil, ErrInvalidArgument(msg) } } else { if !s3utils.IsValidIP(endpoint) && !s3utils.IsValidDomain(endpoint) { msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards." return nil, ErrInvalidArgument(msg) } } // If secure is false, use 'http' scheme. scheme := "https" if !secure { scheme = "http" } // Construct a secured endpoint URL. endpointURLStr := scheme + "://" + endpoint endpointURL, err := url.Parse(endpointURLStr) if err != nil { return nil, err } // Validate incoming endpoint URL. if err := isValidEndpointURL(*endpointURL); err != nil { return nil, err } return endpointURL, nil }
go
func getEndpointURL(endpoint string, secure bool) (*url.URL, error) { if strings.Contains(endpoint, ":") { host, _, err := net.SplitHostPort(endpoint) if err != nil { return nil, err } if !s3utils.IsValidIP(host) && !s3utils.IsValidDomain(host) { msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards." return nil, ErrInvalidArgument(msg) } } else { if !s3utils.IsValidIP(endpoint) && !s3utils.IsValidDomain(endpoint) { msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards." return nil, ErrInvalidArgument(msg) } } // If secure is false, use 'http' scheme. scheme := "https" if !secure { scheme = "http" } // Construct a secured endpoint URL. endpointURLStr := scheme + "://" + endpoint endpointURL, err := url.Parse(endpointURLStr) if err != nil { return nil, err } // Validate incoming endpoint URL. if err := isValidEndpointURL(*endpointURL); err != nil { return nil, err } return endpointURL, nil }
[ "func", "getEndpointURL", "(", "endpoint", "string", ",", "secure", "bool", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "if", "strings", ".", "Contains", "(", "endpoint", ",", "\"", "\"", ")", "{", "host", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "!", "s3utils", ".", "IsValidIP", "(", "host", ")", "&&", "!", "s3utils", ".", "IsValidDomain", "(", "host", ")", "{", "msg", ":=", "\"", "\"", "+", "endpoint", "+", "\"", "\"", "\n", "return", "nil", ",", "ErrInvalidArgument", "(", "msg", ")", "\n", "}", "\n", "}", "else", "{", "if", "!", "s3utils", ".", "IsValidIP", "(", "endpoint", ")", "&&", "!", "s3utils", ".", "IsValidDomain", "(", "endpoint", ")", "{", "msg", ":=", "\"", "\"", "+", "endpoint", "+", "\"", "\"", "\n", "return", "nil", ",", "ErrInvalidArgument", "(", "msg", ")", "\n", "}", "\n", "}", "\n", "// If secure is false, use 'http' scheme.", "scheme", ":=", "\"", "\"", "\n", "if", "!", "secure", "{", "scheme", "=", "\"", "\"", "\n", "}", "\n\n", "// Construct a secured endpoint URL.", "endpointURLStr", ":=", "scheme", "+", "\"", "\"", "+", "endpoint", "\n", "endpointURL", ",", "err", ":=", "url", ".", "Parse", "(", "endpointURLStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Validate incoming endpoint URL.", "if", "err", ":=", "isValidEndpointURL", "(", "*", "endpointURL", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "endpointURL", ",", "nil", "\n", "}" ]
// getEndpointURL - construct a new endpoint.
[ "getEndpointURL", "-", "construct", "a", "new", "endpoint", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L59-L93
148,640
minio/minio-go
utils.go
isValidExpiry
func isValidExpiry(expires time.Duration) error { expireSeconds := int64(expires / time.Second) if expireSeconds < 1 { return ErrInvalidArgument("Expires cannot be lesser than 1 second.") } if expireSeconds > 604800 { return ErrInvalidArgument("Expires cannot be greater than 7 days.") } return nil }
go
func isValidExpiry(expires time.Duration) error { expireSeconds := int64(expires / time.Second) if expireSeconds < 1 { return ErrInvalidArgument("Expires cannot be lesser than 1 second.") } if expireSeconds > 604800 { return ErrInvalidArgument("Expires cannot be greater than 7 days.") } return nil }
[ "func", "isValidExpiry", "(", "expires", "time", ".", "Duration", ")", "error", "{", "expireSeconds", ":=", "int64", "(", "expires", "/", "time", ".", "Second", ")", "\n", "if", "expireSeconds", "<", "1", "{", "return", "ErrInvalidArgument", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "expireSeconds", ">", "604800", "{", "return", "ErrInvalidArgument", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Verify if input expires value is valid.
[ "Verify", "if", "input", "expires", "value", "is", "valid", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L145-L154
148,641
minio/minio-go
utils.go
cloneHeader
func cloneHeader(h http.Header) http.Header { h2 := make(http.Header, len(h)) for k, vv := range h { vv2 := make([]string, len(vv)) copy(vv2, vv) h2[k] = vv2 } return h2 }
go
func cloneHeader(h http.Header) http.Header { h2 := make(http.Header, len(h)) for k, vv := range h { vv2 := make([]string, len(vv)) copy(vv2, vv) h2[k] = vv2 } return h2 }
[ "func", "cloneHeader", "(", "h", "http", ".", "Header", ")", "http", ".", "Header", "{", "h2", ":=", "make", "(", "http", ".", "Header", ",", "len", "(", "h", ")", ")", "\n", "for", "k", ",", "vv", ":=", "range", "h", "{", "vv2", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "vv", ")", ")", "\n", "copy", "(", "vv2", ",", "vv", ")", "\n", "h2", "[", "k", "]", "=", "vv2", "\n", "}", "\n", "return", "h2", "\n", "}" ]
// make a copy of http.Header
[ "make", "a", "copy", "of", "http", ".", "Header" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L157-L165
148,642
minio/minio-go
utils.go
filterHeader
func filterHeader(header http.Header, filterKeys []string) (filteredHeader http.Header) { filteredHeader = cloneHeader(header) for _, key := range filterKeys { filteredHeader.Del(key) } return filteredHeader }
go
func filterHeader(header http.Header, filterKeys []string) (filteredHeader http.Header) { filteredHeader = cloneHeader(header) for _, key := range filterKeys { filteredHeader.Del(key) } return filteredHeader }
[ "func", "filterHeader", "(", "header", "http", ".", "Header", ",", "filterKeys", "[", "]", "string", ")", "(", "filteredHeader", "http", ".", "Header", ")", "{", "filteredHeader", "=", "cloneHeader", "(", "header", ")", "\n", "for", "_", ",", "key", ":=", "range", "filterKeys", "{", "filteredHeader", ".", "Del", "(", "key", ")", "\n", "}", "\n", "return", "filteredHeader", "\n", "}" ]
// Filter relevant response headers from // the HEAD, GET http response. The function takes // a list of headers which are filtered out and // returned as a new http header.
[ "Filter", "relevant", "response", "headers", "from", "the", "HEAD", "GET", "http", "response", ".", "The", "function", "takes", "a", "list", "of", "headers", "which", "are", "filtered", "out", "and", "returned", "as", "a", "new", "http", "header", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L171-L177
148,643
minio/minio-go
utils.go
redactSignature
func redactSignature(origAuth string) string { if !strings.HasPrefix(origAuth, signV4Algorithm) { // Set a temporary redacted auth return "AWS **REDACTED**:**REDACTED**" } /// Signature V4 authorization header. // Strip out accessKeyID from: // Credential=<access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request newAuth := regCred.ReplaceAllString(origAuth, "Credential=**REDACTED**/") // Strip out 256-bit signature from: Signature=<256-bit signature> return regSign.ReplaceAllString(newAuth, "Signature=**REDACTED**") }
go
func redactSignature(origAuth string) string { if !strings.HasPrefix(origAuth, signV4Algorithm) { // Set a temporary redacted auth return "AWS **REDACTED**:**REDACTED**" } /// Signature V4 authorization header. // Strip out accessKeyID from: // Credential=<access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request newAuth := regCred.ReplaceAllString(origAuth, "Credential=**REDACTED**/") // Strip out 256-bit signature from: Signature=<256-bit signature> return regSign.ReplaceAllString(newAuth, "Signature=**REDACTED**") }
[ "func", "redactSignature", "(", "origAuth", "string", ")", "string", "{", "if", "!", "strings", ".", "HasPrefix", "(", "origAuth", ",", "signV4Algorithm", ")", "{", "// Set a temporary redacted auth", "return", "\"", "\"", "\n", "}", "\n\n", "/// Signature V4 authorization header.", "// Strip out accessKeyID from:", "// Credential=<access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request", "newAuth", ":=", "regCred", ".", "ReplaceAllString", "(", "origAuth", ",", "\"", "\"", ")", "\n\n", "// Strip out 256-bit signature from: Signature=<256-bit signature>", "return", "regSign", ".", "ReplaceAllString", "(", "newAuth", ",", "\"", "\"", ")", "\n", "}" ]
// Redact out signature value from authorization string.
[ "Redact", "out", "signature", "value", "from", "authorization", "string", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L186-L200
148,644
minio/minio-go
utils.go
getDefaultLocation
func getDefaultLocation(u url.URL, regionOverride string) (location string) { if regionOverride != "" { return regionOverride } region := s3utils.GetRegionFromURL(u) if region == "" { region = "us-east-1" } return region }
go
func getDefaultLocation(u url.URL, regionOverride string) (location string) { if regionOverride != "" { return regionOverride } region := s3utils.GetRegionFromURL(u) if region == "" { region = "us-east-1" } return region }
[ "func", "getDefaultLocation", "(", "u", "url", ".", "URL", ",", "regionOverride", "string", ")", "(", "location", "string", ")", "{", "if", "regionOverride", "!=", "\"", "\"", "{", "return", "regionOverride", "\n", "}", "\n", "region", ":=", "s3utils", ".", "GetRegionFromURL", "(", "u", ")", "\n", "if", "region", "==", "\"", "\"", "{", "region", "=", "\"", "\"", "\n", "}", "\n", "return", "region", "\n", "}" ]
// Get default location returns the location based on the input // URL `u`, if region override is provided then all location // defaults to regionOverride. // // If no other cases match then the location is set to `us-east-1` // as a last resort.
[ "Get", "default", "location", "returns", "the", "location", "based", "on", "the", "input", "URL", "u", "if", "region", "override", "is", "provided", "then", "all", "location", "defaults", "to", "regionOverride", ".", "If", "no", "other", "cases", "match", "then", "the", "location", "is", "set", "to", "us", "-", "east", "-", "1", "as", "a", "last", "resort", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L208-L217
148,645
minio/minio-go
utils.go
isStorageClassHeader
func isStorageClassHeader(headerKey string) bool { return strings.ToLower(amzStorageClass) == strings.ToLower(headerKey) }
go
func isStorageClassHeader(headerKey string) bool { return strings.ToLower(amzStorageClass) == strings.ToLower(headerKey) }
[ "func", "isStorageClassHeader", "(", "headerKey", "string", ")", "bool", "{", "return", "strings", ".", "ToLower", "(", "amzStorageClass", ")", "==", "strings", ".", "ToLower", "(", "headerKey", ")", "\n", "}" ]
// isStorageClassHeader returns true if the header is a supported storage class header
[ "isStorageClassHeader", "returns", "true", "if", "the", "header", "is", "a", "supported", "storage", "class", "header" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L231-L233
148,646
minio/minio-go
utils.go
isStandardHeader
func isStandardHeader(headerKey string) bool { key := strings.ToLower(headerKey) for _, header := range supportedHeaders { if strings.ToLower(header) == key { return true } } return false }
go
func isStandardHeader(headerKey string) bool { key := strings.ToLower(headerKey) for _, header := range supportedHeaders { if strings.ToLower(header) == key { return true } } return false }
[ "func", "isStandardHeader", "(", "headerKey", "string", ")", "bool", "{", "key", ":=", "strings", ".", "ToLower", "(", "headerKey", ")", "\n", "for", "_", ",", "header", ":=", "range", "supportedHeaders", "{", "if", "strings", ".", "ToLower", "(", "header", ")", "==", "key", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// isStandardHeader returns true if header is a supported header and not a custom header
[ "isStandardHeader", "returns", "true", "if", "header", "is", "a", "supported", "header", "and", "not", "a", "custom", "header" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L236-L244
148,647
minio/minio-go
utils.go
isSSEHeader
func isSSEHeader(headerKey string) bool { key := strings.ToLower(headerKey) for _, h := range sseHeaders { if strings.ToLower(h) == key { return true } } return false }
go
func isSSEHeader(headerKey string) bool { key := strings.ToLower(headerKey) for _, h := range sseHeaders { if strings.ToLower(h) == key { return true } } return false }
[ "func", "isSSEHeader", "(", "headerKey", "string", ")", "bool", "{", "key", ":=", "strings", ".", "ToLower", "(", "headerKey", ")", "\n", "for", "_", ",", "h", ":=", "range", "sseHeaders", "{", "if", "strings", ".", "ToLower", "(", "h", ")", "==", "key", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// isSSEHeader returns true if header is a server side encryption header.
[ "isSSEHeader", "returns", "true", "if", "header", "is", "a", "server", "side", "encryption", "header", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L257-L265
148,648
minio/minio-go
pkg/credentials/file_minio_client.go
NewFileMinioClient
func NewFileMinioClient(filename string, alias string) *Credentials { return New(&FileMinioClient{ filename: filename, alias: alias, }) }
go
func NewFileMinioClient(filename string, alias string) *Credentials { return New(&FileMinioClient{ filename: filename, alias: alias, }) }
[ "func", "NewFileMinioClient", "(", "filename", "string", ",", "alias", "string", ")", "*", "Credentials", "{", "return", "New", "(", "&", "FileMinioClient", "{", "filename", ":", "filename", ",", "alias", ":", "alias", ",", "}", ")", "\n", "}" ]
// NewFileMinioClient returns a pointer to a new Credentials object // wrapping the Alias file provider.
[ "NewFileMinioClient", "returns", "a", "pointer", "to", "a", "new", "Credentials", "object", "wrapping", "the", "Alias", "file", "provider", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/file_minio_client.go#L54-L59
148,649
minio/minio-go
pkg/credentials/file_minio_client.go
loadAlias
func loadAlias(filename, alias string) (hostConfig, error) { cfg := &config{} configBytes, err := ioutil.ReadFile(filename) if err != nil { return hostConfig{}, err } if err = json.Unmarshal(configBytes, cfg); err != nil { return hostConfig{}, err } return cfg.Hosts[alias], nil }
go
func loadAlias(filename, alias string) (hostConfig, error) { cfg := &config{} configBytes, err := ioutil.ReadFile(filename) if err != nil { return hostConfig{}, err } if err = json.Unmarshal(configBytes, cfg); err != nil { return hostConfig{}, err } return cfg.Hosts[alias], nil }
[ "func", "loadAlias", "(", "filename", ",", "alias", "string", ")", "(", "hostConfig", ",", "error", ")", "{", "cfg", ":=", "&", "config", "{", "}", "\n", "configBytes", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "hostConfig", "{", "}", ",", "err", "\n", "}", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "configBytes", ",", "cfg", ")", ";", "err", "!=", "nil", "{", "return", "hostConfig", "{", "}", ",", "err", "\n", "}", "\n", "return", "cfg", ".", "Hosts", "[", "alias", "]", ",", "nil", "\n", "}" ]
// loadAliass loads from the file pointed to by shared credentials filename for alias. // The credentials retrieved from the alias will be returned or error. Error will be // returned if it fails to read from the file.
[ "loadAliass", "loads", "from", "the", "file", "pointed", "to", "by", "shared", "credentials", "filename", "for", "alias", ".", "The", "credentials", "retrieved", "from", "the", "alias", "will", "be", "returned", "or", "error", ".", "Error", "will", "be", "returned", "if", "it", "fails", "to", "read", "from", "the", "file", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/file_minio_client.go#L123-L133
148,650
minio/minio-go
api-get-object-acl.go
GetObjectACL
func (c Client) GetObjectACL(bucketName, objectName string) (*ObjectInfo, error) { resp, err := c.executeMethod(context.Background(), "GET", requestMetadata{ bucketName: bucketName, objectName: objectName, queryValues: url.Values{ "acl": []string{""}, }, }) if err != nil { return nil, err } defer closeResponse(resp) if resp.StatusCode != http.StatusOK { return nil, httpRespToErrorResponse(resp, bucketName, objectName) } res := &accessControlPolicy{} if err := xmlDecoder(resp.Body, res); err != nil { return nil, err } objInfo, err := c.statObject(context.Background(), bucketName, objectName, StatObjectOptions{}) if err != nil { return nil, err } cannedACL := getCannedACL(res) if cannedACL != "" { objInfo.Metadata.Add("X-Amz-Acl", cannedACL) return &objInfo, nil } grantACL := getAmzGrantACL(res) for k, v := range grantACL { objInfo.Metadata[k] = v } return &objInfo, nil }
go
func (c Client) GetObjectACL(bucketName, objectName string) (*ObjectInfo, error) { resp, err := c.executeMethod(context.Background(), "GET", requestMetadata{ bucketName: bucketName, objectName: objectName, queryValues: url.Values{ "acl": []string{""}, }, }) if err != nil { return nil, err } defer closeResponse(resp) if resp.StatusCode != http.StatusOK { return nil, httpRespToErrorResponse(resp, bucketName, objectName) } res := &accessControlPolicy{} if err := xmlDecoder(resp.Body, res); err != nil { return nil, err } objInfo, err := c.statObject(context.Background(), bucketName, objectName, StatObjectOptions{}) if err != nil { return nil, err } cannedACL := getCannedACL(res) if cannedACL != "" { objInfo.Metadata.Add("X-Amz-Acl", cannedACL) return &objInfo, nil } grantACL := getAmzGrantACL(res) for k, v := range grantACL { objInfo.Metadata[k] = v } return &objInfo, nil }
[ "func", "(", "c", "Client", ")", "GetObjectACL", "(", "bucketName", ",", "objectName", "string", ")", "(", "*", "ObjectInfo", ",", "error", ")", "{", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "context", ".", "Background", "(", ")", ",", "\"", "\"", ",", "requestMetadata", "{", "bucketName", ":", "bucketName", ",", "objectName", ":", "objectName", ",", "queryValues", ":", "url", ".", "Values", "{", "\"", "\"", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "closeResponse", "(", "resp", ")", "\n\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "return", "nil", ",", "httpRespToErrorResponse", "(", "resp", ",", "bucketName", ",", "objectName", ")", "\n", "}", "\n\n", "res", ":=", "&", "accessControlPolicy", "{", "}", "\n\n", "if", "err", ":=", "xmlDecoder", "(", "resp", ".", "Body", ",", "res", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "objInfo", ",", "err", ":=", "c", ".", "statObject", "(", "context", ".", "Background", "(", ")", ",", "bucketName", ",", "objectName", ",", "StatObjectOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "cannedACL", ":=", "getCannedACL", "(", "res", ")", "\n", "if", "cannedACL", "!=", "\"", "\"", "{", "objInfo", ".", "Metadata", ".", "Add", "(", "\"", "\"", ",", "cannedACL", ")", "\n", "return", "&", "objInfo", ",", "nil", "\n", "}", "\n\n", "grantACL", ":=", "getAmzGrantACL", "(", "res", ")", "\n", "for", "k", ",", "v", ":=", "range", "grantACL", "{", "objInfo", ".", "Metadata", "[", "k", "]", "=", "v", "\n", "}", "\n\n", "return", "&", "objInfo", ",", "nil", "\n", "}" ]
//GetObjectACL get object ACLs
[ "GetObjectACL", "get", "object", "ACLs" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object-acl.go#L44-L85
148,651
minio/minio-go
api-compose-object.go
SetRange
func (s *SourceInfo) SetRange(start, end int64) error { if start > end || start < 0 { return ErrInvalidArgument("start must be non-negative, and start must be at most end.") } // Note that 0 <= start <= end s.start, s.end = start, end return nil }
go
func (s *SourceInfo) SetRange(start, end int64) error { if start > end || start < 0 { return ErrInvalidArgument("start must be non-negative, and start must be at most end.") } // Note that 0 <= start <= end s.start, s.end = start, end return nil }
[ "func", "(", "s", "*", "SourceInfo", ")", "SetRange", "(", "start", ",", "end", "int64", ")", "error", "{", "if", "start", ">", "end", "||", "start", "<", "0", "{", "return", "ErrInvalidArgument", "(", "\"", "\"", ")", "\n", "}", "\n", "// Note that 0 <= start <= end", "s", ".", "start", ",", "s", ".", "end", "=", "start", ",", "end", "\n", "return", "nil", "\n", "}" ]
// SetRange - Set the start and end offset of the source object to be // copied. If this method is not called, the whole source object is // copied.
[ "SetRange", "-", "Set", "the", "start", "and", "end", "offset", "of", "the", "source", "object", "to", "be", "copied", ".", "If", "this", "method", "is", "not", "called", "the", "whole", "source", "object", "is", "copied", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L147-L154
148,652
minio/minio-go
api-compose-object.go
SetMatchETagCond
func (s *SourceInfo) SetMatchETagCond(etag string) error { if etag == "" { return ErrInvalidArgument("ETag cannot be empty.") } s.Headers.Set("x-amz-copy-source-if-match", etag) return nil }
go
func (s *SourceInfo) SetMatchETagCond(etag string) error { if etag == "" { return ErrInvalidArgument("ETag cannot be empty.") } s.Headers.Set("x-amz-copy-source-if-match", etag) return nil }
[ "func", "(", "s", "*", "SourceInfo", ")", "SetMatchETagCond", "(", "etag", "string", ")", "error", "{", "if", "etag", "==", "\"", "\"", "{", "return", "ErrInvalidArgument", "(", "\"", "\"", ")", "\n", "}", "\n", "s", ".", "Headers", ".", "Set", "(", "\"", "\"", ",", "etag", ")", "\n", "return", "nil", "\n", "}" ]
// SetMatchETagCond - Set ETag match condition. The object is copied // only if the etag of the source matches the value given here.
[ "SetMatchETagCond", "-", "Set", "ETag", "match", "condition", ".", "The", "object", "is", "copied", "only", "if", "the", "etag", "of", "the", "source", "matches", "the", "value", "given", "here", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L158-L164
148,653
minio/minio-go
api-compose-object.go
SetModifiedSinceCond
func (s *SourceInfo) SetModifiedSinceCond(modTime time.Time) error { if modTime.IsZero() { return ErrInvalidArgument("Input time cannot be 0.") } s.Headers.Set("x-amz-copy-source-if-modified-since", modTime.Format(http.TimeFormat)) return nil }
go
func (s *SourceInfo) SetModifiedSinceCond(modTime time.Time) error { if modTime.IsZero() { return ErrInvalidArgument("Input time cannot be 0.") } s.Headers.Set("x-amz-copy-source-if-modified-since", modTime.Format(http.TimeFormat)) return nil }
[ "func", "(", "s", "*", "SourceInfo", ")", "SetModifiedSinceCond", "(", "modTime", "time", ".", "Time", ")", "error", "{", "if", "modTime", ".", "IsZero", "(", ")", "{", "return", "ErrInvalidArgument", "(", "\"", "\"", ")", "\n", "}", "\n", "s", ".", "Headers", ".", "Set", "(", "\"", "\"", ",", "modTime", ".", "Format", "(", "http", ".", "TimeFormat", ")", ")", "\n", "return", "nil", "\n", "}" ]
// SetModifiedSinceCond - Set the modified since condition.
[ "SetModifiedSinceCond", "-", "Set", "the", "modified", "since", "condition", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L178-L184
148,654
minio/minio-go
api-compose-object.go
getProps
func (s *SourceInfo) getProps(c Client) (size int64, etag string, userMeta map[string]string, err error) { // Get object info - need size and etag here. Also, decryption // headers are added to the stat request if given. var objInfo ObjectInfo opts := StatObjectOptions{GetObjectOptions{ServerSideEncryption: encrypt.SSE(s.encryption)}} objInfo, err = c.statObject(context.Background(), s.bucket, s.object, opts) if err != nil { err = ErrInvalidArgument(fmt.Sprintf("Could not stat object - %s/%s: %v", s.bucket, s.object, err)) } else { size = objInfo.Size etag = objInfo.ETag userMeta = make(map[string]string) for k, v := range objInfo.Metadata { if strings.HasPrefix(k, "x-amz-meta-") { if len(v) > 0 { userMeta[k] = v[0] } } } } return }
go
func (s *SourceInfo) getProps(c Client) (size int64, etag string, userMeta map[string]string, err error) { // Get object info - need size and etag here. Also, decryption // headers are added to the stat request if given. var objInfo ObjectInfo opts := StatObjectOptions{GetObjectOptions{ServerSideEncryption: encrypt.SSE(s.encryption)}} objInfo, err = c.statObject(context.Background(), s.bucket, s.object, opts) if err != nil { err = ErrInvalidArgument(fmt.Sprintf("Could not stat object - %s/%s: %v", s.bucket, s.object, err)) } else { size = objInfo.Size etag = objInfo.ETag userMeta = make(map[string]string) for k, v := range objInfo.Metadata { if strings.HasPrefix(k, "x-amz-meta-") { if len(v) > 0 { userMeta[k] = v[0] } } } } return }
[ "func", "(", "s", "*", "SourceInfo", ")", "getProps", "(", "c", "Client", ")", "(", "size", "int64", ",", "etag", "string", ",", "userMeta", "map", "[", "string", "]", "string", ",", "err", "error", ")", "{", "// Get object info - need size and etag here. Also, decryption", "// headers are added to the stat request if given.", "var", "objInfo", "ObjectInfo", "\n", "opts", ":=", "StatObjectOptions", "{", "GetObjectOptions", "{", "ServerSideEncryption", ":", "encrypt", ".", "SSE", "(", "s", ".", "encryption", ")", "}", "}", "\n", "objInfo", ",", "err", "=", "c", ".", "statObject", "(", "context", ".", "Background", "(", ")", ",", "s", ".", "bucket", ",", "s", ".", "object", ",", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "err", "=", "ErrInvalidArgument", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "bucket", ",", "s", ".", "object", ",", "err", ")", ")", "\n", "}", "else", "{", "size", "=", "objInfo", ".", "Size", "\n", "etag", "=", "objInfo", ".", "ETag", "\n", "userMeta", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "k", ",", "v", ":=", "range", "objInfo", ".", "Metadata", "{", "if", "strings", ".", "HasPrefix", "(", "k", ",", "\"", "\"", ")", "{", "if", "len", "(", "v", ")", ">", "0", "{", "userMeta", "[", "k", "]", "=", "v", "[", "0", "]", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// Helper to fetch size and etag of an object using a StatObject call.
[ "Helper", "to", "fetch", "size", "and", "etag", "of", "an", "object", "using", "a", "StatObject", "call", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L196-L217
148,655
minio/minio-go
api-compose-object.go
copyObjectDo
func (c Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, metadata map[string]string) (ObjectInfo, error) { // Build headers. headers := make(http.Header) // Set all the metadata headers. for k, v := range metadata { headers.Set(k, v) } // Set the source header headers.Set("x-amz-copy-source", s3utils.EncodePath(srcBucket+"/"+srcObject)) // Send upload-part-copy request resp, err := c.executeMethod(ctx, "PUT", requestMetadata{ bucketName: destBucket, objectName: destObject, customHeader: headers, }) defer closeResponse(resp) if err != nil { return ObjectInfo{}, err } // Check if we got an error response. if resp.StatusCode != http.StatusOK { return ObjectInfo{}, httpRespToErrorResponse(resp, srcBucket, srcObject) } cpObjRes := copyObjectResult{} err = xmlDecoder(resp.Body, &cpObjRes) if err != nil { return ObjectInfo{}, err } objInfo := ObjectInfo{ Key: destObject, ETag: strings.Trim(cpObjRes.ETag, "\""), LastModified: cpObjRes.LastModified, } return objInfo, nil }
go
func (c Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, metadata map[string]string) (ObjectInfo, error) { // Build headers. headers := make(http.Header) // Set all the metadata headers. for k, v := range metadata { headers.Set(k, v) } // Set the source header headers.Set("x-amz-copy-source", s3utils.EncodePath(srcBucket+"/"+srcObject)) // Send upload-part-copy request resp, err := c.executeMethod(ctx, "PUT", requestMetadata{ bucketName: destBucket, objectName: destObject, customHeader: headers, }) defer closeResponse(resp) if err != nil { return ObjectInfo{}, err } // Check if we got an error response. if resp.StatusCode != http.StatusOK { return ObjectInfo{}, httpRespToErrorResponse(resp, srcBucket, srcObject) } cpObjRes := copyObjectResult{} err = xmlDecoder(resp.Body, &cpObjRes) if err != nil { return ObjectInfo{}, err } objInfo := ObjectInfo{ Key: destObject, ETag: strings.Trim(cpObjRes.ETag, "\""), LastModified: cpObjRes.LastModified, } return objInfo, nil }
[ "func", "(", "c", "Client", ")", "copyObjectDo", "(", "ctx", "context", ".", "Context", ",", "srcBucket", ",", "srcObject", ",", "destBucket", ",", "destObject", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "(", "ObjectInfo", ",", "error", ")", "{", "// Build headers.", "headers", ":=", "make", "(", "http", ".", "Header", ")", "\n\n", "// Set all the metadata headers.", "for", "k", ",", "v", ":=", "range", "metadata", "{", "headers", ".", "Set", "(", "k", ",", "v", ")", "\n", "}", "\n\n", "// Set the source header", "headers", ".", "Set", "(", "\"", "\"", ",", "s3utils", ".", "EncodePath", "(", "srcBucket", "+", "\"", "\"", "+", "srcObject", ")", ")", "\n\n", "// Send upload-part-copy request", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "ctx", ",", "\"", "\"", ",", "requestMetadata", "{", "bucketName", ":", "destBucket", ",", "objectName", ":", "destObject", ",", "customHeader", ":", "headers", ",", "}", ")", "\n", "defer", "closeResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ObjectInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "// Check if we got an error response.", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "return", "ObjectInfo", "{", "}", ",", "httpRespToErrorResponse", "(", "resp", ",", "srcBucket", ",", "srcObject", ")", "\n", "}", "\n\n", "cpObjRes", ":=", "copyObjectResult", "{", "}", "\n", "err", "=", "xmlDecoder", "(", "resp", ".", "Body", ",", "&", "cpObjRes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ObjectInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "objInfo", ":=", "ObjectInfo", "{", "Key", ":", "destObject", ",", "ETag", ":", "strings", ".", "Trim", "(", "cpObjRes", ".", "ETag", ",", "\"", "\\\"", "\"", ")", ",", "LastModified", ":", "cpObjRes", ".", "LastModified", ",", "}", "\n", "return", "objInfo", ",", "nil", "\n", "}" ]
// Low level implementation of CopyObject API, supports only upto 5GiB worth of copy.
[ "Low", "level", "implementation", "of", "CopyObject", "API", "supports", "only", "upto", "5GiB", "worth", "of", "copy", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L220-L262
148,656
minio/minio-go
api-compose-object.go
calculateEvenSplits
func calculateEvenSplits(size int64, src SourceInfo) (startIndex, endIndex []int64) { if size == 0 { return } reqParts := partsRequired(size) startIndex = make([]int64, reqParts) endIndex = make([]int64, reqParts) // Compute number of required parts `k`, as: // // k = ceiling(size / copyPartSize) // // Now, distribute the `size` bytes in the source into // k parts as evenly as possible: // // r parts sized (q+1) bytes, and // (k - r) parts sized q bytes, where // // size = q * k + r (by simple division of size by k, // so that 0 <= r < k) // start := src.start if start == -1 { start = 0 } quot, rem := size/reqParts, size%reqParts nextStart := start for j := int64(0); j < reqParts; j++ { curPartSize := quot if j < rem { curPartSize++ } cStart := nextStart cEnd := cStart + curPartSize - 1 nextStart = cEnd + 1 startIndex[j], endIndex[j] = cStart, cEnd } return }
go
func calculateEvenSplits(size int64, src SourceInfo) (startIndex, endIndex []int64) { if size == 0 { return } reqParts := partsRequired(size) startIndex = make([]int64, reqParts) endIndex = make([]int64, reqParts) // Compute number of required parts `k`, as: // // k = ceiling(size / copyPartSize) // // Now, distribute the `size` bytes in the source into // k parts as evenly as possible: // // r parts sized (q+1) bytes, and // (k - r) parts sized q bytes, where // // size = q * k + r (by simple division of size by k, // so that 0 <= r < k) // start := src.start if start == -1 { start = 0 } quot, rem := size/reqParts, size%reqParts nextStart := start for j := int64(0); j < reqParts; j++ { curPartSize := quot if j < rem { curPartSize++ } cStart := nextStart cEnd := cStart + curPartSize - 1 nextStart = cEnd + 1 startIndex[j], endIndex[j] = cStart, cEnd } return }
[ "func", "calculateEvenSplits", "(", "size", "int64", ",", "src", "SourceInfo", ")", "(", "startIndex", ",", "endIndex", "[", "]", "int64", ")", "{", "if", "size", "==", "0", "{", "return", "\n", "}", "\n\n", "reqParts", ":=", "partsRequired", "(", "size", ")", "\n", "startIndex", "=", "make", "(", "[", "]", "int64", ",", "reqParts", ")", "\n", "endIndex", "=", "make", "(", "[", "]", "int64", ",", "reqParts", ")", "\n", "// Compute number of required parts `k`, as:", "//", "// k = ceiling(size / copyPartSize)", "//", "// Now, distribute the `size` bytes in the source into", "// k parts as evenly as possible:", "//", "// r parts sized (q+1) bytes, and", "// (k - r) parts sized q bytes, where", "//", "// size = q * k + r (by simple division of size by k,", "// so that 0 <= r < k)", "//", "start", ":=", "src", ".", "start", "\n", "if", "start", "==", "-", "1", "{", "start", "=", "0", "\n", "}", "\n", "quot", ",", "rem", ":=", "size", "/", "reqParts", ",", "size", "%", "reqParts", "\n", "nextStart", ":=", "start", "\n", "for", "j", ":=", "int64", "(", "0", ")", ";", "j", "<", "reqParts", ";", "j", "++", "{", "curPartSize", ":=", "quot", "\n", "if", "j", "<", "rem", "{", "curPartSize", "++", "\n", "}", "\n\n", "cStart", ":=", "nextStart", "\n", "cEnd", ":=", "cStart", "+", "curPartSize", "-", "1", "\n", "nextStart", "=", "cEnd", "+", "1", "\n\n", "startIndex", "[", "j", "]", ",", "endIndex", "[", "j", "]", "=", "cStart", ",", "cEnd", "\n", "}", "\n", "return", "\n", "}" ]
// calculateEvenSplits - computes splits for a source and returns // start and end index slices. Splits happen evenly to be sure that no // part is less than 5MiB, as that could fail the multipart request if // it is not the last part.
[ "calculateEvenSplits", "-", "computes", "splits", "for", "a", "source", "and", "returns", "start", "and", "end", "index", "slices", ".", "Splits", "happen", "evenly", "to", "be", "sure", "that", "no", "part", "is", "less", "than", "5MiB", "as", "that", "could", "fail", "the", "multipart", "request", "if", "it", "is", "not", "the", "last", "part", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L525-L565
148,657
minio/minio-go
pkg/set/stringset.go
ToSlice
func (set StringSet) ToSlice() []string { keys := make([]string, 0, len(set)) for k := range set { keys = append(keys, k) } sort.Strings(keys) return keys }
go
func (set StringSet) ToSlice() []string { keys := make([]string, 0, len(set)) for k := range set { keys = append(keys, k) } sort.Strings(keys) return keys }
[ "func", "(", "set", "StringSet", ")", "ToSlice", "(", ")", "[", "]", "string", "{", "keys", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "set", ")", ")", "\n", "for", "k", ":=", "range", "set", "{", "keys", "=", "append", "(", "keys", ",", "k", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "keys", ")", "\n", "return", "keys", "\n", "}" ]
// ToSlice - returns StringSet as string slice.
[ "ToSlice", "-", "returns", "StringSet", "as", "string", "slice", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L30-L37
148,658
minio/minio-go
pkg/set/stringset.go
Contains
func (set StringSet) Contains(s string) bool { _, ok := set[s] return ok }
go
func (set StringSet) Contains(s string) bool { _, ok := set[s] return ok }
[ "func", "(", "set", "StringSet", ")", "Contains", "(", "s", "string", ")", "bool", "{", "_", ",", "ok", ":=", "set", "[", "s", "]", "\n", "return", "ok", "\n", "}" ]
// Contains - checks if string is in the set.
[ "Contains", "-", "checks", "if", "string", "is", "in", "the", "set", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L55-L58
148,659
minio/minio-go
pkg/set/stringset.go
FuncMatch
func (set StringSet) FuncMatch(matchFn func(string, string) bool, matchString string) StringSet { nset := NewStringSet() for k := range set { if matchFn(k, matchString) { nset.Add(k) } } return nset }
go
func (set StringSet) FuncMatch(matchFn func(string, string) bool, matchString string) StringSet { nset := NewStringSet() for k := range set { if matchFn(k, matchString) { nset.Add(k) } } return nset }
[ "func", "(", "set", "StringSet", ")", "FuncMatch", "(", "matchFn", "func", "(", "string", ",", "string", ")", "bool", ",", "matchString", "string", ")", "StringSet", "{", "nset", ":=", "NewStringSet", "(", ")", "\n", "for", "k", ":=", "range", "set", "{", "if", "matchFn", "(", "k", ",", "matchString", ")", "{", "nset", ".", "Add", "(", "k", ")", "\n", "}", "\n", "}", "\n", "return", "nset", "\n", "}" ]
// FuncMatch - returns new set containing each value who passes match function. // A 'matchFn' should accept element in a set as first argument and // 'matchString' as second argument. The function can do any logic to // compare both the arguments and should return true to accept element in // a set to include in output set else the element is ignored.
[ "FuncMatch", "-", "returns", "new", "set", "containing", "each", "value", "who", "passes", "match", "function", ".", "A", "matchFn", "should", "accept", "element", "in", "a", "set", "as", "first", "argument", "and", "matchString", "as", "second", "argument", ".", "The", "function", "can", "do", "any", "logic", "to", "compare", "both", "the", "arguments", "and", "should", "return", "true", "to", "accept", "element", "in", "a", "set", "to", "include", "in", "output", "set", "else", "the", "element", "is", "ignored", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L65-L73
148,660
minio/minio-go
pkg/set/stringset.go
ApplyFunc
func (set StringSet) ApplyFunc(applyFn func(string) string) StringSet { nset := NewStringSet() for k := range set { nset.Add(applyFn(k)) } return nset }
go
func (set StringSet) ApplyFunc(applyFn func(string) string) StringSet { nset := NewStringSet() for k := range set { nset.Add(applyFn(k)) } return nset }
[ "func", "(", "set", "StringSet", ")", "ApplyFunc", "(", "applyFn", "func", "(", "string", ")", "string", ")", "StringSet", "{", "nset", ":=", "NewStringSet", "(", ")", "\n", "for", "k", ":=", "range", "set", "{", "nset", ".", "Add", "(", "applyFn", "(", "k", ")", ")", "\n", "}", "\n", "return", "nset", "\n", "}" ]
// ApplyFunc - returns new set containing each value processed by 'applyFn'. // A 'applyFn' should accept element in a set as a argument and return // a processed string. The function can do any logic to return a processed // string.
[ "ApplyFunc", "-", "returns", "new", "set", "containing", "each", "value", "processed", "by", "applyFn", ".", "A", "applyFn", "should", "accept", "element", "in", "a", "set", "as", "a", "argument", "and", "return", "a", "processed", "string", ".", "The", "function", "can", "do", "any", "logic", "to", "return", "a", "processed", "string", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L79-L85
148,661
minio/minio-go
pkg/set/stringset.go
Equals
func (set StringSet) Equals(sset StringSet) bool { // If length of set is not equal to length of given set, the // set is not equal to given set. if len(set) != len(sset) { return false } // As both sets are equal in length, check each elements are equal. for k := range set { if _, ok := sset[k]; !ok { return false } } return true }
go
func (set StringSet) Equals(sset StringSet) bool { // If length of set is not equal to length of given set, the // set is not equal to given set. if len(set) != len(sset) { return false } // As both sets are equal in length, check each elements are equal. for k := range set { if _, ok := sset[k]; !ok { return false } } return true }
[ "func", "(", "set", "StringSet", ")", "Equals", "(", "sset", "StringSet", ")", "bool", "{", "// If length of set is not equal to length of given set, the", "// set is not equal to given set.", "if", "len", "(", "set", ")", "!=", "len", "(", "sset", ")", "{", "return", "false", "\n", "}", "\n\n", "// As both sets are equal in length, check each elements are equal.", "for", "k", ":=", "range", "set", "{", "if", "_", ",", "ok", ":=", "sset", "[", "k", "]", ";", "!", "ok", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "return", "true", "\n", "}" ]
// Equals - checks whether given set is equal to current set or not.
[ "Equals", "-", "checks", "whether", "given", "set", "is", "equal", "to", "current", "set", "or", "not", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L88-L103
148,662
minio/minio-go
pkg/set/stringset.go
Intersection
func (set StringSet) Intersection(sset StringSet) StringSet { nset := NewStringSet() for k := range set { if _, ok := sset[k]; ok { nset.Add(k) } } return nset }
go
func (set StringSet) Intersection(sset StringSet) StringSet { nset := NewStringSet() for k := range set { if _, ok := sset[k]; ok { nset.Add(k) } } return nset }
[ "func", "(", "set", "StringSet", ")", "Intersection", "(", "sset", "StringSet", ")", "StringSet", "{", "nset", ":=", "NewStringSet", "(", ")", "\n", "for", "k", ":=", "range", "set", "{", "if", "_", ",", "ok", ":=", "sset", "[", "k", "]", ";", "ok", "{", "nset", ".", "Add", "(", "k", ")", "\n", "}", "\n", "}", "\n\n", "return", "nset", "\n", "}" ]
// Intersection - returns the intersection with given set as new set.
[ "Intersection", "-", "returns", "the", "intersection", "with", "given", "set", "as", "new", "set", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L106-L115
148,663
minio/minio-go
pkg/set/stringset.go
Union
func (set StringSet) Union(sset StringSet) StringSet { nset := NewStringSet() for k := range set { nset.Add(k) } for k := range sset { nset.Add(k) } return nset }
go
func (set StringSet) Union(sset StringSet) StringSet { nset := NewStringSet() for k := range set { nset.Add(k) } for k := range sset { nset.Add(k) } return nset }
[ "func", "(", "set", "StringSet", ")", "Union", "(", "sset", "StringSet", ")", "StringSet", "{", "nset", ":=", "NewStringSet", "(", ")", "\n", "for", "k", ":=", "range", "set", "{", "nset", ".", "Add", "(", "k", ")", "\n", "}", "\n\n", "for", "k", ":=", "range", "sset", "{", "nset", ".", "Add", "(", "k", ")", "\n", "}", "\n\n", "return", "nset", "\n", "}" ]
// Union - returns the union with given set as new set.
[ "Union", "-", "returns", "the", "union", "with", "given", "set", "as", "new", "set", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L130-L141
148,664
minio/minio-go
pkg/set/stringset.go
UnmarshalJSON
func (set *StringSet) UnmarshalJSON(data []byte) error { sl := []string{} var err error if err = json.Unmarshal(data, &sl); err == nil { *set = make(StringSet) for _, s := range sl { set.Add(s) } } else { var s string if err = json.Unmarshal(data, &s); err == nil { *set = make(StringSet) set.Add(s) } } return err }
go
func (set *StringSet) UnmarshalJSON(data []byte) error { sl := []string{} var err error if err = json.Unmarshal(data, &sl); err == nil { *set = make(StringSet) for _, s := range sl { set.Add(s) } } else { var s string if err = json.Unmarshal(data, &s); err == nil { *set = make(StringSet) set.Add(s) } } return err }
[ "func", "(", "set", "*", "StringSet", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "sl", ":=", "[", "]", "string", "{", "}", "\n", "var", "err", "error", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "data", ",", "&", "sl", ")", ";", "err", "==", "nil", "{", "*", "set", "=", "make", "(", "StringSet", ")", "\n", "for", "_", ",", "s", ":=", "range", "sl", "{", "set", ".", "Add", "(", "s", ")", "\n", "}", "\n", "}", "else", "{", "var", "s", "string", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "data", ",", "&", "s", ")", ";", "err", "==", "nil", "{", "*", "set", "=", "make", "(", "StringSet", ")", "\n", "set", ".", "Add", "(", "s", ")", "\n", "}", "\n", "}", "\n\n", "return", "err", "\n", "}" ]
// UnmarshalJSON - parses JSON data and creates new set with it. // If 'data' contains JSON string array, the set contains each string. // If 'data' contains JSON string, the set contains the string as one element. // If 'data' contains Other JSON types, JSON parse error is returned.
[ "UnmarshalJSON", "-", "parses", "JSON", "data", "and", "creates", "new", "set", "with", "it", ".", "If", "data", "contains", "JSON", "string", "array", "the", "set", "contains", "each", "string", ".", "If", "data", "contains", "JSON", "string", "the", "set", "contains", "the", "string", "as", "one", "element", ".", "If", "data", "contains", "Other", "JSON", "types", "JSON", "parse", "error", "is", "returned", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L152-L169
148,665
minio/minio-go
pkg/set/stringset.go
CreateStringSet
func CreateStringSet(sl ...string) StringSet { set := make(StringSet) for _, k := range sl { set.Add(k) } return set }
go
func CreateStringSet(sl ...string) StringSet { set := make(StringSet) for _, k := range sl { set.Add(k) } return set }
[ "func", "CreateStringSet", "(", "sl", "...", "string", ")", "StringSet", "{", "set", ":=", "make", "(", "StringSet", ")", "\n", "for", "_", ",", "k", ":=", "range", "sl", "{", "set", ".", "Add", "(", "k", ")", "\n", "}", "\n", "return", "set", "\n", "}" ]
// CreateStringSet - creates new string set with given string values.
[ "CreateStringSet", "-", "creates", "new", "string", "set", "with", "given", "string", "values", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L182-L188
148,666
minio/minio-go
pkg/set/stringset.go
CopyStringSet
func CopyStringSet(set StringSet) StringSet { nset := NewStringSet() for k, v := range set { nset[k] = v } return nset }
go
func CopyStringSet(set StringSet) StringSet { nset := NewStringSet() for k, v := range set { nset[k] = v } return nset }
[ "func", "CopyStringSet", "(", "set", "StringSet", ")", "StringSet", "{", "nset", ":=", "NewStringSet", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "set", "{", "nset", "[", "k", "]", "=", "v", "\n", "}", "\n", "return", "nset", "\n", "}" ]
// CopyStringSet - returns copy of given set.
[ "CopyStringSet", "-", "returns", "copy", "of", "given", "set", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L191-L197
148,667
minio/minio-go
api-put-bucket.go
SetBucketPolicy
func (c Client) SetBucketPolicy(bucketName, policy string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // If policy is empty then delete the bucket policy. if policy == "" { return c.removeBucketPolicy(bucketName) } // Save the updated policies. return c.putBucketPolicy(bucketName, policy) }
go
func (c Client) SetBucketPolicy(bucketName, policy string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // If policy is empty then delete the bucket policy. if policy == "" { return c.removeBucketPolicy(bucketName) } // Save the updated policies. return c.putBucketPolicy(bucketName, policy) }
[ "func", "(", "c", "Client", ")", "SetBucketPolicy", "(", "bucketName", ",", "policy", "string", ")", "error", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// If policy is empty then delete the bucket policy.", "if", "policy", "==", "\"", "\"", "{", "return", "c", ".", "removeBucketPolicy", "(", "bucketName", ")", "\n", "}", "\n\n", "// Save the updated policies.", "return", "c", ".", "putBucketPolicy", "(", "bucketName", ",", "policy", ")", "\n", "}" ]
// SetBucketPolicy set the access permissions on an existing bucket.
[ "SetBucketPolicy", "set", "the", "access", "permissions", "on", "an", "existing", "bucket", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L102-L115
148,668
minio/minio-go
api-put-bucket.go
putBucketPolicy
func (c Client) putBucketPolicy(bucketName, policy string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("policy", "") // Content-length is mandatory for put policy request policyReader := strings.NewReader(policy) b, err := ioutil.ReadAll(policyReader) if err != nil { return err } reqMetadata := requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentBody: policyReader, contentLength: int64(len(b)), } // Execute PUT to upload a new bucket policy. resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata) defer closeResponse(resp) if err != nil { return err } if resp != nil { if resp.StatusCode != http.StatusNoContent { return httpRespToErrorResponse(resp, bucketName, "") } } return nil }
go
func (c Client) putBucketPolicy(bucketName, policy string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("policy", "") // Content-length is mandatory for put policy request policyReader := strings.NewReader(policy) b, err := ioutil.ReadAll(policyReader) if err != nil { return err } reqMetadata := requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentBody: policyReader, contentLength: int64(len(b)), } // Execute PUT to upload a new bucket policy. resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata) defer closeResponse(resp) if err != nil { return err } if resp != nil { if resp.StatusCode != http.StatusNoContent { return httpRespToErrorResponse(resp, bucketName, "") } } return nil }
[ "func", "(", "c", "Client", ")", "putBucketPolicy", "(", "bucketName", ",", "policy", "string", ")", "error", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Get resources properly escaped and lined up before", "// using them in http request.", "urlValues", ":=", "make", "(", "url", ".", "Values", ")", "\n", "urlValues", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "// Content-length is mandatory for put policy request", "policyReader", ":=", "strings", ".", "NewReader", "(", "policy", ")", "\n", "b", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "policyReader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "reqMetadata", ":=", "requestMetadata", "{", "bucketName", ":", "bucketName", ",", "queryValues", ":", "urlValues", ",", "contentBody", ":", "policyReader", ",", "contentLength", ":", "int64", "(", "len", "(", "b", ")", ")", ",", "}", "\n\n", "// Execute PUT to upload a new bucket policy.", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "context", ".", "Background", "(", ")", ",", "\"", "\"", ",", "reqMetadata", ")", "\n", "defer", "closeResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "resp", "!=", "nil", "{", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusNoContent", "{", "return", "httpRespToErrorResponse", "(", "resp", ",", "bucketName", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Saves a new bucket policy.
[ "Saves", "a", "new", "bucket", "policy", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L118-L155
148,669
minio/minio-go
api-put-bucket.go
removeBucketPolicy
func (c Client) removeBucketPolicy(bucketName string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("policy", "") // Execute DELETE on objectName. resp, err := c.executeMethod(context.Background(), "DELETE", requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentSHA256Hex: emptySHA256Hex, }) defer closeResponse(resp) if err != nil { return err } return nil }
go
func (c Client) removeBucketPolicy(bucketName string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("policy", "") // Execute DELETE on objectName. resp, err := c.executeMethod(context.Background(), "DELETE", requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentSHA256Hex: emptySHA256Hex, }) defer closeResponse(resp) if err != nil { return err } return nil }
[ "func", "(", "c", "Client", ")", "removeBucketPolicy", "(", "bucketName", "string", ")", "error", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// Get resources properly escaped and lined up before", "// using them in http request.", "urlValues", ":=", "make", "(", "url", ".", "Values", ")", "\n", "urlValues", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "// Execute DELETE on objectName.", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "context", ".", "Background", "(", ")", ",", "\"", "\"", ",", "requestMetadata", "{", "bucketName", ":", "bucketName", ",", "queryValues", ":", "urlValues", ",", "contentSHA256Hex", ":", "emptySHA256Hex", ",", "}", ")", "\n", "defer", "closeResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Removes all policies on a bucket.
[ "Removes", "all", "policies", "on", "a", "bucket", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L158-L179
148,670
minio/minio-go
api-put-bucket.go
SetBucketLifecycle
func (c Client) SetBucketLifecycle(bucketName, lifecycle string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // If lifecycle is empty then delete it. if lifecycle == "" { return c.removeBucketLifecycle(bucketName) } // Save the updated lifecycle. return c.putBucketLifecycle(bucketName, lifecycle) }
go
func (c Client) SetBucketLifecycle(bucketName, lifecycle string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // If lifecycle is empty then delete it. if lifecycle == "" { return c.removeBucketLifecycle(bucketName) } // Save the updated lifecycle. return c.putBucketLifecycle(bucketName, lifecycle) }
[ "func", "(", "c", "Client", ")", "SetBucketLifecycle", "(", "bucketName", ",", "lifecycle", "string", ")", "error", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// If lifecycle is empty then delete it.", "if", "lifecycle", "==", "\"", "\"", "{", "return", "c", ".", "removeBucketLifecycle", "(", "bucketName", ")", "\n", "}", "\n\n", "// Save the updated lifecycle.", "return", "c", ".", "putBucketLifecycle", "(", "bucketName", ",", "lifecycle", ")", "\n", "}" ]
// SetBucketLifecycle set the lifecycle on an existing bucket.
[ "SetBucketLifecycle", "set", "the", "lifecycle", "on", "an", "existing", "bucket", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L182-L195
148,671
minio/minio-go
api-put-bucket.go
putBucketLifecycle
func (c Client) putBucketLifecycle(bucketName, lifecycle string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("lifecycle", "") // Content-length is mandatory for put lifecycle request lifecycleReader := strings.NewReader(lifecycle) b, err := ioutil.ReadAll(lifecycleReader) if err != nil { return err } reqMetadata := requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentBody: lifecycleReader, contentLength: int64(len(b)), contentMD5Base64: sumMD5Base64(b), } // Execute PUT to upload a new bucket lifecycle. resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata) defer closeResponse(resp) if err != nil { return err } if resp != nil { if resp.StatusCode != http.StatusOK { return httpRespToErrorResponse(resp, bucketName, "") } } return nil }
go
func (c Client) putBucketLifecycle(bucketName, lifecycle string) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("lifecycle", "") // Content-length is mandatory for put lifecycle request lifecycleReader := strings.NewReader(lifecycle) b, err := ioutil.ReadAll(lifecycleReader) if err != nil { return err } reqMetadata := requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentBody: lifecycleReader, contentLength: int64(len(b)), contentMD5Base64: sumMD5Base64(b), } // Execute PUT to upload a new bucket lifecycle. resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata) defer closeResponse(resp) if err != nil { return err } if resp != nil { if resp.StatusCode != http.StatusOK { return httpRespToErrorResponse(resp, bucketName, "") } } return nil }
[ "func", "(", "c", "Client", ")", "putBucketLifecycle", "(", "bucketName", ",", "lifecycle", "string", ")", "error", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Get resources properly escaped and lined up before", "// using them in http request.", "urlValues", ":=", "make", "(", "url", ".", "Values", ")", "\n", "urlValues", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "// Content-length is mandatory for put lifecycle request", "lifecycleReader", ":=", "strings", ".", "NewReader", "(", "lifecycle", ")", "\n", "b", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "lifecycleReader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "reqMetadata", ":=", "requestMetadata", "{", "bucketName", ":", "bucketName", ",", "queryValues", ":", "urlValues", ",", "contentBody", ":", "lifecycleReader", ",", "contentLength", ":", "int64", "(", "len", "(", "b", ")", ")", ",", "contentMD5Base64", ":", "sumMD5Base64", "(", "b", ")", ",", "}", "\n\n", "// Execute PUT to upload a new bucket lifecycle.", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "context", ".", "Background", "(", ")", ",", "\"", "\"", ",", "reqMetadata", ")", "\n", "defer", "closeResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "resp", "!=", "nil", "{", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "return", "httpRespToErrorResponse", "(", "resp", ",", "bucketName", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Saves a new bucket lifecycle.
[ "Saves", "a", "new", "bucket", "lifecycle", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L198-L236
148,672
minio/minio-go
api-put-bucket.go
SetBucketNotification
func (c Client) SetBucketNotification(bucketName string, bucketNotification BucketNotification) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("notification", "") notifBytes, err := xml.Marshal(bucketNotification) if err != nil { return err } notifBuffer := bytes.NewReader(notifBytes) reqMetadata := requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentBody: notifBuffer, contentLength: int64(len(notifBytes)), contentMD5Base64: sumMD5Base64(notifBytes), contentSHA256Hex: sum256Hex(notifBytes), } // Execute PUT to upload a new bucket notification. resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata) defer closeResponse(resp) if err != nil { return err } if resp != nil { if resp.StatusCode != http.StatusOK { return httpRespToErrorResponse(resp, bucketName, "") } } return nil }
go
func (c Client) SetBucketNotification(bucketName string, bucketNotification BucketNotification) error { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return err } // Get resources properly escaped and lined up before // using them in http request. urlValues := make(url.Values) urlValues.Set("notification", "") notifBytes, err := xml.Marshal(bucketNotification) if err != nil { return err } notifBuffer := bytes.NewReader(notifBytes) reqMetadata := requestMetadata{ bucketName: bucketName, queryValues: urlValues, contentBody: notifBuffer, contentLength: int64(len(notifBytes)), contentMD5Base64: sumMD5Base64(notifBytes), contentSHA256Hex: sum256Hex(notifBytes), } // Execute PUT to upload a new bucket notification. resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata) defer closeResponse(resp) if err != nil { return err } if resp != nil { if resp.StatusCode != http.StatusOK { return httpRespToErrorResponse(resp, bucketName, "") } } return nil }
[ "func", "(", "c", "Client", ")", "SetBucketNotification", "(", "bucketName", "string", ",", "bucketNotification", "BucketNotification", ")", "error", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Get resources properly escaped and lined up before", "// using them in http request.", "urlValues", ":=", "make", "(", "url", ".", "Values", ")", "\n", "urlValues", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "notifBytes", ",", "err", ":=", "xml", ".", "Marshal", "(", "bucketNotification", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "notifBuffer", ":=", "bytes", ".", "NewReader", "(", "notifBytes", ")", "\n", "reqMetadata", ":=", "requestMetadata", "{", "bucketName", ":", "bucketName", ",", "queryValues", ":", "urlValues", ",", "contentBody", ":", "notifBuffer", ",", "contentLength", ":", "int64", "(", "len", "(", "notifBytes", ")", ")", ",", "contentMD5Base64", ":", "sumMD5Base64", "(", "notifBytes", ")", ",", "contentSHA256Hex", ":", "sum256Hex", "(", "notifBytes", ")", ",", "}", "\n\n", "// Execute PUT to upload a new bucket notification.", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "context", ".", "Background", "(", ")", ",", "\"", "\"", ",", "reqMetadata", ")", "\n", "defer", "closeResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "resp", "!=", "nil", "{", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "return", "httpRespToErrorResponse", "(", "resp", ",", "bucketName", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// SetBucketNotification saves a new bucket notification.
[ "SetBucketNotification", "saves", "a", "new", "bucket", "notification", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L263-L301
148,673
minio/minio-go
api-put-bucket.go
RemoveAllBucketNotification
func (c Client) RemoveAllBucketNotification(bucketName string) error { return c.SetBucketNotification(bucketName, BucketNotification{}) }
go
func (c Client) RemoveAllBucketNotification(bucketName string) error { return c.SetBucketNotification(bucketName, BucketNotification{}) }
[ "func", "(", "c", "Client", ")", "RemoveAllBucketNotification", "(", "bucketName", "string", ")", "error", "{", "return", "c", ".", "SetBucketNotification", "(", "bucketName", ",", "BucketNotification", "{", "}", ")", "\n", "}" ]
// RemoveAllBucketNotification - Remove bucket notification clears all previously specified config
[ "RemoveAllBucketNotification", "-", "Remove", "bucket", "notification", "clears", "all", "previously", "specified", "config" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L304-L306
148,674
minio/minio-go
pkg/credentials/static.go
NewStaticV2
func NewStaticV2(id, secret, token string) *Credentials { return NewStatic(id, secret, token, SignatureV2) }
go
func NewStaticV2(id, secret, token string) *Credentials { return NewStatic(id, secret, token, SignatureV2) }
[ "func", "NewStaticV2", "(", "id", ",", "secret", ",", "token", "string", ")", "*", "Credentials", "{", "return", "NewStatic", "(", "id", ",", "secret", ",", "token", ",", "SignatureV2", ")", "\n", "}" ]
// NewStaticV2 returns a pointer to a new Credentials object // wrapping a static credentials value provider, signature is // set to v2. If access and secret are not specified then // regardless of signature type set it Value will return // as anonymous.
[ "NewStaticV2", "returns", "a", "pointer", "to", "a", "new", "Credentials", "object", "wrapping", "a", "static", "credentials", "value", "provider", "signature", "is", "set", "to", "v2", ".", "If", "access", "and", "secret", "are", "not", "specified", "then", "regardless", "of", "signature", "type", "set", "it", "Value", "will", "return", "as", "anonymous", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/static.go#L31-L33
148,675
minio/minio-go
pkg/credentials/static.go
NewStaticV4
func NewStaticV4(id, secret, token string) *Credentials { return NewStatic(id, secret, token, SignatureV4) }
go
func NewStaticV4(id, secret, token string) *Credentials { return NewStatic(id, secret, token, SignatureV4) }
[ "func", "NewStaticV4", "(", "id", ",", "secret", ",", "token", "string", ")", "*", "Credentials", "{", "return", "NewStatic", "(", "id", ",", "secret", ",", "token", ",", "SignatureV4", ")", "\n", "}" ]
// NewStaticV4 is similar to NewStaticV2 with similar considerations.
[ "NewStaticV4", "is", "similar", "to", "NewStaticV2", "with", "similar", "considerations", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/static.go#L36-L38
148,676
minio/minio-go
pkg/credentials/static.go
NewStatic
func NewStatic(id, secret, token string, signerType SignatureType) *Credentials { return New(&Static{ Value: Value{ AccessKeyID: id, SecretAccessKey: secret, SessionToken: token, SignerType: signerType, }, }) }
go
func NewStatic(id, secret, token string, signerType SignatureType) *Credentials { return New(&Static{ Value: Value{ AccessKeyID: id, SecretAccessKey: secret, SessionToken: token, SignerType: signerType, }, }) }
[ "func", "NewStatic", "(", "id", ",", "secret", ",", "token", "string", ",", "signerType", "SignatureType", ")", "*", "Credentials", "{", "return", "New", "(", "&", "Static", "{", "Value", ":", "Value", "{", "AccessKeyID", ":", "id", ",", "SecretAccessKey", ":", "secret", ",", "SessionToken", ":", "token", ",", "SignerType", ":", "signerType", ",", "}", ",", "}", ")", "\n", "}" ]
// NewStatic returns a pointer to a new Credentials object // wrapping a static credentials value provider.
[ "NewStatic", "returns", "a", "pointer", "to", "a", "new", "Credentials", "object", "wrapping", "a", "static", "credentials", "value", "provider", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/static.go#L42-L51
148,677
minio/minio-go
pkg/credentials/static.go
Retrieve
func (s *Static) Retrieve() (Value, error) { if s.AccessKeyID == "" || s.SecretAccessKey == "" { // Anonymous is not an error return Value{SignerType: SignatureAnonymous}, nil } return s.Value, nil }
go
func (s *Static) Retrieve() (Value, error) { if s.AccessKeyID == "" || s.SecretAccessKey == "" { // Anonymous is not an error return Value{SignerType: SignatureAnonymous}, nil } return s.Value, nil }
[ "func", "(", "s", "*", "Static", ")", "Retrieve", "(", ")", "(", "Value", ",", "error", ")", "{", "if", "s", ".", "AccessKeyID", "==", "\"", "\"", "||", "s", ".", "SecretAccessKey", "==", "\"", "\"", "{", "// Anonymous is not an error", "return", "Value", "{", "SignerType", ":", "SignatureAnonymous", "}", ",", "nil", "\n", "}", "\n", "return", "s", ".", "Value", ",", "nil", "\n", "}" ]
// Retrieve returns the static credentials.
[ "Retrieve", "returns", "the", "static", "credentials", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/static.go#L54-L60
148,678
minio/minio-go
api-put-object-file-context.go
FPutObjectWithContext
func (c Client) FPutObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts PutObjectOptions) (n int64, err error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return 0, err } if err := s3utils.CheckValidObjectName(objectName); err != nil { return 0, err } // Open the referenced file. fileReader, err := os.Open(filePath) // If any error fail quickly here. if err != nil { return 0, err } defer fileReader.Close() // Save the file stat. fileStat, err := fileReader.Stat() if err != nil { return 0, err } // Save the file size. fileSize := fileStat.Size() // Set contentType based on filepath extension if not given or default // value of "application/octet-stream" if the extension has no associated type. if opts.ContentType == "" { if opts.ContentType = mime.TypeByExtension(filepath.Ext(filePath)); opts.ContentType == "" { opts.ContentType = "application/octet-stream" } } return c.PutObjectWithContext(ctx, bucketName, objectName, fileReader, fileSize, opts) }
go
func (c Client) FPutObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts PutObjectOptions) (n int64, err error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return 0, err } if err := s3utils.CheckValidObjectName(objectName); err != nil { return 0, err } // Open the referenced file. fileReader, err := os.Open(filePath) // If any error fail quickly here. if err != nil { return 0, err } defer fileReader.Close() // Save the file stat. fileStat, err := fileReader.Stat() if err != nil { return 0, err } // Save the file size. fileSize := fileStat.Size() // Set contentType based on filepath extension if not given or default // value of "application/octet-stream" if the extension has no associated type. if opts.ContentType == "" { if opts.ContentType = mime.TypeByExtension(filepath.Ext(filePath)); opts.ContentType == "" { opts.ContentType = "application/octet-stream" } } return c.PutObjectWithContext(ctx, bucketName, objectName, fileReader, fileSize, opts) }
[ "func", "(", "c", "Client", ")", "FPutObjectWithContext", "(", "ctx", "context", ".", "Context", ",", "bucketName", ",", "objectName", ",", "filePath", "string", ",", "opts", "PutObjectOptions", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "err", ":=", "s3utils", ".", "CheckValidObjectName", "(", "objectName", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "// Open the referenced file.", "fileReader", ",", "err", ":=", "os", ".", "Open", "(", "filePath", ")", "\n", "// If any error fail quickly here.", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "defer", "fileReader", ".", "Close", "(", ")", "\n\n", "// Save the file stat.", "fileStat", ",", "err", ":=", "fileReader", ".", "Stat", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "// Save the file size.", "fileSize", ":=", "fileStat", ".", "Size", "(", ")", "\n\n", "// Set contentType based on filepath extension if not given or default", "// value of \"application/octet-stream\" if the extension has no associated type.", "if", "opts", ".", "ContentType", "==", "\"", "\"", "{", "if", "opts", ".", "ContentType", "=", "mime", ".", "TypeByExtension", "(", "filepath", ".", "Ext", "(", "filePath", ")", ")", ";", "opts", ".", "ContentType", "==", "\"", "\"", "{", "opts", ".", "ContentType", "=", "\"", "\"", "\n", "}", "\n", "}", "\n", "return", "c", ".", "PutObjectWithContext", "(", "ctx", ",", "bucketName", ",", "objectName", ",", "fileReader", ",", "fileSize", ",", "opts", ")", "\n", "}" ]
// FPutObjectWithContext - Create an object in a bucket, with contents from file at filePath. Allows request cancellation.
[ "FPutObjectWithContext", "-", "Create", "an", "object", "in", "a", "bucket", "with", "contents", "from", "file", "at", "filePath", ".", "Allows", "request", "cancellation", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-file-context.go#L30-L64
148,679
minio/minio-go
api.go
NewV2
func NewV2(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Client, error) { creds := credentials.NewStaticV2(accessKeyID, secretAccessKey, "") clnt, err := privateNew(endpoint, creds, secure, "", BucketLookupAuto) if err != nil { return nil, err } clnt.overrideSignerType = credentials.SignatureV2 return clnt, nil }
go
func NewV2(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Client, error) { creds := credentials.NewStaticV2(accessKeyID, secretAccessKey, "") clnt, err := privateNew(endpoint, creds, secure, "", BucketLookupAuto) if err != nil { return nil, err } clnt.overrideSignerType = credentials.SignatureV2 return clnt, nil }
[ "func", "NewV2", "(", "endpoint", "string", ",", "accessKeyID", ",", "secretAccessKey", "string", ",", "secure", "bool", ")", "(", "*", "Client", ",", "error", ")", "{", "creds", ":=", "credentials", ".", "NewStaticV2", "(", "accessKeyID", ",", "secretAccessKey", ",", "\"", "\"", ")", "\n", "clnt", ",", "err", ":=", "privateNew", "(", "endpoint", ",", "creds", ",", "secure", ",", "\"", "\"", ",", "BucketLookupAuto", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "clnt", ".", "overrideSignerType", "=", "credentials", ".", "SignatureV2", "\n", "return", "clnt", ",", "nil", "\n", "}" ]
// NewV2 - instantiate minio client with Amazon S3 signature version // '2' compatibility.
[ "NewV2", "-", "instantiate", "minio", "client", "with", "Amazon", "S3", "signature", "version", "2", "compatibility", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L129-L137
148,680
minio/minio-go
api.go
NewV4
func NewV4(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Client, error) { creds := credentials.NewStaticV4(accessKeyID, secretAccessKey, "") clnt, err := privateNew(endpoint, creds, secure, "", BucketLookupAuto) if err != nil { return nil, err } clnt.overrideSignerType = credentials.SignatureV4 return clnt, nil }
go
func NewV4(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Client, error) { creds := credentials.NewStaticV4(accessKeyID, secretAccessKey, "") clnt, err := privateNew(endpoint, creds, secure, "", BucketLookupAuto) if err != nil { return nil, err } clnt.overrideSignerType = credentials.SignatureV4 return clnt, nil }
[ "func", "NewV4", "(", "endpoint", "string", ",", "accessKeyID", ",", "secretAccessKey", "string", ",", "secure", "bool", ")", "(", "*", "Client", ",", "error", ")", "{", "creds", ":=", "credentials", ".", "NewStaticV4", "(", "accessKeyID", ",", "secretAccessKey", ",", "\"", "\"", ")", "\n", "clnt", ",", "err", ":=", "privateNew", "(", "endpoint", ",", "creds", ",", "secure", ",", "\"", "\"", ",", "BucketLookupAuto", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "clnt", ".", "overrideSignerType", "=", "credentials", ".", "SignatureV4", "\n", "return", "clnt", ",", "nil", "\n", "}" ]
// NewV4 - instantiate minio client with Amazon S3 signature version // '4' compatibility.
[ "NewV4", "-", "instantiate", "minio", "client", "with", "Amazon", "S3", "signature", "version", "4", "compatibility", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L141-L149
148,681
minio/minio-go
api.go
New
func New(endpoint, accessKeyID, secretAccessKey string, secure bool) (*Client, error) { creds := credentials.NewStaticV4(accessKeyID, secretAccessKey, "") clnt, err := privateNew(endpoint, creds, secure, "", BucketLookupAuto) if err != nil { return nil, err } // Google cloud storage should be set to signature V2, force it if not. if s3utils.IsGoogleEndpoint(*clnt.endpointURL) { clnt.overrideSignerType = credentials.SignatureV2 } // If Amazon S3 set to signature v4. if s3utils.IsAmazonEndpoint(*clnt.endpointURL) { clnt.overrideSignerType = credentials.SignatureV4 } return clnt, nil }
go
func New(endpoint, accessKeyID, secretAccessKey string, secure bool) (*Client, error) { creds := credentials.NewStaticV4(accessKeyID, secretAccessKey, "") clnt, err := privateNew(endpoint, creds, secure, "", BucketLookupAuto) if err != nil { return nil, err } // Google cloud storage should be set to signature V2, force it if not. if s3utils.IsGoogleEndpoint(*clnt.endpointURL) { clnt.overrideSignerType = credentials.SignatureV2 } // If Amazon S3 set to signature v4. if s3utils.IsAmazonEndpoint(*clnt.endpointURL) { clnt.overrideSignerType = credentials.SignatureV4 } return clnt, nil }
[ "func", "New", "(", "endpoint", ",", "accessKeyID", ",", "secretAccessKey", "string", ",", "secure", "bool", ")", "(", "*", "Client", ",", "error", ")", "{", "creds", ":=", "credentials", ".", "NewStaticV4", "(", "accessKeyID", ",", "secretAccessKey", ",", "\"", "\"", ")", "\n", "clnt", ",", "err", ":=", "privateNew", "(", "endpoint", ",", "creds", ",", "secure", ",", "\"", "\"", ",", "BucketLookupAuto", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Google cloud storage should be set to signature V2, force it if not.", "if", "s3utils", ".", "IsGoogleEndpoint", "(", "*", "clnt", ".", "endpointURL", ")", "{", "clnt", ".", "overrideSignerType", "=", "credentials", ".", "SignatureV2", "\n", "}", "\n", "// If Amazon S3 set to signature v4.", "if", "s3utils", ".", "IsAmazonEndpoint", "(", "*", "clnt", ".", "endpointURL", ")", "{", "clnt", ".", "overrideSignerType", "=", "credentials", ".", "SignatureV4", "\n", "}", "\n", "return", "clnt", ",", "nil", "\n", "}" ]
// New - instantiate minio client, adds automatic verification of signature.
[ "New", "-", "instantiate", "minio", "client", "adds", "automatic", "verification", "of", "signature", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L152-L167
148,682
minio/minio-go
api.go
NewWithCredentials
func NewWithCredentials(endpoint string, creds *credentials.Credentials, secure bool, region string) (*Client, error) { return privateNew(endpoint, creds, secure, region, BucketLookupAuto) }
go
func NewWithCredentials(endpoint string, creds *credentials.Credentials, secure bool, region string) (*Client, error) { return privateNew(endpoint, creds, secure, region, BucketLookupAuto) }
[ "func", "NewWithCredentials", "(", "endpoint", "string", ",", "creds", "*", "credentials", ".", "Credentials", ",", "secure", "bool", ",", "region", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "privateNew", "(", "endpoint", ",", "creds", ",", "secure", ",", "region", ",", "BucketLookupAuto", ")", "\n", "}" ]
// NewWithCredentials - instantiate minio client with credentials provider // for retrieving credentials from various credentials provider such as // IAM, File, Env etc.
[ "NewWithCredentials", "-", "instantiate", "minio", "client", "with", "credentials", "provider", "for", "retrieving", "credentials", "from", "various", "credentials", "provider", "such", "as", "IAM", "File", "Env", "etc", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L172-L174
148,683
minio/minio-go
api.go
NewWithOptions
func NewWithOptions(endpoint string, opts *Options) (*Client, error) { return privateNew(endpoint, opts.Creds, opts.Secure, opts.Region, opts.BucketLookup) }
go
func NewWithOptions(endpoint string, opts *Options) (*Client, error) { return privateNew(endpoint, opts.Creds, opts.Secure, opts.Region, opts.BucketLookup) }
[ "func", "NewWithOptions", "(", "endpoint", "string", ",", "opts", "*", "Options", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "privateNew", "(", "endpoint", ",", "opts", ".", "Creds", ",", "opts", ".", "Secure", ",", "opts", ".", "Region", ",", "opts", ".", "BucketLookup", ")", "\n", "}" ]
// NewWithOptions - instantiate minio client with options
[ "NewWithOptions", "-", "instantiate", "minio", "client", "with", "options" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L185-L187
148,684
minio/minio-go
api.go
redirectHeaders
func (c *Client) redirectHeaders(req *http.Request, via []*http.Request) error { if len(via) >= 5 { return errors.New("stopped after 5 redirects") } if len(via) == 0 { return nil } lastRequest := via[len(via)-1] var reAuth bool for attr, val := range lastRequest.Header { // if hosts do not match do not copy Authorization header if attr == "Authorization" && req.Host != lastRequest.Host { reAuth = true continue } if _, ok := req.Header[attr]; !ok { req.Header[attr] = val } } *c.endpointURL = *req.URL value, err := c.credsProvider.Get() if err != nil { return err } var ( signerType = value.SignerType accessKeyID = value.AccessKeyID secretAccessKey = value.SecretAccessKey sessionToken = value.SessionToken region = c.region ) // Custom signer set then override the behavior. if c.overrideSignerType != credentials.SignatureDefault { signerType = c.overrideSignerType } // If signerType returned by credentials helper is anonymous, // then do not sign regardless of signerType override. if value.SignerType == credentials.SignatureAnonymous { signerType = credentials.SignatureAnonymous } if reAuth { // Check if there is no region override, if not get it from the URL if possible. if region == "" { region = s3utils.GetRegionFromURL(*c.endpointURL) } switch { case signerType.IsV2(): return errors.New("signature V2 cannot support redirection") case signerType.IsV4(): req = s3signer.SignV4(*req, accessKeyID, secretAccessKey, sessionToken, getDefaultLocation(*c.endpointURL, region)) } } return nil }
go
func (c *Client) redirectHeaders(req *http.Request, via []*http.Request) error { if len(via) >= 5 { return errors.New("stopped after 5 redirects") } if len(via) == 0 { return nil } lastRequest := via[len(via)-1] var reAuth bool for attr, val := range lastRequest.Header { // if hosts do not match do not copy Authorization header if attr == "Authorization" && req.Host != lastRequest.Host { reAuth = true continue } if _, ok := req.Header[attr]; !ok { req.Header[attr] = val } } *c.endpointURL = *req.URL value, err := c.credsProvider.Get() if err != nil { return err } var ( signerType = value.SignerType accessKeyID = value.AccessKeyID secretAccessKey = value.SecretAccessKey sessionToken = value.SessionToken region = c.region ) // Custom signer set then override the behavior. if c.overrideSignerType != credentials.SignatureDefault { signerType = c.overrideSignerType } // If signerType returned by credentials helper is anonymous, // then do not sign regardless of signerType override. if value.SignerType == credentials.SignatureAnonymous { signerType = credentials.SignatureAnonymous } if reAuth { // Check if there is no region override, if not get it from the URL if possible. if region == "" { region = s3utils.GetRegionFromURL(*c.endpointURL) } switch { case signerType.IsV2(): return errors.New("signature V2 cannot support redirection") case signerType.IsV4(): req = s3signer.SignV4(*req, accessKeyID, secretAccessKey, sessionToken, getDefaultLocation(*c.endpointURL, region)) } } return nil }
[ "func", "(", "c", "*", "Client", ")", "redirectHeaders", "(", "req", "*", "http", ".", "Request", ",", "via", "[", "]", "*", "http", ".", "Request", ")", "error", "{", "if", "len", "(", "via", ")", ">=", "5", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "via", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "lastRequest", ":=", "via", "[", "len", "(", "via", ")", "-", "1", "]", "\n", "var", "reAuth", "bool", "\n", "for", "attr", ",", "val", ":=", "range", "lastRequest", ".", "Header", "{", "// if hosts do not match do not copy Authorization header", "if", "attr", "==", "\"", "\"", "&&", "req", ".", "Host", "!=", "lastRequest", ".", "Host", "{", "reAuth", "=", "true", "\n", "continue", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "req", ".", "Header", "[", "attr", "]", ";", "!", "ok", "{", "req", ".", "Header", "[", "attr", "]", "=", "val", "\n", "}", "\n", "}", "\n\n", "*", "c", ".", "endpointURL", "=", "*", "req", ".", "URL", "\n\n", "value", ",", "err", ":=", "c", ".", "credsProvider", ".", "Get", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "(", "signerType", "=", "value", ".", "SignerType", "\n", "accessKeyID", "=", "value", ".", "AccessKeyID", "\n", "secretAccessKey", "=", "value", ".", "SecretAccessKey", "\n", "sessionToken", "=", "value", ".", "SessionToken", "\n", "region", "=", "c", ".", "region", "\n", ")", "\n\n", "// Custom signer set then override the behavior.", "if", "c", ".", "overrideSignerType", "!=", "credentials", ".", "SignatureDefault", "{", "signerType", "=", "c", ".", "overrideSignerType", "\n", "}", "\n\n", "// If signerType returned by credentials helper is anonymous,", "// then do not sign regardless of signerType override.", "if", "value", ".", "SignerType", "==", "credentials", ".", "SignatureAnonymous", "{", "signerType", "=", "credentials", ".", "SignatureAnonymous", "\n", "}", "\n\n", "if", "reAuth", "{", "// Check if there is no region override, if not get it from the URL if possible.", "if", "region", "==", "\"", "\"", "{", "region", "=", "s3utils", ".", "GetRegionFromURL", "(", "*", "c", ".", "endpointURL", ")", "\n", "}", "\n", "switch", "{", "case", "signerType", ".", "IsV2", "(", ")", ":", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "case", "signerType", ".", "IsV4", "(", ")", ":", "req", "=", "s3signer", ".", "SignV4", "(", "*", "req", ",", "accessKeyID", ",", "secretAccessKey", ",", "sessionToken", ",", "getDefaultLocation", "(", "*", "c", ".", "endpointURL", ",", "region", ")", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Redirect requests by re signing the request.
[ "Redirect", "requests", "by", "re", "signing", "the", "request", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L212-L270
148,685
minio/minio-go
api.go
hashMaterials
func (c *Client) hashMaterials() (hashAlgos map[string]hash.Hash, hashSums map[string][]byte) { hashSums = make(map[string][]byte) hashAlgos = make(map[string]hash.Hash) if c.overrideSignerType.IsV4() { if c.secure { hashAlgos["md5"] = md5.New() } else { hashAlgos["sha256"] = sha256.New() } } else { if c.overrideSignerType.IsAnonymous() { hashAlgos["md5"] = md5.New() } } return hashAlgos, hashSums }
go
func (c *Client) hashMaterials() (hashAlgos map[string]hash.Hash, hashSums map[string][]byte) { hashSums = make(map[string][]byte) hashAlgos = make(map[string]hash.Hash) if c.overrideSignerType.IsV4() { if c.secure { hashAlgos["md5"] = md5.New() } else { hashAlgos["sha256"] = sha256.New() } } else { if c.overrideSignerType.IsAnonymous() { hashAlgos["md5"] = md5.New() } } return hashAlgos, hashSums }
[ "func", "(", "c", "*", "Client", ")", "hashMaterials", "(", ")", "(", "hashAlgos", "map", "[", "string", "]", "hash", ".", "Hash", ",", "hashSums", "map", "[", "string", "]", "[", "]", "byte", ")", "{", "hashSums", "=", "make", "(", "map", "[", "string", "]", "[", "]", "byte", ")", "\n", "hashAlgos", "=", "make", "(", "map", "[", "string", "]", "hash", ".", "Hash", ")", "\n", "if", "c", ".", "overrideSignerType", ".", "IsV4", "(", ")", "{", "if", "c", ".", "secure", "{", "hashAlgos", "[", "\"", "\"", "]", "=", "md5", ".", "New", "(", ")", "\n", "}", "else", "{", "hashAlgos", "[", "\"", "\"", "]", "=", "sha256", ".", "New", "(", ")", "\n", "}", "\n", "}", "else", "{", "if", "c", ".", "overrideSignerType", ".", "IsAnonymous", "(", ")", "{", "hashAlgos", "[", "\"", "\"", "]", "=", "md5", ".", "New", "(", ")", "\n", "}", "\n", "}", "\n", "return", "hashAlgos", ",", "hashSums", "\n", "}" ]
// Hash materials provides relevant initialized hash algo writers // based on the expected signature type. // // - For signature v4 request if the connection is insecure compute only sha256. // - For signature v4 request if the connection is secure compute only md5. // - For anonymous request compute md5.
[ "Hash", "materials", "provides", "relevant", "initialized", "hash", "algo", "writers", "based", "on", "the", "expected", "signature", "type", ".", "-", "For", "signature", "v4", "request", "if", "the", "connection", "is", "insecure", "compute", "only", "sha256", ".", "-", "For", "signature", "v4", "request", "if", "the", "connection", "is", "secure", "compute", "only", "md5", ".", "-", "For", "anonymous", "request", "compute", "md5", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L399-L414
148,686
minio/minio-go
api.go
isVirtualHostStyleRequest
func (c *Client) isVirtualHostStyleRequest(url url.URL, bucketName string) bool { if bucketName == "" { return false } if c.lookup == BucketLookupDNS { return true } if c.lookup == BucketLookupPath { return false } // default to virtual only for Amazon/Google storage. In all other cases use // path style requests return s3utils.IsVirtualHostSupported(url, bucketName) }
go
func (c *Client) isVirtualHostStyleRequest(url url.URL, bucketName string) bool { if bucketName == "" { return false } if c.lookup == BucketLookupDNS { return true } if c.lookup == BucketLookupPath { return false } // default to virtual only for Amazon/Google storage. In all other cases use // path style requests return s3utils.IsVirtualHostSupported(url, bucketName) }
[ "func", "(", "c", "*", "Client", ")", "isVirtualHostStyleRequest", "(", "url", "url", ".", "URL", ",", "bucketName", "string", ")", "bool", "{", "if", "bucketName", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "if", "c", ".", "lookup", "==", "BucketLookupDNS", "{", "return", "true", "\n", "}", "\n", "if", "c", ".", "lookup", "==", "BucketLookupPath", "{", "return", "false", "\n", "}", "\n\n", "// default to virtual only for Amazon/Google storage. In all other cases use", "// path style requests", "return", "s3utils", ".", "IsVirtualHostSupported", "(", "url", ",", "bucketName", ")", "\n", "}" ]
// returns true if virtual hosted style requests are to be used.
[ "returns", "true", "if", "virtual", "hosted", "style", "requests", "are", "to", "be", "used", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api.go#L888-L903
148,687
minio/minio-go
api-list.go
listIncompleteUploads
func (c Client) listIncompleteUploads(bucketName, objectPrefix string, recursive, aggregateSize bool, doneCh <-chan struct{}) <-chan ObjectMultipartInfo { // Allocate channel for multipart uploads. objectMultipartStatCh := make(chan ObjectMultipartInfo, 1) // Delimiter is set to "/" by default. delimiter := "/" if recursive { // If recursive do not delimit. delimiter = "" } // Validate bucket name. if err := s3utils.CheckValidBucketName(bucketName); err != nil { defer close(objectMultipartStatCh) objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } return objectMultipartStatCh } // Validate incoming object prefix. if err := s3utils.CheckValidObjectNamePrefix(objectPrefix); err != nil { defer close(objectMultipartStatCh) objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } return objectMultipartStatCh } go func(objectMultipartStatCh chan<- ObjectMultipartInfo) { defer close(objectMultipartStatCh) // object and upload ID marker for future requests. var objectMarker string var uploadIDMarker string for { // list all multipart uploads. result, err := c.listMultipartUploadsQuery(bucketName, objectMarker, uploadIDMarker, objectPrefix, delimiter, 1000) if err != nil { objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } return } // Save objectMarker and uploadIDMarker for next request. objectMarker = result.NextKeyMarker uploadIDMarker = result.NextUploadIDMarker // Send all multipart uploads. for _, obj := range result.Uploads { // Calculate total size of the uploaded parts if 'aggregateSize' is enabled. if aggregateSize { // Get total multipart size. obj.Size, err = c.getTotalMultipartSize(bucketName, obj.Key, obj.UploadID) if err != nil { objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } continue } } select { // Send individual uploads here. case objectMultipartStatCh <- obj: // If done channel return here. case <-doneCh: return } } // Send all common prefixes if any. // NOTE: prefixes are only present if the request is delimited. for _, obj := range result.CommonPrefixes { object := ObjectMultipartInfo{} object.Key = obj.Prefix object.Size = 0 select { // Send delimited prefixes here. case objectMultipartStatCh <- object: // If done channel return here. case <-doneCh: return } } // Listing ends if result not truncated, return right here. if !result.IsTruncated { return } } }(objectMultipartStatCh) // return. return objectMultipartStatCh }
go
func (c Client) listIncompleteUploads(bucketName, objectPrefix string, recursive, aggregateSize bool, doneCh <-chan struct{}) <-chan ObjectMultipartInfo { // Allocate channel for multipart uploads. objectMultipartStatCh := make(chan ObjectMultipartInfo, 1) // Delimiter is set to "/" by default. delimiter := "/" if recursive { // If recursive do not delimit. delimiter = "" } // Validate bucket name. if err := s3utils.CheckValidBucketName(bucketName); err != nil { defer close(objectMultipartStatCh) objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } return objectMultipartStatCh } // Validate incoming object prefix. if err := s3utils.CheckValidObjectNamePrefix(objectPrefix); err != nil { defer close(objectMultipartStatCh) objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } return objectMultipartStatCh } go func(objectMultipartStatCh chan<- ObjectMultipartInfo) { defer close(objectMultipartStatCh) // object and upload ID marker for future requests. var objectMarker string var uploadIDMarker string for { // list all multipart uploads. result, err := c.listMultipartUploadsQuery(bucketName, objectMarker, uploadIDMarker, objectPrefix, delimiter, 1000) if err != nil { objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } return } // Save objectMarker and uploadIDMarker for next request. objectMarker = result.NextKeyMarker uploadIDMarker = result.NextUploadIDMarker // Send all multipart uploads. for _, obj := range result.Uploads { // Calculate total size of the uploaded parts if 'aggregateSize' is enabled. if aggregateSize { // Get total multipart size. obj.Size, err = c.getTotalMultipartSize(bucketName, obj.Key, obj.UploadID) if err != nil { objectMultipartStatCh <- ObjectMultipartInfo{ Err: err, } continue } } select { // Send individual uploads here. case objectMultipartStatCh <- obj: // If done channel return here. case <-doneCh: return } } // Send all common prefixes if any. // NOTE: prefixes are only present if the request is delimited. for _, obj := range result.CommonPrefixes { object := ObjectMultipartInfo{} object.Key = obj.Prefix object.Size = 0 select { // Send delimited prefixes here. case objectMultipartStatCh <- object: // If done channel return here. case <-doneCh: return } } // Listing ends if result not truncated, return right here. if !result.IsTruncated { return } } }(objectMultipartStatCh) // return. return objectMultipartStatCh }
[ "func", "(", "c", "Client", ")", "listIncompleteUploads", "(", "bucketName", ",", "objectPrefix", "string", ",", "recursive", ",", "aggregateSize", "bool", ",", "doneCh", "<-", "chan", "struct", "{", "}", ")", "<-", "chan", "ObjectMultipartInfo", "{", "// Allocate channel for multipart uploads.", "objectMultipartStatCh", ":=", "make", "(", "chan", "ObjectMultipartInfo", ",", "1", ")", "\n", "// Delimiter is set to \"/\" by default.", "delimiter", ":=", "\"", "\"", "\n", "if", "recursive", "{", "// If recursive do not delimit.", "delimiter", "=", "\"", "\"", "\n", "}", "\n", "// Validate bucket name.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "defer", "close", "(", "objectMultipartStatCh", ")", "\n", "objectMultipartStatCh", "<-", "ObjectMultipartInfo", "{", "Err", ":", "err", ",", "}", "\n", "return", "objectMultipartStatCh", "\n", "}", "\n", "// Validate incoming object prefix.", "if", "err", ":=", "s3utils", ".", "CheckValidObjectNamePrefix", "(", "objectPrefix", ")", ";", "err", "!=", "nil", "{", "defer", "close", "(", "objectMultipartStatCh", ")", "\n", "objectMultipartStatCh", "<-", "ObjectMultipartInfo", "{", "Err", ":", "err", ",", "}", "\n", "return", "objectMultipartStatCh", "\n", "}", "\n", "go", "func", "(", "objectMultipartStatCh", "chan", "<-", "ObjectMultipartInfo", ")", "{", "defer", "close", "(", "objectMultipartStatCh", ")", "\n", "// object and upload ID marker for future requests.", "var", "objectMarker", "string", "\n", "var", "uploadIDMarker", "string", "\n", "for", "{", "// list all multipart uploads.", "result", ",", "err", ":=", "c", ".", "listMultipartUploadsQuery", "(", "bucketName", ",", "objectMarker", ",", "uploadIDMarker", ",", "objectPrefix", ",", "delimiter", ",", "1000", ")", "\n", "if", "err", "!=", "nil", "{", "objectMultipartStatCh", "<-", "ObjectMultipartInfo", "{", "Err", ":", "err", ",", "}", "\n", "return", "\n", "}", "\n", "// Save objectMarker and uploadIDMarker for next request.", "objectMarker", "=", "result", ".", "NextKeyMarker", "\n", "uploadIDMarker", "=", "result", ".", "NextUploadIDMarker", "\n", "// Send all multipart uploads.", "for", "_", ",", "obj", ":=", "range", "result", ".", "Uploads", "{", "// Calculate total size of the uploaded parts if 'aggregateSize' is enabled.", "if", "aggregateSize", "{", "// Get total multipart size.", "obj", ".", "Size", ",", "err", "=", "c", ".", "getTotalMultipartSize", "(", "bucketName", ",", "obj", ".", "Key", ",", "obj", ".", "UploadID", ")", "\n", "if", "err", "!=", "nil", "{", "objectMultipartStatCh", "<-", "ObjectMultipartInfo", "{", "Err", ":", "err", ",", "}", "\n", "continue", "\n", "}", "\n", "}", "\n", "select", "{", "// Send individual uploads here.", "case", "objectMultipartStatCh", "<-", "obj", ":", "// If done channel return here.", "case", "<-", "doneCh", ":", "return", "\n", "}", "\n", "}", "\n", "// Send all common prefixes if any.", "// NOTE: prefixes are only present if the request is delimited.", "for", "_", ",", "obj", ":=", "range", "result", ".", "CommonPrefixes", "{", "object", ":=", "ObjectMultipartInfo", "{", "}", "\n", "object", ".", "Key", "=", "obj", ".", "Prefix", "\n", "object", ".", "Size", "=", "0", "\n", "select", "{", "// Send delimited prefixes here.", "case", "objectMultipartStatCh", "<-", "object", ":", "// If done channel return here.", "case", "<-", "doneCh", ":", "return", "\n", "}", "\n", "}", "\n", "// Listing ends if result not truncated, return right here.", "if", "!", "result", ".", "IsTruncated", "{", "return", "\n", "}", "\n", "}", "\n", "}", "(", "objectMultipartStatCh", ")", "\n", "// return.", "return", "objectMultipartStatCh", "\n", "}" ]
// listIncompleteUploads lists all incomplete uploads.
[ "listIncompleteUploads", "lists", "all", "incomplete", "uploads", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-list.go#L452-L537
148,688
minio/minio-go
api-list.go
listObjectParts
func (c Client) listObjectParts(bucketName, objectName, uploadID string) (partsInfo map[int]ObjectPart, err error) { // Part number marker for the next batch of request. var nextPartNumberMarker int partsInfo = make(map[int]ObjectPart) for { // Get list of uploaded parts a maximum of 1000 per request. listObjPartsResult, err := c.listObjectPartsQuery(bucketName, objectName, uploadID, nextPartNumberMarker, 1000) if err != nil { return nil, err } // Append to parts info. for _, part := range listObjPartsResult.ObjectParts { // Trim off the odd double quotes from ETag in the beginning and end. part.ETag = strings.TrimPrefix(part.ETag, "\"") part.ETag = strings.TrimSuffix(part.ETag, "\"") partsInfo[part.PartNumber] = part } // Keep part number marker, for the next iteration. nextPartNumberMarker = listObjPartsResult.NextPartNumberMarker // Listing ends result is not truncated, return right here. if !listObjPartsResult.IsTruncated { break } } // Return all the parts. return partsInfo, nil }
go
func (c Client) listObjectParts(bucketName, objectName, uploadID string) (partsInfo map[int]ObjectPart, err error) { // Part number marker for the next batch of request. var nextPartNumberMarker int partsInfo = make(map[int]ObjectPart) for { // Get list of uploaded parts a maximum of 1000 per request. listObjPartsResult, err := c.listObjectPartsQuery(bucketName, objectName, uploadID, nextPartNumberMarker, 1000) if err != nil { return nil, err } // Append to parts info. for _, part := range listObjPartsResult.ObjectParts { // Trim off the odd double quotes from ETag in the beginning and end. part.ETag = strings.TrimPrefix(part.ETag, "\"") part.ETag = strings.TrimSuffix(part.ETag, "\"") partsInfo[part.PartNumber] = part } // Keep part number marker, for the next iteration. nextPartNumberMarker = listObjPartsResult.NextPartNumberMarker // Listing ends result is not truncated, return right here. if !listObjPartsResult.IsTruncated { break } } // Return all the parts. return partsInfo, nil }
[ "func", "(", "c", "Client", ")", "listObjectParts", "(", "bucketName", ",", "objectName", ",", "uploadID", "string", ")", "(", "partsInfo", "map", "[", "int", "]", "ObjectPart", ",", "err", "error", ")", "{", "// Part number marker for the next batch of request.", "var", "nextPartNumberMarker", "int", "\n", "partsInfo", "=", "make", "(", "map", "[", "int", "]", "ObjectPart", ")", "\n", "for", "{", "// Get list of uploaded parts a maximum of 1000 per request.", "listObjPartsResult", ",", "err", ":=", "c", ".", "listObjectPartsQuery", "(", "bucketName", ",", "objectName", ",", "uploadID", ",", "nextPartNumberMarker", ",", "1000", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Append to parts info.", "for", "_", ",", "part", ":=", "range", "listObjPartsResult", ".", "ObjectParts", "{", "// Trim off the odd double quotes from ETag in the beginning and end.", "part", ".", "ETag", "=", "strings", ".", "TrimPrefix", "(", "part", ".", "ETag", ",", "\"", "\\\"", "\"", ")", "\n", "part", ".", "ETag", "=", "strings", ".", "TrimSuffix", "(", "part", ".", "ETag", ",", "\"", "\\\"", "\"", ")", "\n", "partsInfo", "[", "part", ".", "PartNumber", "]", "=", "part", "\n", "}", "\n", "// Keep part number marker, for the next iteration.", "nextPartNumberMarker", "=", "listObjPartsResult", ".", "NextPartNumberMarker", "\n", "// Listing ends result is not truncated, return right here.", "if", "!", "listObjPartsResult", ".", "IsTruncated", "{", "break", "\n", "}", "\n", "}", "\n\n", "// Return all the parts.", "return", "partsInfo", ",", "nil", "\n", "}" ]
// listObjectParts list all object parts recursively.
[ "listObjectParts", "list", "all", "object", "parts", "recursively", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-list.go#L602-L629
148,689
minio/minio-go
api-list.go
findUploadIDs
func (c Client) findUploadIDs(bucketName, objectName string) ([]string, error) { var uploadIDs []string // Make list incomplete uploads recursive. isRecursive := true // Turn off size aggregation of individual parts, in this request. isAggregateSize := false // Create done channel to cleanup the routine. doneCh := make(chan struct{}) defer close(doneCh) // List all incomplete uploads. for mpUpload := range c.listIncompleteUploads(bucketName, objectName, isRecursive, isAggregateSize, doneCh) { if mpUpload.Err != nil { return nil, mpUpload.Err } if objectName == mpUpload.Key { uploadIDs = append(uploadIDs, mpUpload.UploadID) } } // Return the latest upload id. return uploadIDs, nil }
go
func (c Client) findUploadIDs(bucketName, objectName string) ([]string, error) { var uploadIDs []string // Make list incomplete uploads recursive. isRecursive := true // Turn off size aggregation of individual parts, in this request. isAggregateSize := false // Create done channel to cleanup the routine. doneCh := make(chan struct{}) defer close(doneCh) // List all incomplete uploads. for mpUpload := range c.listIncompleteUploads(bucketName, objectName, isRecursive, isAggregateSize, doneCh) { if mpUpload.Err != nil { return nil, mpUpload.Err } if objectName == mpUpload.Key { uploadIDs = append(uploadIDs, mpUpload.UploadID) } } // Return the latest upload id. return uploadIDs, nil }
[ "func", "(", "c", "Client", ")", "findUploadIDs", "(", "bucketName", ",", "objectName", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "uploadIDs", "[", "]", "string", "\n", "// Make list incomplete uploads recursive.", "isRecursive", ":=", "true", "\n", "// Turn off size aggregation of individual parts, in this request.", "isAggregateSize", ":=", "false", "\n", "// Create done channel to cleanup the routine.", "doneCh", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "defer", "close", "(", "doneCh", ")", "\n", "// List all incomplete uploads.", "for", "mpUpload", ":=", "range", "c", ".", "listIncompleteUploads", "(", "bucketName", ",", "objectName", ",", "isRecursive", ",", "isAggregateSize", ",", "doneCh", ")", "{", "if", "mpUpload", ".", "Err", "!=", "nil", "{", "return", "nil", ",", "mpUpload", ".", "Err", "\n", "}", "\n", "if", "objectName", "==", "mpUpload", ".", "Key", "{", "uploadIDs", "=", "append", "(", "uploadIDs", ",", "mpUpload", ".", "UploadID", ")", "\n", "}", "\n", "}", "\n", "// Return the latest upload id.", "return", "uploadIDs", ",", "nil", "\n", "}" ]
// findUploadIDs lists all incomplete uploads and find the uploadIDs of the matching object name.
[ "findUploadIDs", "lists", "all", "incomplete", "uploads", "and", "find", "the", "uploadIDs", "of", "the", "matching", "object", "name", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-list.go#L632-L652
148,690
minio/minio-go
api-list.go
getTotalMultipartSize
func (c Client) getTotalMultipartSize(bucketName, objectName, uploadID string) (size int64, err error) { // Iterate over all parts and aggregate the size. partsInfo, err := c.listObjectParts(bucketName, objectName, uploadID) if err != nil { return 0, err } for _, partInfo := range partsInfo { size += partInfo.Size } return size, nil }
go
func (c Client) getTotalMultipartSize(bucketName, objectName, uploadID string) (size int64, err error) { // Iterate over all parts and aggregate the size. partsInfo, err := c.listObjectParts(bucketName, objectName, uploadID) if err != nil { return 0, err } for _, partInfo := range partsInfo { size += partInfo.Size } return size, nil }
[ "func", "(", "c", "Client", ")", "getTotalMultipartSize", "(", "bucketName", ",", "objectName", ",", "uploadID", "string", ")", "(", "size", "int64", ",", "err", "error", ")", "{", "// Iterate over all parts and aggregate the size.", "partsInfo", ",", "err", ":=", "c", ".", "listObjectParts", "(", "bucketName", ",", "objectName", ",", "uploadID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "for", "_", ",", "partInfo", ":=", "range", "partsInfo", "{", "size", "+=", "partInfo", ".", "Size", "\n", "}", "\n", "return", "size", ",", "nil", "\n", "}" ]
// getTotalMultipartSize - calculate total uploaded size for the a given multipart object.
[ "getTotalMultipartSize", "-", "calculate", "total", "uploaded", "size", "for", "the", "a", "given", "multipart", "object", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-list.go#L655-L665
148,691
minio/minio-go
retry-continous.go
newRetryTimerContinous
func (c Client) newRetryTimerContinous(unit time.Duration, cap time.Duration, jitter float64, doneCh chan struct{}) <-chan int { attemptCh := make(chan int) // normalize jitter to the range [0, 1.0] if jitter < NoJitter { jitter = NoJitter } if jitter > MaxJitter { jitter = MaxJitter } // computes the exponential backoff duration according to // https://www.awsarchitectureblog.com/2015/03/backoff.html exponentialBackoffWait := func(attempt int) time.Duration { // 1<<uint(attempt) below could overflow, so limit the value of attempt maxAttempt := 30 if attempt > maxAttempt { attempt = maxAttempt } //sleep = random_between(0, min(cap, base * 2 ** attempt)) sleep := unit * time.Duration(1<<uint(attempt)) if sleep > cap { sleep = cap } if jitter != NoJitter { sleep -= time.Duration(c.random.Float64() * float64(sleep) * jitter) } return sleep } go func() { defer close(attemptCh) var nextBackoff int for { select { // Attempts starts. case attemptCh <- nextBackoff: nextBackoff++ case <-doneCh: // Stop the routine. return } time.Sleep(exponentialBackoffWait(nextBackoff)) } }() return attemptCh }
go
func (c Client) newRetryTimerContinous(unit time.Duration, cap time.Duration, jitter float64, doneCh chan struct{}) <-chan int { attemptCh := make(chan int) // normalize jitter to the range [0, 1.0] if jitter < NoJitter { jitter = NoJitter } if jitter > MaxJitter { jitter = MaxJitter } // computes the exponential backoff duration according to // https://www.awsarchitectureblog.com/2015/03/backoff.html exponentialBackoffWait := func(attempt int) time.Duration { // 1<<uint(attempt) below could overflow, so limit the value of attempt maxAttempt := 30 if attempt > maxAttempt { attempt = maxAttempt } //sleep = random_between(0, min(cap, base * 2 ** attempt)) sleep := unit * time.Duration(1<<uint(attempt)) if sleep > cap { sleep = cap } if jitter != NoJitter { sleep -= time.Duration(c.random.Float64() * float64(sleep) * jitter) } return sleep } go func() { defer close(attemptCh) var nextBackoff int for { select { // Attempts starts. case attemptCh <- nextBackoff: nextBackoff++ case <-doneCh: // Stop the routine. return } time.Sleep(exponentialBackoffWait(nextBackoff)) } }() return attemptCh }
[ "func", "(", "c", "Client", ")", "newRetryTimerContinous", "(", "unit", "time", ".", "Duration", ",", "cap", "time", ".", "Duration", ",", "jitter", "float64", ",", "doneCh", "chan", "struct", "{", "}", ")", "<-", "chan", "int", "{", "attemptCh", ":=", "make", "(", "chan", "int", ")", "\n\n", "// normalize jitter to the range [0, 1.0]", "if", "jitter", "<", "NoJitter", "{", "jitter", "=", "NoJitter", "\n", "}", "\n", "if", "jitter", ">", "MaxJitter", "{", "jitter", "=", "MaxJitter", "\n", "}", "\n\n", "// computes the exponential backoff duration according to", "// https://www.awsarchitectureblog.com/2015/03/backoff.html", "exponentialBackoffWait", ":=", "func", "(", "attempt", "int", ")", "time", ".", "Duration", "{", "// 1<<uint(attempt) below could overflow, so limit the value of attempt", "maxAttempt", ":=", "30", "\n", "if", "attempt", ">", "maxAttempt", "{", "attempt", "=", "maxAttempt", "\n", "}", "\n", "//sleep = random_between(0, min(cap, base * 2 ** attempt))", "sleep", ":=", "unit", "*", "time", ".", "Duration", "(", "1", "<<", "uint", "(", "attempt", ")", ")", "\n", "if", "sleep", ">", "cap", "{", "sleep", "=", "cap", "\n", "}", "\n", "if", "jitter", "!=", "NoJitter", "{", "sleep", "-=", "time", ".", "Duration", "(", "c", ".", "random", ".", "Float64", "(", ")", "*", "float64", "(", "sleep", ")", "*", "jitter", ")", "\n", "}", "\n", "return", "sleep", "\n", "}", "\n\n", "go", "func", "(", ")", "{", "defer", "close", "(", "attemptCh", ")", "\n", "var", "nextBackoff", "int", "\n", "for", "{", "select", "{", "// Attempts starts.", "case", "attemptCh", "<-", "nextBackoff", ":", "nextBackoff", "++", "\n", "case", "<-", "doneCh", ":", "// Stop the routine.", "return", "\n", "}", "\n", "time", ".", "Sleep", "(", "exponentialBackoffWait", "(", "nextBackoff", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "return", "attemptCh", "\n", "}" ]
// newRetryTimerContinous creates a timer with exponentially increasing delays forever.
[ "newRetryTimerContinous", "creates", "a", "timer", "with", "exponentially", "increasing", "delays", "forever", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/retry-continous.go#L23-L69
148,692
minio/minio-go
pkg/credentials/iam_aws.go
NewIAM
func NewIAM(endpoint string) *Credentials { p := &IAM{ Client: &http.Client{ Transport: http.DefaultTransport, }, endpoint: endpoint, } return New(p) }
go
func NewIAM(endpoint string) *Credentials { p := &IAM{ Client: &http.Client{ Transport: http.DefaultTransport, }, endpoint: endpoint, } return New(p) }
[ "func", "NewIAM", "(", "endpoint", "string", ")", "*", "Credentials", "{", "p", ":=", "&", "IAM", "{", "Client", ":", "&", "http", ".", "Client", "{", "Transport", ":", "http", ".", "DefaultTransport", ",", "}", ",", "endpoint", ":", "endpoint", ",", "}", "\n", "return", "New", "(", "p", ")", "\n", "}" ]
// NewIAM returns a pointer to a new Credentials object wrapping the IAM.
[ "NewIAM", "returns", "a", "pointer", "to", "a", "new", "Credentials", "object", "wrapping", "the", "IAM", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/iam_aws.go#L71-L79
148,693
minio/minio-go
pkg/credentials/iam_aws.go
Retrieve
func (m *IAM) Retrieve() (Value, error) { endpoint, isEcsTask := getEndpoint(m.endpoint) var roleCreds ec2RoleCredRespBody var err error if isEcsTask { roleCreds, err = getEcsTaskCredentials(m.Client, endpoint) } else { roleCreds, err = getCredentials(m.Client, endpoint) } if err != nil { return Value{}, err } // Expiry window is set to 10secs. m.SetExpiration(roleCreds.Expiration, DefaultExpiryWindow) return Value{ AccessKeyID: roleCreds.AccessKeyID, SecretAccessKey: roleCreds.SecretAccessKey, SessionToken: roleCreds.Token, SignerType: SignatureV4, }, nil }
go
func (m *IAM) Retrieve() (Value, error) { endpoint, isEcsTask := getEndpoint(m.endpoint) var roleCreds ec2RoleCredRespBody var err error if isEcsTask { roleCreds, err = getEcsTaskCredentials(m.Client, endpoint) } else { roleCreds, err = getCredentials(m.Client, endpoint) } if err != nil { return Value{}, err } // Expiry window is set to 10secs. m.SetExpiration(roleCreds.Expiration, DefaultExpiryWindow) return Value{ AccessKeyID: roleCreds.AccessKeyID, SecretAccessKey: roleCreds.SecretAccessKey, SessionToken: roleCreds.Token, SignerType: SignatureV4, }, nil }
[ "func", "(", "m", "*", "IAM", ")", "Retrieve", "(", ")", "(", "Value", ",", "error", ")", "{", "endpoint", ",", "isEcsTask", ":=", "getEndpoint", "(", "m", ".", "endpoint", ")", "\n", "var", "roleCreds", "ec2RoleCredRespBody", "\n", "var", "err", "error", "\n", "if", "isEcsTask", "{", "roleCreds", ",", "err", "=", "getEcsTaskCredentials", "(", "m", ".", "Client", ",", "endpoint", ")", "\n", "}", "else", "{", "roleCreds", ",", "err", "=", "getCredentials", "(", "m", ".", "Client", ",", "endpoint", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "Value", "{", "}", ",", "err", "\n", "}", "\n", "// Expiry window is set to 10secs.", "m", ".", "SetExpiration", "(", "roleCreds", ".", "Expiration", ",", "DefaultExpiryWindow", ")", "\n\n", "return", "Value", "{", "AccessKeyID", ":", "roleCreds", ".", "AccessKeyID", ",", "SecretAccessKey", ":", "roleCreds", ".", "SecretAccessKey", ",", "SessionToken", ":", "roleCreds", ".", "Token", ",", "SignerType", ":", "SignatureV4", ",", "}", ",", "nil", "\n", "}" ]
// Retrieve retrieves credentials from the EC2 service. // Error will be returned if the request fails, or unable to extract // the desired
[ "Retrieve", "retrieves", "credentials", "from", "the", "EC2", "service", ".", "Error", "will", "be", "returned", "if", "the", "request", "fails", "or", "unable", "to", "extract", "the", "desired" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/iam_aws.go#L84-L105
148,694
minio/minio-go
pkg/credentials/iam_aws.go
getCredentials
func getCredentials(client *http.Client, endpoint string) (ec2RoleCredRespBody, error) { // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html u, err := getIAMRoleURL(endpoint) if err != nil { return ec2RoleCredRespBody{}, err } // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html roleNames, err := listRoleNames(client, u) if err != nil { return ec2RoleCredRespBody{}, err } if len(roleNames) == 0 { return ec2RoleCredRespBody{}, errors.New("No IAM roles attached to this EC2 service") } // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html // - An instance profile can contain only one IAM role. This limit cannot be increased. roleName := roleNames[0] // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html // The following command retrieves the security credentials for an // IAM role named `s3access`. // // $ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access // u.Path = path.Join(u.Path, roleName) req, err := http.NewRequest("GET", u.String(), nil) if err != nil { return ec2RoleCredRespBody{}, err } resp, err := client.Do(req) if err != nil { return ec2RoleCredRespBody{}, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return ec2RoleCredRespBody{}, errors.New(resp.Status) } respCreds := ec2RoleCredRespBody{} if err := json.NewDecoder(resp.Body).Decode(&respCreds); err != nil { return ec2RoleCredRespBody{}, err } if respCreds.Code != "Success" { // If an error code was returned something failed requesting the role. return ec2RoleCredRespBody{}, errors.New(respCreds.Message) } return respCreds, nil }
go
func getCredentials(client *http.Client, endpoint string) (ec2RoleCredRespBody, error) { // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html u, err := getIAMRoleURL(endpoint) if err != nil { return ec2RoleCredRespBody{}, err } // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html roleNames, err := listRoleNames(client, u) if err != nil { return ec2RoleCredRespBody{}, err } if len(roleNames) == 0 { return ec2RoleCredRespBody{}, errors.New("No IAM roles attached to this EC2 service") } // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html // - An instance profile can contain only one IAM role. This limit cannot be increased. roleName := roleNames[0] // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html // The following command retrieves the security credentials for an // IAM role named `s3access`. // // $ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access // u.Path = path.Join(u.Path, roleName) req, err := http.NewRequest("GET", u.String(), nil) if err != nil { return ec2RoleCredRespBody{}, err } resp, err := client.Do(req) if err != nil { return ec2RoleCredRespBody{}, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return ec2RoleCredRespBody{}, errors.New(resp.Status) } respCreds := ec2RoleCredRespBody{} if err := json.NewDecoder(resp.Body).Decode(&respCreds); err != nil { return ec2RoleCredRespBody{}, err } if respCreds.Code != "Success" { // If an error code was returned something failed requesting the role. return ec2RoleCredRespBody{}, errors.New(respCreds.Message) } return respCreds, nil }
[ "func", "getCredentials", "(", "client", "*", "http", ".", "Client", ",", "endpoint", "string", ")", "(", "ec2RoleCredRespBody", ",", "error", ")", "{", "// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html", "u", ",", "err", ":=", "getIAMRoleURL", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "err", "\n", "}", "\n\n", "// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html", "roleNames", ",", "err", ":=", "listRoleNames", "(", "client", ",", "u", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "roleNames", ")", "==", "0", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html", "// - An instance profile can contain only one IAM role. This limit cannot be increased.", "roleName", ":=", "roleNames", "[", "0", "]", "\n\n", "// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html", "// The following command retrieves the security credentials for an", "// IAM role named `s3access`.", "//", "// $ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access", "//", "u", ".", "Path", "=", "path", ".", "Join", "(", "u", ".", "Path", ",", "roleName", ")", "\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "u", ".", "String", "(", ")", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "err", "\n", "}", "\n\n", "resp", ",", "err", ":=", "client", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "errors", ".", "New", "(", "resp", ".", "Status", ")", "\n", "}", "\n\n", "respCreds", ":=", "ec2RoleCredRespBody", "{", "}", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "resp", ".", "Body", ")", ".", "Decode", "(", "&", "respCreds", ")", ";", "err", "!=", "nil", "{", "return", "ec2RoleCredRespBody", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "respCreds", ".", "Code", "!=", "\"", "\"", "{", "// If an error code was returned something failed requesting the role.", "return", "ec2RoleCredRespBody", "{", "}", ",", "errors", ".", "New", "(", "respCreds", ".", "Message", ")", "\n", "}", "\n\n", "return", "respCreds", ",", "nil", "\n", "}" ]
// getCredentials - obtains the credentials from the IAM role name associated with // the current EC2 service. // // If the credentials cannot be found, or there is an error // reading the response an error will be returned.
[ "getCredentials", "-", "obtains", "the", "credentials", "from", "the", "IAM", "role", "name", "associated", "with", "the", "current", "EC2", "service", ".", "If", "the", "credentials", "cannot", "be", "found", "or", "there", "is", "an", "error", "reading", "the", "response", "an", "error", "will", "be", "returned", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/iam_aws.go#L196-L250
148,695
minio/minio-go
api-put-object-copy.go
CopyObject
func (c Client) CopyObject(dst DestinationInfo, src SourceInfo) error { return c.CopyObjectWithProgress(dst, src, nil) }
go
func (c Client) CopyObject(dst DestinationInfo, src SourceInfo) error { return c.CopyObjectWithProgress(dst, src, nil) }
[ "func", "(", "c", "Client", ")", "CopyObject", "(", "dst", "DestinationInfo", ",", "src", "SourceInfo", ")", "error", "{", "return", "c", ".", "CopyObjectWithProgress", "(", "dst", ",", "src", ",", "nil", ")", "\n", "}" ]
// CopyObject - copy a source object into a new object
[ "CopyObject", "-", "copy", "a", "source", "object", "into", "a", "new", "object" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-copy.go#L30-L32
148,696
minio/minio-go
api-put-object-copy.go
CopyObjectWithProgress
func (c Client) CopyObjectWithProgress(dst DestinationInfo, src SourceInfo, progress io.Reader) error { header := make(http.Header) for k, v := range src.Headers { header[k] = v } var err error var size int64 // If progress bar is specified, size should be requested as well initiate a StatObject request. if progress != nil { size, _, _, err = src.getProps(c) if err != nil { return err } } if src.encryption != nil { encrypt.SSECopy(src.encryption).Marshal(header) } if dst.encryption != nil { dst.encryption.Marshal(header) } for k, v := range dst.getUserMetaHeadersMap(true) { header.Set(k, v) } resp, err := c.executeMethod(context.Background(), "PUT", requestMetadata{ bucketName: dst.bucket, objectName: dst.object, customHeader: header, }) if err != nil { return err } defer closeResponse(resp) if resp.StatusCode != http.StatusOK { return httpRespToErrorResponse(resp, dst.bucket, dst.object) } // Update the progress properly after successful copy. if progress != nil { io.CopyN(ioutil.Discard, progress, size) } return nil }
go
func (c Client) CopyObjectWithProgress(dst DestinationInfo, src SourceInfo, progress io.Reader) error { header := make(http.Header) for k, v := range src.Headers { header[k] = v } var err error var size int64 // If progress bar is specified, size should be requested as well initiate a StatObject request. if progress != nil { size, _, _, err = src.getProps(c) if err != nil { return err } } if src.encryption != nil { encrypt.SSECopy(src.encryption).Marshal(header) } if dst.encryption != nil { dst.encryption.Marshal(header) } for k, v := range dst.getUserMetaHeadersMap(true) { header.Set(k, v) } resp, err := c.executeMethod(context.Background(), "PUT", requestMetadata{ bucketName: dst.bucket, objectName: dst.object, customHeader: header, }) if err != nil { return err } defer closeResponse(resp) if resp.StatusCode != http.StatusOK { return httpRespToErrorResponse(resp, dst.bucket, dst.object) } // Update the progress properly after successful copy. if progress != nil { io.CopyN(ioutil.Discard, progress, size) } return nil }
[ "func", "(", "c", "Client", ")", "CopyObjectWithProgress", "(", "dst", "DestinationInfo", ",", "src", "SourceInfo", ",", "progress", "io", ".", "Reader", ")", "error", "{", "header", ":=", "make", "(", "http", ".", "Header", ")", "\n", "for", "k", ",", "v", ":=", "range", "src", ".", "Headers", "{", "header", "[", "k", "]", "=", "v", "\n", "}", "\n\n", "var", "err", "error", "\n", "var", "size", "int64", "\n", "// If progress bar is specified, size should be requested as well initiate a StatObject request.", "if", "progress", "!=", "nil", "{", "size", ",", "_", ",", "_", ",", "err", "=", "src", ".", "getProps", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "src", ".", "encryption", "!=", "nil", "{", "encrypt", ".", "SSECopy", "(", "src", ".", "encryption", ")", ".", "Marshal", "(", "header", ")", "\n", "}", "\n\n", "if", "dst", ".", "encryption", "!=", "nil", "{", "dst", ".", "encryption", ".", "Marshal", "(", "header", ")", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "dst", ".", "getUserMetaHeadersMap", "(", "true", ")", "{", "header", ".", "Set", "(", "k", ",", "v", ")", "\n", "}", "\n\n", "resp", ",", "err", ":=", "c", ".", "executeMethod", "(", "context", ".", "Background", "(", ")", ",", "\"", "\"", ",", "requestMetadata", "{", "bucketName", ":", "dst", ".", "bucket", ",", "objectName", ":", "dst", ".", "object", ",", "customHeader", ":", "header", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "closeResponse", "(", "resp", ")", "\n\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "return", "httpRespToErrorResponse", "(", "resp", ",", "dst", ".", "bucket", ",", "dst", ".", "object", ")", "\n", "}", "\n\n", "// Update the progress properly after successful copy.", "if", "progress", "!=", "nil", "{", "io", ".", "CopyN", "(", "ioutil", ".", "Discard", ",", "progress", ",", "size", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// CopyObjectWithProgress - copy a source object into a new object, optionally takes // progress bar input to notify current progress.
[ "CopyObjectWithProgress", "-", "copy", "a", "source", "object", "into", "a", "new", "object", "optionally", "takes", "progress", "bar", "input", "to", "notify", "current", "progress", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-copy.go#L36-L83
148,697
minio/minio-go
api-put-object-file.go
FPutObject
func (c Client) FPutObject(bucketName, objectName, filePath string, opts PutObjectOptions) (n int64, err error) { return c.FPutObjectWithContext(context.Background(), bucketName, objectName, filePath, opts) }
go
func (c Client) FPutObject(bucketName, objectName, filePath string, opts PutObjectOptions) (n int64, err error) { return c.FPutObjectWithContext(context.Background(), bucketName, objectName, filePath, opts) }
[ "func", "(", "c", "Client", ")", "FPutObject", "(", "bucketName", ",", "objectName", ",", "filePath", "string", ",", "opts", "PutObjectOptions", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "return", "c", ".", "FPutObjectWithContext", "(", "context", ".", "Background", "(", ")", ",", "bucketName", ",", "objectName", ",", "filePath", ",", "opts", ")", "\n", "}" ]
// FPutObject - Create an object in a bucket, with contents from file at filePath
[ "FPutObject", "-", "Create", "an", "object", "in", "a", "bucket", "with", "contents", "from", "file", "at", "filePath" ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-file.go#L25-L27
148,698
minio/minio-go
s3-endpoints.go
getS3Endpoint
func getS3Endpoint(bucketLocation string) (s3Endpoint string) { s3Endpoint, ok := awsS3EndpointMap[bucketLocation] if !ok { // Default to 's3.dualstack.us-east-1.amazonaws.com' endpoint. s3Endpoint = "s3.dualstack.us-east-1.amazonaws.com" } return s3Endpoint }
go
func getS3Endpoint(bucketLocation string) (s3Endpoint string) { s3Endpoint, ok := awsS3EndpointMap[bucketLocation] if !ok { // Default to 's3.dualstack.us-east-1.amazonaws.com' endpoint. s3Endpoint = "s3.dualstack.us-east-1.amazonaws.com" } return s3Endpoint }
[ "func", "getS3Endpoint", "(", "bucketLocation", "string", ")", "(", "s3Endpoint", "string", ")", "{", "s3Endpoint", ",", "ok", ":=", "awsS3EndpointMap", "[", "bucketLocation", "]", "\n", "if", "!", "ok", "{", "// Default to 's3.dualstack.us-east-1.amazonaws.com' endpoint.", "s3Endpoint", "=", "\"", "\"", "\n", "}", "\n", "return", "s3Endpoint", "\n", "}" ]
// getS3Endpoint get Amazon S3 endpoint based on the bucket location.
[ "getS3Endpoint", "get", "Amazon", "S3", "endpoint", "based", "on", "the", "bucket", "location", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/s3-endpoints.go#L45-L52
148,699
minio/minio-go
api-get-policy.go
GetBucketPolicy
func (c Client) GetBucketPolicy(bucketName string) (string, error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return "", err } bucketPolicy, err := c.getBucketPolicy(bucketName) if err != nil { errResponse := ToErrorResponse(err) if errResponse.Code == "NoSuchBucketPolicy" { return "", nil } return "", err } return bucketPolicy, nil }
go
func (c Client) GetBucketPolicy(bucketName string) (string, error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return "", err } bucketPolicy, err := c.getBucketPolicy(bucketName) if err != nil { errResponse := ToErrorResponse(err) if errResponse.Code == "NoSuchBucketPolicy" { return "", nil } return "", err } return bucketPolicy, nil }
[ "func", "(", "c", "Client", ")", "GetBucketPolicy", "(", "bucketName", "string", ")", "(", "string", ",", "error", ")", "{", "// Input validation.", "if", "err", ":=", "s3utils", ".", "CheckValidBucketName", "(", "bucketName", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "bucketPolicy", ",", "err", ":=", "c", ".", "getBucketPolicy", "(", "bucketName", ")", "\n", "if", "err", "!=", "nil", "{", "errResponse", ":=", "ToErrorResponse", "(", "err", ")", "\n", "if", "errResponse", ".", "Code", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "bucketPolicy", ",", "nil", "\n", "}" ]
// GetBucketPolicy - get bucket policy at a given path.
[ "GetBucketPolicy", "-", "get", "bucket", "policy", "at", "a", "given", "path", "." ]
68eef499b4c530409962a5d1a12fa8c848587761
https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-policy.go#L30-L44