Skip to content

Commit

Permalink
resolve test
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioLangaritaBenitez committed Jan 14, 2025
1 parent 8b9ce7f commit a3e5b37
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions pkg/utils/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (minIOAdminClient *MinIOAdminClient) CreateAddPolicy(bucketName string, pol

rs := "arn:aws:s3:::" + bucketName + "/*"

policyInfo, errInfo := minIOAdminClient.adminClient.InfoCannedPolicyV2(context.TODO(), policyName)
_, errInfo := minIOAdminClient.adminClient.InfoCannedPolicyV2(context.TODO(), policyName)
if errInfo != nil {
// If the policy does not exist create it
p := `{
Expand All @@ -306,20 +306,15 @@ func (minIOAdminClient *MinIOAdminClient) CreateAddPolicy(bucketName string, pol
}`
policy = []byte(p)
} else {
actualPolicy := &Policy{}
jsonErr = json.Unmarshal(policyInfo.Policy, actualPolicy)
if jsonErr != nil {
return jsonErr
}
// Add new resource and create policy
actualPolicy.Statement = []Statement{
{
Resource: []string{rs},
Action: []string{"s3:*"},
Effect: "Allow",
actualPolicy := &Policy{
Statement: []Statement{
{
Resource: []string{rs},
Action: []string{"s3:*"},
Effect: "Allow",
},
},
}

policy, jsonErr = json.Marshal(actualPolicy)
if jsonErr != nil {
return jsonErr
Expand Down Expand Up @@ -356,6 +351,7 @@ func createPolicy(adminClient *madmin.AdminClient, bucketName string, allUsers b
actualPolicy := &Policy{}
jsonErr = json.Unmarshal(policyInfo.Policy, actualPolicy)
if jsonErr != nil {
fmt.Println("here2")
return jsonErr
}
// Add new resource and create policy
Expand Down Expand Up @@ -407,6 +403,8 @@ func (minIOAdminClient *MinIOAdminClient) RemoveFromPolicy(bucketName string, po
actualPolicy := &Policy{}
jsonErr := json.Unmarshal(policyInfo.Policy, actualPolicy)
if jsonErr != nil {
fmt.Println("here3")

return jsonErr
}
if len(actualPolicy.Statement[0].Resource) == 1 {
Expand Down

0 comments on commit a3e5b37

Please sign in to comment.