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 f92d3973..515cc631 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, + } +}