Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature to introduce BucketPolicy #233

Merged
merged 13 commits into from
May 21, 2024
6 changes: 6 additions & 0 deletions apis/provider-ceph/v1alpha1/bucket_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ type BucketParameters struct {
// AssumeRoleTags may be used to add custom values to an AssumeRole request.
// +optional
AssumeRoleTags []Tag `json:"assumeRoleTags,omitempty"`

// BucketPolicy is a JSON string of BucketPolicy.
// If it is set, Provider-Ceph calls PutBucketPolicy API after creating the bucket.
// Before adding it, you should validate the JSON string.
// +optional
BucketPolicy string `json:"bucketPolicy,omitempty"`
}

// BackendInfo contains relevant information about an S3 backend for
Expand Down
3 changes: 3 additions & 0 deletions internal/backendstore/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type S3Client interface {
DeleteBucketLifecycle(context.Context, *s3.DeleteBucketLifecycleInput, ...func(*s3.Options)) (*s3.DeleteBucketLifecycleOutput, error)
GetBucketAcl(context.Context, *s3.GetBucketAclInput, ...func(*s3.Options)) (*s3.GetBucketAclOutput, error)
PutBucketAcl(context.Context, *s3.PutBucketAclInput, ...func(*s3.Options)) (*s3.PutBucketAclOutput, error)
PutBucketPolicy(context.Context, *s3.PutBucketPolicyInput, ...func(*s3.Options)) (*s3.PutBucketPolicyOutput, error)
GetBucketPolicy(context.Context, *s3.GetBucketPolicyInput, ...func(*s3.Options)) (*s3.GetBucketPolicyOutput, error)
DeleteBucketPolicy(context.Context, *s3.DeleteBucketPolicyInput, ...func(*s3.Options)) (*s3.DeleteBucketPolicyOutput, error)
}

//counterfeiter:generate . STSClient
Expand Down
249 changes: 249 additions & 0 deletions internal/backendstore/backendstorefakes/fake_s3client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/controller/bucket/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ const (
errObserveAcl = "failed to observe bucket acl"
errHandleAcl = "failed to handle bucket acl"

// BucketPolicy error messages.
errObservePolicy = "failed to observe bucket policy"
errHandlePolicy = "failed to handle bucket policy"

True = "true"
)
1 change: 1 addition & 0 deletions internal/controller/bucket/lifecycleconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func NewLifecycleConfigurationClient(b *backendstore.BackendStore, h *s3clientha
return &LifecycleConfigurationClient{backendStore: b, s3ClientHandler: h, log: l}
}

//nolint:dupl // LifecycleConfiguration and BucketPolicy are different feature.
func (l *LifecycleConfigurationClient) Observe(ctx context.Context, bucket *v1alpha1.Bucket, backendNames []string) (ResourceStatus, error) {
ctx, span := otel.Tracer("").Start(ctx, "bucket.LifecycleConfigurationClient.Observe")
defer span.End()
Expand Down
Loading
Loading