fileresolver

package
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkipPath = errors.New("skip path")

Functions

func NewExcludingDecorator added in v0.85.0

func NewExcludingDecorator(delegate file.Resolver, excludeFn excludeFn) file.Resolver

NewExcludingDecorator create a new resolver which wraps the provided delegate and excludes entries based on a provided path exclusion function

func NewFromRootedUnindexedDirectory

func NewFromRootedUnindexedDirectory(dir string, base string) file.WritableResolver

func NewFromUnindexedDirectory

func NewFromUnindexedDirectory(dir string) file.WritableResolver

func NewFromUnindexedDirectoryFS

func NewFromUnindexedDirectoryFS(fs afero.Fs, dir string, base string) file.WritableResolver

func NormalizeBaseDirectory added in v0.85.0

func NormalizeBaseDirectory(base string) (string, error)

func NormalizeRootDirectory added in v0.85.0

func NormalizeRootDirectory(root string) (string, error)

Types

type ChrootContext added in v0.85.0

type ChrootContext struct {
	// contains filtered or unexported fields
}

ChrootContext helps to modify path from a real filesystem to a chroot-like filesystem, taking into account the user given root, the base path (if any) to consider as the root, and the current working directory. Note: this only works on a real filesystem, not on a virtual filesystem (such as a stereoscope filetree).

func NewChrootContext added in v0.85.0

func NewChrootContext(root, base, cwd string) (*ChrootContext, error)

func NewChrootContextFromCWD added in v0.85.0

func NewChrootContextFromCWD(root, base string) (*ChrootContext, error)

func (ChrootContext) Base added in v0.85.0

func (r ChrootContext) Base() string

Base returns the absolute base path with all symlinks evaluated.

func (*ChrootContext) ChangeDirectory added in v0.85.0

func (r *ChrootContext) ChangeDirectory(dir string) error

ChangeDirectory changes the current working directory so that any relative paths passed into ToNativePath() and ToChrootPath() honor the new CWD. If the process changes the CWD in-flight, this should be called again to ensure correct functionality of ToNativePath() and ToChrootPath().

func (*ChrootContext) ChangeRoot added in v0.85.0

func (r *ChrootContext) ChangeRoot(dir string) error

ChangeRoot swaps the path for the chroot.

func (ChrootContext) Root added in v0.85.0

func (r ChrootContext) Root() string

Root returns the root path with all symlinks evaluated.

func (ChrootContext) ToChrootPath added in v0.85.0

func (r ChrootContext) ToChrootPath(nativePath string) string

ToChrootPath takes a path from the underlying fs domain and converts it to a path that is relative to the current root context.

func (ChrootContext) ToNativeGlob added in v1.13.0

func (r ChrootContext) ToNativeGlob(chrootPath string) (string, error)

func (ChrootContext) ToNativePath added in v0.85.0

func (r ChrootContext) ToNativePath(chrootPath string) (string, error)

ToNativePath takes a path in the context of the chroot-like filesystem and converts it to a path in the underlying fs domain.

type ContainerImageAllLayers

type ContainerImageAllLayers struct {
	// contains filtered or unexported fields
}

ContainerImageAllLayers implements path and content access for the AllLayers source option for container image data sources.

func NewFromContainerImageAllLayers

func NewFromContainerImageAllLayers(img *image.Image) (*ContainerImageAllLayers, error)

NewFromContainerImageAllLayers returns a new resolver from the perspective of all image layers for the given image.

func (*ContainerImageAllLayers) AllLocations

func (r *ContainerImageAllLayers) AllLocations(ctx context.Context) <-chan file.Location

func (*ContainerImageAllLayers) FileContentsByLocation

func (r *ContainerImageAllLayers) FileContentsByLocation(location file.Location) (io.ReadCloser, error)

FileContentsByLocation fetches file contents for a single file reference, irregardless of the source layer. If the path does not exist an error is returned.

func (*ContainerImageAllLayers) FileMetadataByLocation

func (r *ContainerImageAllLayers) FileMetadataByLocation(location file.Location) (file.Metadata, error)

func (*ContainerImageAllLayers) FilesByGlob

func (r *ContainerImageAllLayers) FilesByGlob(patterns ...string) ([]file.Location, error)

FilesByGlob returns all file.References that match the given path glob pattern from any layer in the image.

func (*ContainerImageAllLayers) FilesByMIMEType

func (r *ContainerImageAllLayers) FilesByMIMEType(types ...string) ([]file.Location, error)

func (*ContainerImageAllLayers) FilesByPath

func (r *ContainerImageAllLayers) FilesByPath(paths ...string) ([]file.Location, error)

FilesByPath returns all file.References that match the given paths from any layer in the image.

func (*ContainerImageAllLayers) HasPath

func (r *ContainerImageAllLayers) HasPath(path string) bool

HasPath indicates if the given path exists in the underlying source.

func (*ContainerImageAllLayers) RelativeFileByPath

func (r *ContainerImageAllLayers) RelativeFileByPath(location file.Location, path string) *file.Location

RelativeFileByPath fetches a single file at the given path relative to the layer squash of the given reference. This is helpful when attempting to find a file that is in the same layer or lower as another file.

type ContainerImageSquash

type ContainerImageSquash struct {
	// contains filtered or unexported fields
}

ContainerImageSquash implements path and content access for the Squashed source option for container image data sources.

func NewFromContainerImageSquash

func NewFromContainerImageSquash(img *image.Image) (*ContainerImageSquash, error)

NewFromContainerImageSquash returns a new resolver from the perspective of the squashed representation for the given image.

func (*ContainerImageSquash) AllLocations

func (r *ContainerImageSquash) AllLocations(ctx context.Context) <-chan file.Location

func (*ContainerImageSquash) FileContentsByLocation

func (r *ContainerImageSquash) FileContentsByLocation(location file.Location) (io.ReadCloser, error)

FileContentsByLocation fetches file contents for a single file reference, regardless of the source layer. If the path does not exist an error is returned.

func (*ContainerImageSquash) FileMetadataByLocation

func (r *ContainerImageSquash) FileMetadataByLocation(location file.Location) (file.Metadata, error)

func (*ContainerImageSquash) FilesByGlob

func (r *ContainerImageSquash) FilesByGlob(patterns ...string) ([]file.Location, error)

FilesByGlob returns all file.References that match the given path glob pattern within the squashed representation of the image.

func (*ContainerImageSquash) FilesByMIMEType

func (r *ContainerImageSquash) FilesByMIMEType(types ...string) ([]file.Location, error)

func (*ContainerImageSquash) FilesByPath

func (r *ContainerImageSquash) FilesByPath(paths ...string) ([]file.Location, error)

FilesByPath returns all file.References that match the given paths within the squashed representation of the image.

func (*ContainerImageSquash) HasPath

func (r *ContainerImageSquash) HasPath(path string) bool

HasPath indicates if the given path exists in the underlying source.

func (*ContainerImageSquash) RelativeFileByPath

func (r *ContainerImageSquash) RelativeFileByPath(_ file.Location, path string) *file.Location

RelativeFileByPath fetches a single file at the given path relative to the layer squash of the given reference. This is helpful when attempting to find a file that is in the same layer or lower as another file. For the ContainerImageSquash, this is a simple path lookup.

type Deferred

type Deferred struct {
	// contains filtered or unexported fields
}

func NewDeferred

func NewDeferred(creator func() (file.Resolver, error)) *Deferred

func (*Deferred) AllLocations

func (d *Deferred) AllLocations(ctx context.Context) <-chan file.Location

func (*Deferred) FileContentsByLocation

func (d *Deferred) FileContentsByLocation(location file.Location) (io.ReadCloser, error)

func (*Deferred) FileMetadataByLocation

func (d *Deferred) FileMetadataByLocation(location file.Location) (file.Metadata, error)

func (*Deferred) FilesByGlob

func (d *Deferred) FilesByGlob(patterns ...string) ([]file.Location, error)

func (*Deferred) FilesByMIMEType

func (d *Deferred) FilesByMIMEType(types ...string) ([]file.Location, error)

func (*Deferred) FilesByPath

func (d *Deferred) FilesByPath(paths ...string) ([]file.Location, error)

func (*Deferred) HasPath

func (d *Deferred) HasPath(s string) bool

func (*Deferred) RelativeFileByPath

func (d *Deferred) RelativeFileByPath(location file.Location, path string) *file.Location

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

Directory implements path and content access for the directory data source.

func NewFromDirectory

func NewFromDirectory(root string, base string, pathFilters ...PathIndexVisitor) (*Directory, error)

func (*Directory) AllLocations

func (r *Directory) AllLocations(ctx context.Context) <-chan file.Location

func (Directory) FileContentsByLocation

func (r Directory) FileContentsByLocation(location file.Location) (io.ReadCloser, error)

FileContentsByLocation fetches file contents for a single file reference relative to a directory. If the path does not exist an error is returned.

func (*Directory) FileMetadataByLocation

func (r *Directory) FileMetadataByLocation(location file.Location) (file.Metadata, error)

func (Directory) FilesByGlob

func (r Directory) FilesByGlob(patterns ...string) ([]file.Location, error)

FilesByGlob returns all file.References that match the given path glob pattern from any layer in the image.

func (*Directory) FilesByMIMEType

func (r *Directory) FilesByMIMEType(types ...string) ([]file.Location, error)

func (Directory) FilesByPath

func (r Directory) FilesByPath(userPaths ...string) ([]file.Location, error)

FilesByPath returns all file.References that match the given paths from the directory.

func (*Directory) HasPath

func (r *Directory) HasPath(userPath string) bool

HasPath indicates if the given path exists in the underlying source.

func (*Directory) RelativeFileByPath

func (r *Directory) RelativeFileByPath(_ file.Location, path string) *file.Location

RelativeFileByPath fetches a single file at the given path relative to the layer squash of the given reference. This is helpful when attempting to find a file that is in the same layer or lower as another file. For the Directory, this is a simple path lookup.

func (Directory) String

func (r Directory) String() string

Stringer to represent a directory path data source

type Empty

type Empty struct{}

func (Empty) AllLocations

func (e Empty) AllLocations(_ context.Context) <-chan file.Location

func (Empty) FileContentsByLocation

func (e Empty) FileContentsByLocation(_ file.Location) (io.ReadCloser, error)

func (Empty) FileMetadataByLocation

func (e Empty) FileMetadataByLocation(_ file.Location) (file.Metadata, error)

func (Empty) FilesByGlob

func (e Empty) FilesByGlob(_ ...string) ([]file.Location, error)

func (Empty) FilesByMIMEType

func (e Empty) FilesByMIMEType(_ ...string) ([]file.Location, error)

func (Empty) FilesByPath

func (e Empty) FilesByPath(_ ...string) ([]file.Location, error)

func (Empty) HasPath

func (e Empty) HasPath(_ string) bool

func (Empty) RelativeFileByPath

func (e Empty) RelativeFileByPath(_ file.Location, _ string) *file.Location

func (Empty) Write

func (e Empty) Write(_ file.Location, _ io.Reader) error

type PathIndexVisitor

type PathIndexVisitor func(string, string, os.FileInfo, error) error

type UnindexedDirectory

type UnindexedDirectory struct {
	// contains filtered or unexported fields
}

func (UnindexedDirectory) AllLocations

func (u UnindexedDirectory) AllLocations(ctx context.Context) <-chan file.Location

- NO symlink resolution should be performed on results - returns locations for any file or directory

func (UnindexedDirectory) FileContentsByLocation

func (u UnindexedDirectory) FileContentsByLocation(location file.Location) (io.ReadCloser, error)

func (UnindexedDirectory) FileMetadataByLocation

func (u UnindexedDirectory) FileMetadataByLocation(_ file.Location) (file.Metadata, error)

func (UnindexedDirectory) FilesByGlob

func (u UnindexedDirectory) FilesByGlob(patterns ...string) (out []file.Location, _ error)

- full symlink resolution should be performed on all requests - if multiple paths to the same file are found, the best single match should be returned - only returns locations to files (NOT directories)

func (UnindexedDirectory) FilesByMIMEType

func (u UnindexedDirectory) FilesByMIMEType(_ ...string) ([]file.Location, error)

func (UnindexedDirectory) FilesByPath

func (u UnindexedDirectory) FilesByPath(paths ...string) (out []file.Location, _ error)

- full symlink resolution should be performed on all requests - only returns locations to files (NOT directories)

func (UnindexedDirectory) HasPath

func (u UnindexedDirectory) HasPath(p string) bool

- full symlink resolution should be performed on all requests - returns locations for any file or directory

func (UnindexedDirectory) RelativeFileByPath

func (u UnindexedDirectory) RelativeFileByPath(l file.Location, p string) *file.Location

RelativeFileByPath fetches a single file at the given path relative to the layer squash of the given reference. This is helpful when attempting to find a file that is in the same layer or lower as another file.

func (UnindexedDirectory) Write

func (u UnindexedDirectory) Write(location file.Location, reader io.Reader) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL