@@ -74,7 +74,7 @@ var validActions = commonBucketActions.
74
74
Union (readOnlyObjectActions ).
75
75
Union (writeOnlyObjectActions )
76
76
77
- var startsWithFunc = func (resource string , resourcePrefix string ) bool {
77
+ var startsWithFunc = func (resource , resourcePrefix string ) bool {
78
78
return strings .HasPrefix (resource , resourcePrefix )
79
79
}
80
80
@@ -154,7 +154,7 @@ func isValidStatement(statement Statement, bucketName string) bool {
154
154
}
155
155
156
156
// 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 ) {
158
158
statements = []Statement {}
159
159
if policy == BucketPolicyNone || bucketName == "" {
160
160
return statements
@@ -204,7 +204,7 @@ func newBucketStatement(policy BucketPolicy, bucketName string, prefix string) (
204
204
}
205
205
206
206
// 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 ) {
208
208
statements = []Statement {}
209
209
if policy == BucketPolicyNone || bucketName == "" {
210
210
return statements
@@ -230,7 +230,7 @@ func newObjectStatement(policy BucketPolicy, bucketName string, prefix string) (
230
230
}
231
231
232
232
// 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 ) {
234
234
statements = []Statement {}
235
235
ns := newBucketStatement (policy , bucketName , prefix )
236
236
statements = append (statements , ns ... )
@@ -242,7 +242,7 @@ func newStatements(policy BucketPolicy, bucketName string, prefix string) (state
242
242
}
243
243
244
244
// 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 ) {
246
246
resourcePrefix := awsResourcePrefix + bucketName + "/"
247
247
objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
248
248
@@ -279,7 +279,7 @@ func removeObjectActions(statement Statement, objectResource string) Statement {
279
279
}
280
280
281
281
// 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 {
283
283
removeReadOnly := func () {
284
284
if ! statement .Actions .Intersection (readOnlyBucketActions ).Equals (readOnlyBucketActions ) {
285
285
return
@@ -341,7 +341,7 @@ func removeBucketActions(statement Statement, prefix string, bucketResource stri
341
341
342
342
// Returns statements containing removed actions/statements for given
343
343
// policy, bucket name and prefix.
344
- func removeStatements (statements []Statement , bucketName string , prefix string ) []Statement {
344
+ func removeStatements (statements []Statement , bucketName , prefix string ) []Statement {
345
345
bucketResource := awsResourcePrefix + bucketName
346
346
objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
347
347
readOnlyInUse , writeOnlyInUse := getInUsePolicy (statements , bucketName , prefix )
@@ -473,7 +473,7 @@ func appendStatement(statements []Statement, statement Statement) []Statement {
473
473
}
474
474
475
475
// Appends two statement lists.
476
- func appendStatements (statements [] Statement , appendStatements []Statement ) []Statement {
476
+ func appendStatements (statements , appendStatements []Statement ) []Statement {
477
477
for _ , s := range appendStatements {
478
478
statements = appendStatement (statements , s )
479
479
}
@@ -523,7 +523,7 @@ func getBucketPolicy(statement Statement, prefix string) (commonFound, readOnly,
523
523
}
524
524
525
525
// Returns policy of given object statement.
526
- func getObjectPolicy (statement Statement ) (readOnly bool , writeOnly bool ) {
526
+ func getObjectPolicy (statement Statement ) (readOnly , writeOnly bool ) {
527
527
if statement .Effect == "Allow" &&
528
528
statement .Principal .AWS .Contains ("*" ) &&
529
529
statement .Conditions == nil {
@@ -539,7 +539,7 @@ func getObjectPolicy(statement Statement) (readOnly bool, writeOnly bool) {
539
539
}
540
540
541
541
// 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 {
543
543
bucketResource := awsResourcePrefix + bucketName
544
544
objectResource := awsResourcePrefix + bucketName + "/" + prefix + "*"
545
545
@@ -625,7 +625,7 @@ func GetPolicies(statements []Statement, bucketName, prefix string) map[string]B
625
625
}
626
626
627
627
// 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 {
629
629
out := removeStatements (statements , bucketName , prefix )
630
630
// fmt.Println("out = ")
631
631
// printstatement(out)
0 commit comments