From 174b0124d1a76b94936e65805b048a772208cc18 Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Tue, 5 Sep 2023 18:24:33 -0700 Subject: [PATCH 1/2] Implementing ToErrorResponse method Signed-off-by: Alan Protasio --- providers/s3/s3.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/providers/s3/s3.go b/providers/s3/s3.go index f92d3973..29a59945 100644 --- a/providers/s3/s3.go +++ b/providers/s3/s3.go @@ -638,3 +638,37 @@ func NewTestBucketFromConfig(t testing.TB, location string, c Config, reuseBucke func ContextWithSSEConfig(ctx context.Context, value encrypt.ServerSide) context.Context { return context.WithValue(ctx, sseConfigKey, value) } + +/* **** SAMPLE ERROR RESPONSE **** + + + AccessDenied + Access Denied + bucketName + objectName + F19772218238A85A + GuWkjyviSiGHizehqpmsD1ndz5NClSP19DOT+s2mv7gXGQ8/X1lhbDGiIJEXpGFD + +*/ + +type ErrorResponse struct { + Code string + Message string + BucketName string + Key string + RequestId string + HostId string +} + +// ToErrorResponse Returns parsed s3 ErrorResponse +func ToErrorResponse(err error) ErrorResponse { + er := minio.ToErrorResponse(errors.Cause(err)) + return ErrorResponse{ + Code: er.Code, + Message: er.Message, + BucketName: er.BucketName, + Key: er.Key, + RequestId: er.RequestID, + HostId: er.HostID, + } +} From 8ebeaeb708081bfdd4b157a6a72a3a9af3f4403f Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Tue, 5 Sep 2023 18:28:58 -0700 Subject: [PATCH 2/2] changelog Signed-off-by: Alan Protasio --- CHANGELOG.md | 3 +++ providers/s3/s3.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32d0f742..4d64c3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re ## Unreleased +### Added +- [#74](https://github.com/thanos-io/objstore/pull/74) S3: Implementing `ToErrorResponse` function to return the parsed S3 ErrorResponse. + ### Fixed - [#33](https://github.com/thanos-io/objstore/pull/33) Tracing: Add `ContextWithTracer()` to inject the tracer into the context. - [#34](https://github.com/thanos-io/objstore/pull/34) Fix ignored options when creating shared credential Azure client. diff --git a/providers/s3/s3.go b/providers/s3/s3.go index 29a59945..515cc631 100644 --- a/providers/s3/s3.go +++ b/providers/s3/s3.go @@ -660,7 +660,7 @@ type ErrorResponse struct { HostId string } -// ToErrorResponse Returns parsed s3 ErrorResponse +// ToErrorResponse Returns parsed s3 ErrorResponse. func ToErrorResponse(err error) ErrorResponse { er := minio.ToErrorResponse(errors.Cause(err)) return ErrorResponse{