Skip to content

Commit 589ff8d

Browse files
run gofumpt -extra -w on all files (#1854)
1 parent b7aec2f commit 589ff8d

21 files changed

+44
-44
lines changed

api-bucket-replication.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (c *Client) ResetBucketReplicationOnTarget(ctx context.Context, bucketName
219219

220220
// ResetBucketReplication kicks off replication of previously replicated objects if ExistingObjectReplication
221221
// is enabled in the replication config
222-
func (c *Client) resetBucketReplicationOnTarget(ctx context.Context, bucketName string, olderThan time.Duration, tgtArn string, resetID string) (rinfo replication.ResyncTargetsInfo, err error) {
222+
func (c *Client) resetBucketReplicationOnTarget(ctx context.Context, bucketName string, olderThan time.Duration, tgtArn, resetID string) (rinfo replication.ResyncTargetsInfo, err error) {
223223
// Input validation.
224224
if err = s3utils.CheckValidBucketName(bucketName); err != nil {
225225
return

api-compose-object.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ func (c *Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBuc
286286
return objInfo, nil
287287
}
288288

289-
func (c *Client) copyObjectPartDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string,
290-
partID int, startOffset int64, length int64, metadata map[string]string,
289+
func (c *Client) copyObjectPartDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject, uploadID string,
290+
partID int, startOffset, length int64, metadata map[string]string,
291291
) (p CompletePart, err error) {
292292
headers := make(http.Header)
293293

api-list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (c *Client) listObjectsV2(ctx context.Context, bucketName string, opts List
176176
// ?delimiter - A delimiter is a character you use to group keys.
177177
// ?start-after - Sets a marker to start listing lexically at this key onwards.
178178
// ?max-keys - Sets the maximum number of keys returned in the response body.
179-
func (c *Client) listObjectsV2Query(ctx context.Context, bucketName, objectPrefix, continuationToken string, fetchOwner, metadata bool, delimiter string, startAfter string, maxkeys int, headers http.Header) (ListBucketV2Result, error) {
179+
func (c *Client) listObjectsV2Query(ctx context.Context, bucketName, objectPrefix, continuationToken string, fetchOwner, metadata bool, delimiter, startAfter string, maxkeys int, headers http.Header) (ListBucketV2Result, error) {
180180
// Validate bucket name.
181181
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
182182
return ListBucketV2Result{}, err

api-presigned.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
// presignURL - Returns a presigned URL for an input 'method'.
3232
// Expires maximum is 7days - ie. 604800 and minimum is 1.
33-
func (c *Client) presignURL(ctx context.Context, method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values, extraHeaders http.Header) (u *url.URL, err error) {
33+
func (c *Client) presignURL(ctx context.Context, method, bucketName, objectName string, expires time.Duration, reqParams url.Values, extraHeaders http.Header) (u *url.URL, err error) {
3434
// Input validation.
3535
if method == "" {
3636
return nil, errInvalidArgument("method cannot be empty.")
@@ -66,7 +66,7 @@ func (c *Client) presignURL(ctx context.Context, method string, bucketName strin
6666
// data without credentials. URL can have a maximum expiry of
6767
// upto 7days or a minimum of 1sec. Additionally you can override
6868
// a set of response headers using the query parameters.
69-
func (c *Client) PresignedGetObject(ctx context.Context, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
69+
func (c *Client) PresignedGetObject(ctx context.Context, bucketName, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
7070
if err = s3utils.CheckValidObjectName(objectName); err != nil {
7171
return nil, err
7272
}
@@ -77,7 +77,7 @@ func (c *Client) PresignedGetObject(ctx context.Context, bucketName string, obje
7777
// object metadata without credentials. URL can have a maximum expiry
7878
// of upto 7days or a minimum of 1sec. Additionally you can override
7979
// a set of response headers using the query parameters.
80-
func (c *Client) PresignedHeadObject(ctx context.Context, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
80+
func (c *Client) PresignedHeadObject(ctx context.Context, bucketName, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
8181
if err = s3utils.CheckValidObjectName(objectName); err != nil {
8282
return nil, err
8383
}
@@ -87,7 +87,7 @@ func (c *Client) PresignedHeadObject(ctx context.Context, bucketName string, obj
8787
// PresignedPutObject - Returns a presigned URL to upload an object
8888
// without credentials. URL can have a maximum expiry of upto 7days
8989
// or a minimum of 1sec.
90-
func (c *Client) PresignedPutObject(ctx context.Context, bucketName string, objectName string, expires time.Duration) (u *url.URL, err error) {
90+
func (c *Client) PresignedPutObject(ctx context.Context, bucketName, objectName string, expires time.Duration) (u *url.URL, err error) {
9191
if err = s3utils.CheckValidObjectName(objectName); err != nil {
9292
return nil, err
9393
}
@@ -101,14 +101,14 @@ func (c *Client) PresignedPutObject(ctx context.Context, bucketName string, obje
101101
//
102102
// FIXME: The extra header parameter should be included in Presign() in the next
103103
// major version bump, and this function should then be deprecated.
104-
func (c *Client) PresignHeader(ctx context.Context, method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values, extraHeaders http.Header) (u *url.URL, err error) {
104+
func (c *Client) PresignHeader(ctx context.Context, method, bucketName, objectName string, expires time.Duration, reqParams url.Values, extraHeaders http.Header) (u *url.URL, err error) {
105105
return c.presignURL(ctx, method, bucketName, objectName, expires, reqParams, extraHeaders)
106106
}
107107

108108
// Presign - returns a presigned URL for any http method of your choice along
109109
// with custom request params and extra signed headers. URL can have a maximum
110110
// expiry of upto 7days or a minimum of 1sec.
111-
func (c *Client) Presign(ctx context.Context, method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
111+
func (c *Client) Presign(ctx context.Context, method, bucketName, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
112112
return c.presignURL(ctx, method, bucketName, objectName, expires, reqParams, nil)
113113
}
114114

api-put-bucket.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (c *Client) makeBucket(ctx context.Context, bucketName string, opts MakeBuc
4242
return err
4343
}
4444

45-
func (c *Client) doMakeBucket(ctx context.Context, bucketName string, location string, objectLockEnabled bool) (err error) {
45+
func (c *Client) doMakeBucket(ctx context.Context, bucketName, location string, objectLockEnabled bool) (err error) {
4646
defer func() {
4747
// Save the location into cache on a successful makeBucket response.
4848
if err == nil {

api-put-object-common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func isReadAt(reader io.Reader) (ok bool) {
6868
// maxPartsCount - 10000
6969
// minPartSize - 16MiB
7070
// maxMultipartPutObjectSize - 5TiB
71-
func OptimalPartInfo(objectSize int64, configuredPartSize uint64) (totalPartsCount int, partSize int64, lastPartSize int64, err error) {
71+
func OptimalPartInfo(objectSize int64, configuredPartSize uint64) (totalPartsCount int, partSize, lastPartSize int64, err error) {
7272
// object size is '-1' set it to 5TiB.
7373
var unknownSize bool
7474
if objectSize == -1 {

api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func privateNew(endpoint string, opts *Options) (*Client, error) {
278278
}
279279

280280
// SetAppInfo - add application details to user agent.
281-
func (c *Client) SetAppInfo(appName string, appVersion string) {
281+
func (c *Client) SetAppInfo(appName, appVersion string) {
282282
// if app name and version not set, we do not set a new user agent.
283283
if appName != "" && appVersion != "" {
284284
c.appInfo.appName = appName

bucket-cache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (r *bucketLocationCache) Get(bucketName string) (location string, ok bool)
5858
}
5959

6060
// Set - Will persist a value into cache.
61-
func (r *bucketLocationCache) Set(bucketName string, location string) {
61+
func (r *bucketLocationCache) Set(bucketName, location string) {
6262
r.Lock()
6363
defer r.Unlock()
6464
r.items[bucketName] = location

core.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (c Core) CopyObject(ctx context.Context, sourceBucket, sourceObject, destBu
6262

6363
// CopyObjectPart - creates a part in a multipart upload by copying (a
6464
// part of) an existing object.
65-
func (c Core) CopyObjectPart(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string,
65+
func (c Core) CopyObjectPart(ctx context.Context, srcBucket, srcObject, destBucket, destObject, uploadID string,
6666
partID int, startOffset, length int64, metadata map[string]string,
6767
) (p CompletePart, err error) {
6868
return c.copyObjectPartDo(ctx, srcBucket, srcObject, destBucket, destObject, uploadID,
@@ -115,7 +115,7 @@ func (c Core) PutObjectPart(ctx context.Context, bucket, object, uploadID string
115115
}
116116

117117
// ListObjectParts - List uploaded parts of an incomplete upload.x
118-
func (c Core) ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker int, maxParts int) (result ListObjectPartsResult, err error) {
118+
func (c Core) ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker, maxParts int) (result ListObjectPartsResult, err error) {
119119
return c.listObjectPartsQuery(ctx, bucket, object, uploadID, partNumberMarker, maxParts)
120120
}
121121

functional_tests.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func cleanEmptyEntries(fields log.Fields) log.Fields {
141141
}
142142

143143
// log successful test runs
144-
func successLogger(testName string, function string, args map[string]interface{}, startTime time.Time) *log.Entry {
144+
func successLogger(testName, function string, args map[string]interface{}, startTime time.Time) *log.Entry {
145145
// calculate the test case duration
146146
duration := time.Since(startTime)
147147
// log with the fields as per mint
@@ -151,7 +151,7 @@ func successLogger(testName string, function string, args map[string]interface{}
151151

152152
// As few of the features are not available in Gateway(s) currently, Check if err value is NotImplemented,
153153
// and log as NA in that case and continue execution. Otherwise log as failure and return
154-
func logError(testName string, function string, args map[string]interface{}, startTime time.Time, alert string, message string, err error) {
154+
func logError(testName, function string, args map[string]interface{}, startTime time.Time, alert, message string, err error) {
155155
// If server returns NotImplemented we assume it is gateway mode and hence log it as info and move on to next tests
156156
// Special case for ComposeObject API as it is implemented on client side and adds specific error details like `Error in upload-part-copy` in
157157
// addition to NotImplemented error returned from server
@@ -165,7 +165,7 @@ func logError(testName string, function string, args map[string]interface{}, sta
165165
}
166166

167167
// log failed test runs
168-
func failureLog(testName string, function string, args map[string]interface{}, startTime time.Time, alert string, message string, err error) *log.Entry {
168+
func failureLog(testName, function string, args map[string]interface{}, startTime time.Time, alert, message string, err error) *log.Entry {
169169
// calculate the test case duration
170170
duration := time.Since(startTime)
171171
var fields log.Fields
@@ -185,7 +185,7 @@ func failureLog(testName string, function string, args map[string]interface{}, s
185185
}
186186

187187
// log not applicable test runs
188-
func ignoredLog(testName string, function string, args map[string]interface{}, startTime time.Time, alert string) *log.Entry {
188+
func ignoredLog(testName, function string, args map[string]interface{}, startTime time.Time, alert string) *log.Entry {
189189
// calculate the test case duration
190190
duration := time.Since(startTime)
191191
// log with the fields as per mint

pkg/credentials/file_aws_credentials.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type FileAWSCredentials struct {
6464

6565
// NewFileAWSCredentials returns a pointer to a new Credentials object
6666
// wrapping the Profile file provider.
67-
func NewFileAWSCredentials(filename string, profile string) *Credentials {
67+
func NewFileAWSCredentials(filename, profile string) *Credentials {
6868
return New(&FileAWSCredentials{
6969
Filename: filename,
7070
Profile: profile,

pkg/credentials/file_minio_client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type FileMinioClient struct {
4949

5050
// NewFileMinioClient returns a pointer to a new Credentials object
5151
// wrapping the Alias file provider.
52-
func NewFileMinioClient(filename string, alias string) *Credentials {
52+
func NewFileMinioClient(filename, alias string) *Credentials {
5353
return New(&FileMinioClient{
5454
Filename: filename,
5555
Alias: alias,

pkg/credentials/iam_aws.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func listRoleNames(client *http.Client, u *url.URL, token string) ([]string, err
227227
return credsList, nil
228228
}
229229

230-
func getEcsTaskCredentials(client *http.Client, endpoint string, token string) (ec2RoleCredRespBody, error) {
230+
func getEcsTaskCredentials(client *http.Client, endpoint, token string) (ec2RoleCredRespBody, error) {
231231
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
232232
if err != nil {
233233
return ec2RoleCredRespBody{}, err

pkg/policy/bucket-policy-condition.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func CopyConditionKeyMap(condKeyMap ConditionKeyMap) ConditionKeyMap {
6161
}
6262

6363
// mergeConditionKeyMap - returns a new ConditionKeyMap which contains merged key/value of given two ConditionKeyMap.
64-
func mergeConditionKeyMap(condKeyMap1 ConditionKeyMap, condKeyMap2 ConditionKeyMap) ConditionKeyMap {
64+
func mergeConditionKeyMap(condKeyMap1, condKeyMap2 ConditionKeyMap) ConditionKeyMap {
6565
out := CopyConditionKeyMap(condKeyMap1)
6666

6767
for k, v := range condKeyMap2 {
@@ -93,7 +93,7 @@ func (cond ConditionMap) Remove(condKey string) {
9393
}
9494

9595
// mergeConditionMap - returns new ConditionMap which contains merged key/value of two ConditionMap.
96-
func mergeConditionMap(condMap1 ConditionMap, condMap2 ConditionMap) ConditionMap {
96+
func mergeConditionMap(condMap1, condMap2 ConditionMap) ConditionMap {
9797
out := make(ConditionMap)
9898

9999
for k, v := range condMap1 {

pkg/policy/bucket-policy.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var validActions = commonBucketActions.
7474
Union(readOnlyObjectActions).
7575
Union(writeOnlyObjectActions)
7676

77-
var startsWithFunc = func(resource string, resourcePrefix string) bool {
77+
var startsWithFunc = func(resource, resourcePrefix string) bool {
7878
return strings.HasPrefix(resource, resourcePrefix)
7979
}
8080

@@ -154,7 +154,7 @@ func isValidStatement(statement Statement, bucketName string) bool {
154154
}
155155

156156
// Returns new statements with bucket actions for given policy.
157-
func newBucketStatement(policy BucketPolicy, bucketName string, prefix string) (statements []Statement) {
157+
func newBucketStatement(policy BucketPolicy, bucketName, prefix string) (statements []Statement) {
158158
statements = []Statement{}
159159
if policy == BucketPolicyNone || bucketName == "" {
160160
return statements
@@ -204,7 +204,7 @@ func newBucketStatement(policy BucketPolicy, bucketName string, prefix string) (
204204
}
205205

206206
// Returns new statements contains object actions for given policy.
207-
func newObjectStatement(policy BucketPolicy, bucketName string, prefix string) (statements []Statement) {
207+
func newObjectStatement(policy BucketPolicy, bucketName, prefix string) (statements []Statement) {
208208
statements = []Statement{}
209209
if policy == BucketPolicyNone || bucketName == "" {
210210
return statements
@@ -230,7 +230,7 @@ func newObjectStatement(policy BucketPolicy, bucketName string, prefix string) (
230230
}
231231

232232
// Returns new statements for given policy, bucket and prefix.
233-
func newStatements(policy BucketPolicy, bucketName string, prefix string) (statements []Statement) {
233+
func newStatements(policy BucketPolicy, bucketName, prefix string) (statements []Statement) {
234234
statements = []Statement{}
235235
ns := newBucketStatement(policy, bucketName, prefix)
236236
statements = append(statements, ns...)
@@ -242,7 +242,7 @@ func newStatements(policy BucketPolicy, bucketName string, prefix string) (state
242242
}
243243

244244
// Returns whether given bucket statements are used by other than given prefix statements.
245-
func getInUsePolicy(statements []Statement, bucketName string, prefix string) (readOnlyInUse, writeOnlyInUse bool) {
245+
func getInUsePolicy(statements []Statement, bucketName, prefix string) (readOnlyInUse, writeOnlyInUse bool) {
246246
resourcePrefix := awsResourcePrefix + bucketName + "/"
247247
objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
248248

@@ -279,7 +279,7 @@ func removeObjectActions(statement Statement, objectResource string) Statement {
279279
}
280280

281281
// Removes bucket actions for given policy in given statement.
282-
func removeBucketActions(statement Statement, prefix string, bucketResource string, readOnlyInUse, writeOnlyInUse bool) Statement {
282+
func removeBucketActions(statement Statement, prefix, bucketResource string, readOnlyInUse, writeOnlyInUse bool) Statement {
283283
removeReadOnly := func() {
284284
if !statement.Actions.Intersection(readOnlyBucketActions).Equals(readOnlyBucketActions) {
285285
return
@@ -341,7 +341,7 @@ func removeBucketActions(statement Statement, prefix string, bucketResource stri
341341

342342
// Returns statements containing removed actions/statements for given
343343
// policy, bucket name and prefix.
344-
func removeStatements(statements []Statement, bucketName string, prefix string) []Statement {
344+
func removeStatements(statements []Statement, bucketName, prefix string) []Statement {
345345
bucketResource := awsResourcePrefix + bucketName
346346
objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
347347
readOnlyInUse, writeOnlyInUse := getInUsePolicy(statements, bucketName, prefix)
@@ -473,7 +473,7 @@ func appendStatement(statements []Statement, statement Statement) []Statement {
473473
}
474474

475475
// Appends two statement lists.
476-
func appendStatements(statements []Statement, appendStatements []Statement) []Statement {
476+
func appendStatements(statements, appendStatements []Statement) []Statement {
477477
for _, s := range appendStatements {
478478
statements = appendStatement(statements, s)
479479
}
@@ -523,7 +523,7 @@ func getBucketPolicy(statement Statement, prefix string) (commonFound, readOnly,
523523
}
524524

525525
// Returns policy of given object statement.
526-
func getObjectPolicy(statement Statement) (readOnly bool, writeOnly bool) {
526+
func getObjectPolicy(statement Statement) (readOnly, writeOnly bool) {
527527
if statement.Effect == "Allow" &&
528528
statement.Principal.AWS.Contains("*") &&
529529
statement.Conditions == nil {
@@ -539,7 +539,7 @@ func getObjectPolicy(statement Statement) (readOnly bool, writeOnly bool) {
539539
}
540540

541541
// GetPolicy - Returns policy of given bucket name, prefix in given statements.
542-
func GetPolicy(statements []Statement, bucketName string, prefix string) BucketPolicy {
542+
func GetPolicy(statements []Statement, bucketName, prefix string) BucketPolicy {
543543
bucketResource := awsResourcePrefix + bucketName
544544
objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
545545

@@ -625,7 +625,7 @@ func GetPolicies(statements []Statement, bucketName, prefix string) map[string]B
625625
}
626626

627627
// SetPolicy - Returns new statements containing policy of given bucket name and prefix are appended.
628-
func SetPolicy(statements []Statement, policy BucketPolicy, bucketName string, prefix string) []Statement {
628+
func SetPolicy(statements []Statement, policy BucketPolicy, bucketName, prefix string) []Statement {
629629
out := removeStatements(statements, bucketName, prefix)
630630
// fmt.Println("out = ")
631631
// printstatement(out)

pkg/set/stringset_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ func TestStringSetFuncMatch(t *testing.T) {
126126
expectedResult string
127127
}{
128128
// Test to check match function doing case insensive compare.
129-
{func(setValue string, compareValue string) bool {
129+
{func(setValue, compareValue string) bool {
130130
return strings.EqualFold(setValue, compareValue)
131131
}, "Bar", `[bar]`},
132132
// Test to check match function doing prefix check.
133-
{func(setValue string, compareValue string) bool {
133+
{func(setValue, compareValue string) bool {
134134
return strings.HasPrefix(compareValue, setValue)
135135
}, "foobar", `[foo]`},
136136
}

pkg/signer/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func sum256(data []byte) []byte {
3535
}
3636

3737
// sumHMAC calculate hmac between two input byte array.
38-
func sumHMAC(key []byte, data []byte) []byte {
38+
func sumHMAC(key, data []byte) []byte {
3939
hash := hmac.New(sha256.New, key)
4040
hash.Write(data)
4141
return hash.Sum(nil)

0 commit comments

Comments
 (0)