package catalog
import (
"context"
"io"
"strings"
"github.com/thanos-io/objstore"
)
type icebucket struct {
bucket objstore .Bucket
prefix string
}
func NewIcebucket (warehouseURI string , bucket objstore .Bucket ) *icebucket {
return &icebucket {
bucket : bucket ,
prefix : warehouseURI ,
}
}
func (i *icebucket ) Upload (ctx context .Context , name string , r io .Reader ) error {
return i .bucket .Upload (ctx , strings .TrimPrefix (name , i .prefix ), r )
}
func (i *icebucket ) Delete (ctx context .Context , name string ) error {
return i .bucket .Delete (ctx , strings .TrimPrefix (name , i .prefix ))
}
func (i *icebucket ) Name () string { return i .bucket .Name () }
func (i *icebucket ) Close () error { return i .bucket .Close () }
func (i *icebucket ) Iter (ctx context .Context , dir string , f func (string ) error , options ...objstore .IterOption ) error {
return i .bucket .Iter (ctx , strings .TrimPrefix (dir , i .prefix ), f , options ...)
}
func (i *icebucket ) Get (ctx context .Context , name string ) (io .ReadCloser , error ) {
return i .bucket .Get (ctx , strings .TrimPrefix (name , i .prefix ))
}
func (i *icebucket ) GetRange (ctx context .Context , name string , off , length int64 ) (io .ReadCloser , error ) {
return i .bucket .GetRange (ctx , strings .TrimPrefix (name , i .prefix ), off , length )
}
func (i *icebucket ) Exists (ctx context .Context , name string ) (bool , error ) {
return i .bucket .Exists (ctx , strings .TrimPrefix (name , i .prefix ))
}
func (i *icebucket ) IsObjNotFoundErr (err error ) bool { return i .bucket .IsObjNotFoundErr (err ) }
func (i *icebucket ) IsAccessDeniedErr (err error ) bool { return i .bucket .IsAccessDeniedErr (err ) }
func (i *icebucket ) Attributes (ctx context .Context , name string ) (objstore .ObjectAttributes , error ) {
return i .bucket .Attributes (ctx , strings .TrimPrefix (name , i .prefix ))
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .