func Tar(
	ctx context.Context,
	readBucket storage.ReadBucket,
	writer io.Writer,
) (retErr error) {
	tarWriter := tar.NewWriter(writer)
	defer func() {
		retErr = multierr.Append(retErr, tarWriter.Close())
	}()
	return storage.WalkReadObjects(
		ctx,
		readBucket,
		"",
		func(readObject storage.ReadObject) error {
			data, err := io.ReadAll(readObject)
			if err != nil {
				return err
			}
			if err := tarWriter.WriteHeader(
				&tar.Header{
					Typeflag: tar.TypeReg,
					Name:     readObject.Path(),
					Size:     int64(len(data)),
					// If we ever use this outside of testing, we will want to do something about this
					Mode: 0644,
				},
			); err != nil {
				return err
			}
			_, err = tarWriter.Write(data)
			return err
		},
	)
}
// Tar tars the given bucket to the writer.
//
// Only regular files are added to the writer.
// All files are written as 0644.
Tar tars the given bucket to the writer.

Only regular files are added to the writer.
All files are written as 0644.
// Tar tars the given bucket to the writer . // // Only regular files are added to the writer . // All files are written as 0644 .
func Tar(
	ctx context.Context,
	readBucket storage.ReadBucket,
	writer io.Writer,
) (retErr error) {
	tarWriter := tar.NewWriter(writer)
	defer func() {
		retErr = multierr.Append(retErr, tarWriter.Close())
	}()
	return storage.WalkReadObjects(
		ctx,
		readBucket,
		"",
		func(readObject storage.ReadObject) error {
			data, err := io.ReadAll(readObject)
			if err != nil {
				return err
			}
			if err := tarWriter.WriteHeader(
				&tar.Header{
					Typeflag: tar.TypeReg,
					Name:     readObject.Path(),
					Size:     int64(len(data)),
					Mode: 0644,
				},
			); err != nil {
				return err
			}
			_, err = tarWriter.Write(data)
			return err
		},
	)
}
func Tar ( ctx context . Context , readBucket storage . ReadBucket , writer io . Writer , ) ( retErr error ) { tarWriter := tar . NewWriter ( writer ) defer func ( ) { retErr = multierr . Append ( retErr , tarWriter . Close ( ) ) } ( ) return storage . WalkReadObjects ( ctx , readBucket , " " , func ( readObject storage . ReadObject ) error { data , err := io . ReadAll ( readObject ) if err != nil { return err } if err := tarWriter . WriteHeader ( & tar . Header { Typeflag : tar . TypeReg , Name : readObject . Path ( ) , Size : int64 ( len ( data ) ) , Mode : 0644 , } , ) ; err != nil { return err } _ , err = tarWriter . Write ( data ) return err } , ) }
Tar tars the given bucket to the writer.
Tar tars the given bucket to the writer .
// If we ever use this outside of testing, we will want to do something about this