From c3ff20dc9ac7a77dd1fb555e168ab98ce5962e51 Mon Sep 17 00:00:00 2001 From: Ayushi Sharma Date: Fri, 6 Dec 2024 14:05:01 +0530 Subject: [PATCH] fix(oss): delete bucket policy if there's no more statements left after revoke --- plugins/providers/oss/provider.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/providers/oss/provider.go b/plugins/providers/oss/provider.go index cbe253bd..61bc4f21 100644 --- a/plugins/providers/oss/provider.go +++ b/plugins/providers/oss/provider.go @@ -196,19 +196,19 @@ func (p *provider) RevokeAccess(ctx context.Context, pc *domain.ProviderConfig, return err } - err = client.SetBucketPolicy(g.Resource.URN, updatedPolicy) - if err != nil { - return fmt.Errorf("failed to set bucket policy: %w", err) - } - if updatedPolicy == "" { - err := client.DeleteBucketPolicy(g.Resource.URN) + err = client.DeleteBucketPolicy(g.Resource.URN) if err != nil { return fmt.Errorf("failed to delete bucket policy: %w", err) } return nil } + err = client.SetBucketPolicy(g.Resource.URN, updatedPolicy) + if err != nil { + return fmt.Errorf("failed to set bucket policy: %w", err) + } + return nil }