diff --git a/pkg/handlers/create.go b/pkg/handlers/create.go index 3ed9b274..7458a7d2 100644 --- a/pkg/handlers/create.go +++ b/pkg/handlers/create.go @@ -373,7 +373,10 @@ func createBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * } if !isAdminUser { - minIOAdminClient.CreateAddPolicy(b, service.AllowedUsers[i], false) + err = minIOAdminClient.CreateAddPolicy(b, service.AllowedUsers[i], false) + if err != nil { + return err + } } } } diff --git a/pkg/handlers/delete.go b/pkg/handlers/delete.go index 102bab39..f9272ba6 100644 --- a/pkg/handlers/delete.go +++ b/pkg/handlers/delete.go @@ -178,7 +178,10 @@ func deleteBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * // Delete user's buckets if isolated spaces had been created if strings.ToUpper(service.IsolationLevel) == "USER" && len(service.BucketList) > 0 { // Delete all private buckets - deletePrivateBuckets(service, minIOAdminClient, s3Client) + err = deletePrivateBuckets(service, minIOAdminClient, s3Client) + if err != nil { + return fmt.Errorf("error while disable the input notification") + } } } @@ -195,7 +198,10 @@ func deleteBuckets(service *types.Service, cfg *types.Config, minIOAdminClient * // Check if the provider identifier is defined in StorageProviders if !isStorageProviderDefined(provName, provID, service.StorageProviders) { // TODO fix - disableInputNotifications(s3Client, service.GetMinIOWebhookARN(), "") + err := disableInputNotifications(s3Client, service.GetMinIOWebhookARN(), "") + if err != nil { + return fmt.Errorf("error while disable the input notification") + } return fmt.Errorf("the StorageProvider \"%s.%s\" is not defined", provName, provID) } diff --git a/pkg/handlers/update.go b/pkg/handlers/update.go index ffdb1eff..3a0edef7 100644 --- a/pkg/handlers/update.go +++ b/pkg/handlers/update.go @@ -129,8 +129,10 @@ func MakeUpdateHandler(cfg *types.Config, back types.ServerlessBackend) gin.Hand return } - disableInputNotifications(s3Client, oldService.GetMinIOWebhookARN(), splitPath[0]) - + err = disableInputNotifications(s3Client, oldService.GetMinIOWebhookARN(), splitPath[0]) + if err != nil { + return + } // Register minio webhook and restart the server if err := registerMinIOWebhook(newService.Name, newService.Token, newService.StorageProviders.MinIO[types.DefaultProvider], cfg); err != nil { uerr := back.UpdateService(*oldService) diff --git a/pkg/utils/minio.go b/pkg/utils/minio.go index 33eff21c..fa5a261e 100644 --- a/pkg/utils/minio.go +++ b/pkg/utils/minio.go @@ -307,8 +307,10 @@ func (minIOAdminClient *MinIOAdminClient) CreateAddPolicy(bucketName string, pol policy = []byte(p) } else { actualPolicy := &Policy{} - json.Unmarshal(policyInfo.Policy, actualPolicy) - + err := json.Unmarshal(policyInfo.Policy, actualPolicy) + if err != nil { + return fmt.Errorf("error unmarshal, the policy is not in correct format") + } // Add new resource and create policy actualPolicy.Statement = []Statement{ { @@ -402,7 +404,10 @@ func (minIOAdminClient *MinIOAdminClient) RemoveFromPolicy(bucketName string, po return fmt.Errorf("policy '%s' does not exist: %v", policyName, errInfo) } actualPolicy := &Policy{} - json.Unmarshal(policyInfo.Policy, actualPolicy) + err := json.Unmarshal(policyInfo.Policy, actualPolicy) + if err != nil { + return fmt.Errorf("error unmarshal, the policy is not in correct format") + } if len(actualPolicy.Statement[0].Resource) == 1 { if err := minIOAdminClient.adminClient.RemoveCannedPolicy(context.TODO(), policyName); err != nil { return fmt.Errorf("error removing canned policy: %v", err) @@ -422,7 +427,7 @@ func (minIOAdminClient *MinIOAdminClient) RemoveFromPolicy(bucketName string, po return jsonErr } - err := minIOAdminClient.adminClient.AddCannedPolicy(context.TODO(), policyName, []byte(policy)) + err = minIOAdminClient.adminClient.AddCannedPolicy(context.TODO(), policyName, []byte(policy)) if err != nil { return fmt.Errorf("error creating MinIO policy for user %s: %v", policyName, err) }