Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make func newDescriptor public #6517

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions bundle/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ func (f *lazyFile) Close() error {
return nil
}

func newDescriptor(url, path string, reader io.Reader) *Descriptor {
func NewDescriptor(url, path string, reader io.Reader) *Descriptor {
return &Descriptor{
url: url,
path: path,
reader: reader,
}
}

func (d *Descriptor) withCloser(closer io.Closer) *Descriptor {
func (d *Descriptor) WithCloser(closer io.Closer) *Descriptor {
d.closer = closer
d.closeOnce = new(sync.Once)
return d
Expand Down Expand Up @@ -230,7 +230,7 @@ func (d *dirLoader) NextFile() (*Descriptor, error) {
fh := newLazyFile(fileName)

cleanedPath := formatPath(fileName, d.root, d.pathFormat)
f := newDescriptor(filepath.Join(d.root, cleanedPath), cleanedPath, fh).withCloser(fh)
f := NewDescriptor(filepath.Join(d.root, cleanedPath), cleanedPath, fh).WithCloser(fh)
return f, nil
}

Expand Down Expand Up @@ -372,16 +372,14 @@ func (t *tarballLoader) NextFile() (*Descriptor, error) {
t.idx++

cleanedPath := formatPath(f.name, "", t.pathFormat)
d := newDescriptor(filepath.Join(t.baseURL, cleanedPath), cleanedPath, f.reader)
d := NewDescriptor(filepath.Join(t.baseURL, cleanedPath), cleanedPath, f.reader)
return d, nil

}

// Next implements the storage.Iterator interface.
// It iterates to the next policy or data file in the directory tree
// and returns a storage.Update for the file.
func (it *iterator) Next() (*storage.Update, error) {

if it.files == nil {
it.files = []file{}

Expand Down
2 changes: 1 addition & 1 deletion bundle/filefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ func (d *dirLoaderFS) NextFile() (*Descriptor, error) {
}

cleanedPath := formatPath(fileName, d.root, d.pathFormat)
f := newDescriptor(cleanedPath, cleanedPath, fh).withCloser(fh)
f := NewDescriptor(cleanedPath, cleanedPath, fh).WithCloser(fh)
return f, nil
}