Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetkovski committed Oct 29, 2024
1 parent 13f53fa commit eed779e
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (b *InMemBucket) Objects() map[string][]byte {

// Iter calls f for each entry in the given directory. The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *InMemBucket) Iter(ctx context.Context, dir string, f func(name string, attrs ObjectAttributes) error, options ...IterOption) error {
func (b *InMemBucket) Iter(ctx context.Context, dir string, f func(attrs ObjectAttributes) error, options ...IterOption) error {
unique := map[string]struct{}{}
params := ApplyIterOptions(options...)

Expand Down
13 changes: 8 additions & 5 deletions objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type BucketReader interface {
// returned by the underlying provider. Attributes can be requested using various IterOption's.
//
// Entries are passed to function in sorted order.
Iter(ctx context.Context, dir string, f func(name string, attrs ObjectAttributes) error, options ...IterOption) error
Iter(ctx context.Context, dir string, f func(attrs ObjectAttributes) error, options ...IterOption) error

// Get returns a reader for the given object name.
Get(ctx context.Context, name string) (io.ReadCloser, error)
Expand Down Expand Up @@ -194,6 +194,9 @@ func applyUploadOptions(options ...UploadOption) uploadParams {
}

type ObjectAttributes struct {
// Name is the object name.
Name string `json:"name"`

// Size is the object size in bytes.
Size int64 `json:"size"`

Expand Down Expand Up @@ -359,10 +362,10 @@ func DownloadDir(ctx context.Context, logger log.Logger, bkt BucketReader, origi
var downloadedFiles []string
var m sync.Mutex

err := bkt.Iter(ctx, src, func(name string, _ ObjectAttributes) error {
err := bkt.Iter(ctx, src, func(attrs ObjectAttributes) error {
g.Go(func() error {
dst := filepath.Join(dst, filepath.Base(name))
if strings.HasSuffix(name, DirDelim) {
dst := filepath.Join(dst, filepath.Base(attrs.Name))
if strings.HasSuffix(attrs.Name, DirDelim) {
if err := DownloadDir(ctx, logger, bkt, originalSrc, name, dst, options...); err != nil {

Check failure on line 369 in objstore.go

View workflow job for this annotation

GitHub Actions / Run tests

undefined: name

Check failure on line 369 in objstore.go

View workflow job for this annotation

GitHub Actions / Documentation check

undefined: name

Check failure on line 369 in objstore.go

View workflow job for this annotation

GitHub Actions / Linters (Static Analysis) for Go

undefined: name
return err
}
Expand Down Expand Up @@ -543,7 +546,7 @@ func (b *metricBucket) ReaderWithExpectedErrs(fn IsOpFailureExpectedFunc) Bucket
return b.WithExpectedErrs(fn)
}

func (b *metricBucket) Iter(ctx context.Context, dir string, f func(name string, _ ObjectAttributes) error, options ...IterOption) error {
func (b *metricBucket) Iter(ctx context.Context, dir string, f func(attrs ObjectAttributes) error, options ...IterOption) error {
const op = OpIter
b.metrics.ops.WithLabelValues(op).Inc()

Expand Down
2 changes: 1 addition & 1 deletion prefixed_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (p *PrefixedBucket) Close() error {
// Iter calls f for each entry in the given directory (not recursive.). The argument to f is the full
// object name including the prefix of the inspected directory.
// Entries are passed to function in sorted order.
func (p *PrefixedBucket) Iter(ctx context.Context, dir string, f func(name string, attrs ObjectAttributes) error, options ...IterOption) error {
func (p *PrefixedBucket) Iter(ctx context.Context, dir string, f func(attrs ObjectAttributes) error, options ...IterOption) error {
pdir := withPrefix(p.prefix, dir)

return p.bkt.Iter(ctx, pdir, func(s string, _ ObjectAttributes) error {

Check failure on line 52 in prefixed_bucket.go

View workflow job for this annotation

GitHub Actions / Run tests

cannot use func(s string, _ ObjectAttributes) error {…} (value of type func(s string, _ ObjectAttributes) error) as func(attrs ObjectAttributes) error value in argument to p.bkt.Iter

Check failure on line 52 in prefixed_bucket.go

View workflow job for this annotation

GitHub Actions / Documentation check

cannot use func(s string, _ ObjectAttributes) error {…} (value of type func(s string, _ ObjectAttributes) error) as func(attrs ObjectAttributes) error value in argument to p.bkt.Iter

Check failure on line 52 in prefixed_bucket.go

View workflow job for this annotation

GitHub Actions / Linters (Static Analysis) for Go

cannot use func(s string, _ ObjectAttributes) error {…} (value of type func(s string, _ ObjectAttributes) error) as func(attrs ObjectAttributes) error value in argument to p.bkt.Iter
Expand Down
2 changes: 1 addition & 1 deletion providers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func NewBucketWithConfig(logger log.Logger, conf Config, component string, wrapR

// Iter calls f for each entry in the given directory. The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
prefix := dir
if prefix != "" && !strings.HasSuffix(prefix, DirDelim) {
prefix += DirDelim
Expand Down
2 changes: 1 addition & 1 deletion providers/bos/bos.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (b *Bucket) Upload(_ context.Context, name string, r io.Reader) error {

// Iter calls f for each entry in the given directory (not recursive). The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, opt ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
if dir != "" {
dir = strings.TrimSuffix(dir, objstore.DirDelim) + objstore.DirDelim
}
Expand Down
2 changes: 1 addition & 1 deletion providers/cos/cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (b *Bucket) Delete(ctx context.Context, name string) error {

// Iter calls f for each entry in the given directory (not recursive.). The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
if dir != "" {
dir = strings.TrimSuffix(dir, dirDelim) + dirDelim
}
Expand Down
2 changes: 1 addition & 1 deletion providers/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewBucket(rootDir string) (*Bucket, error) {

// Iter calls f for each entry in the given directory. The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
if ctx.Err() != nil {
return ctx.Err()
}
Expand Down
2 changes: 1 addition & 1 deletion providers/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (b *Bucket) Name() string {

// Iter calls f for each entry in the given directory. The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
// Ensure the object name actually ends with a dir suffix. Otherwise we'll just iterate the
// object itself as one prefix item.
if dir != "" {
Expand Down
2 changes: 1 addition & 1 deletion providers/obs/obs.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (b *Bucket) multipartUpload(size int64, key, uploadId string, body io.Reade
func (b *Bucket) Close() error { return nil }

// Iter calls f for each entry in the given directory (not recursive.)
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
if dir != "" {
dir = strings.TrimSuffix(dir, DirDelim) + DirDelim
}
Expand Down
2 changes: 1 addition & 1 deletion providers/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (b *Bucket) Name() string {

// Iter calls f for each entry in the given directory (not recursive). The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
// Ensure the object name actually ends with a dir suffix. Otherwise we'll just iterate the
// object itself as one prefix item.
if dir != "" {
Expand Down
2 changes: 1 addition & 1 deletion providers/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func validate(config Config) error {

// Iter calls f for each entry in the given directory (not recursive). The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
if dir != "" {
dir = strings.TrimSuffix(dir, objstore.DirDelim) + objstore.DirDelim
}
Expand Down
2 changes: 1 addition & 1 deletion providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func ValidateForTests(conf Config) error {

// Iter calls f for each entry in the given directory. The argument to f is the full
// object name including the prefix of the inspected directory.
func (b *Bucket) Iter(ctx context.Context, dir string, f func(name string, attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (b *Bucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
// Ensure the object name actually ends with a dir suffix. Otherwise we'll just iterate the
// object itself as one prefix item.
if dir != "" {
Expand Down
2 changes: 1 addition & 1 deletion providers/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (c *Container) Name() string {

// Iter calls f for each entry in the given directory. The argument to f is the full
// object name including the prefix of the inspected directory.
func (c *Container) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
func (c *Container) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) error {
if dir != "" {
dir = strings.TrimSuffix(dir, string(DirDelim)) + string(DirDelim)
}
Expand Down
2 changes: 1 addition & 1 deletion testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (d *delayingBucket) Attributes(ctx context.Context, name string) (ObjectAtt
return d.bkt.Attributes(ctx, name)
}

func (d *delayingBucket) Iter(ctx context.Context, dir string, f func(name string, attrs ObjectAttributes) error, options ...IterOption) error {
func (d *delayingBucket) Iter(ctx context.Context, dir string, f func(attrs ObjectAttributes) error, options ...IterOption) error {
time.Sleep(d.delay)
return d.bkt.Iter(ctx, dir, f, options...)
}
Expand Down
2 changes: 1 addition & 1 deletion tracing/opentelemetry/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func WrapWithTraces(bkt objstore.Bucket, tracer trace.Tracer) objstore.Instrumen
return TracingBucket{tracer: tracer, bkt: bkt}
}

func (t TracingBucket) Iter(ctx context.Context, dir string, f func(name string, attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) (err error) {
func (t TracingBucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) (err error) {
ctx, span := t.tracer.Start(ctx, "bucket_iter")
defer span.End()
span.SetAttributes(attribute.String("dir", dir))
Expand Down
2 changes: 1 addition & 1 deletion tracing/opentracing/opentracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func WrapWithTraces(bkt objstore.Bucket) objstore.InstrumentedBucket {
return TracingBucket{bkt: bkt}
}

func (t TracingBucket) Iter(ctx context.Context, dir string, f func(name string, _ objstore.ObjectAttributes) error, options ...objstore.IterOption) (err error) {
func (t TracingBucket) Iter(ctx context.Context, dir string, f func(attrs objstore.ObjectAttributes) error, options ...objstore.IterOption) (err error) {
doWithSpan(ctx, "bucket_iter", func(spanCtx context.Context, span opentracing.Span) {
span.LogKV("dir", dir)
err = t.bkt.Iter(spanCtx, dir, f, options...)
Expand Down

0 comments on commit eed779e

Please sign in to comment.