filesystem

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const IgnoreFileName = ".cbomkitignore"

Variables

This section is empty.

Functions

func LoadIgnorePatterns

func LoadIgnorePatterns(rootPath string, configPatterns []string, cliPatterns []string) []string

LoadIgnorePatterns loads ignore patterns from all sources: 1. The .cbomkitignore file in rootPath (if rootPath is non-empty) 2. Config-based patterns (passed in) 3. CLI flag patterns (passed in) Patterns are merged; duplicates are not removed (they are harmless).

func ReadAllAndClose

func ReadAllAndClose(rc io.ReadCloser) ([]byte, error)

Types

type FilePathAnalysisFunc

type FilePathAnalysisFunc func(path string) error

FilePathAnalysisFunc A simple interface for a function to walk directories

type Filesystem

type Filesystem interface {
	WalkDir(fn FilePathAnalysisFunc) (err error)            // Walk the full filesystem using the FilePathAnalysisFunc fn
	Open(path string) (readCloser io.ReadCloser, err error) // Read a specific file with a path from the root of the filesystem
	Exists(path string) (exists bool, err error)            // Check if a specific file exists with a path from the root of the filesystem
	GetConfig() (config v1.Config, ok bool)                 // Get a config of this filesystem in container image format (if it exists)
	GetIdentifier() string                                  // Identifier for this specific filesystem; can be used for logging
}

Filesystem interface is mainly used to interact with all types of possible data source (e.g., directories, docker images etc.); for images this represents a squashed layer

func NewFilteredFilesystem

func NewFilteredFilesystem(inner Filesystem, patterns []string) Filesystem

NewFilteredFilesystem creates a new FilteredFilesystem that wraps inner and skips files matching any of the provided patterns. Patterns use doublestar glob syntax (compatible with .gitignore-style patterns).

type FilteredFilesystem

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

FilteredFilesystem wraps a Filesystem and skips paths matching ignore patterns.

func (*FilteredFilesystem) Exists

func (f *FilteredFilesystem) Exists(path string) (bool, error)

Exists delegates to the inner filesystem.

func (*FilteredFilesystem) GetConfig

func (f *FilteredFilesystem) GetConfig() (v1.Config, bool)

GetConfig delegates to the inner filesystem.

func (*FilteredFilesystem) GetIdentifier

func (f *FilteredFilesystem) GetIdentifier() string

GetIdentifier delegates to the inner filesystem.

func (*FilteredFilesystem) Open

func (f *FilteredFilesystem) Open(path string) (io.ReadCloser, error)

Open delegates to the inner filesystem.

func (*FilteredFilesystem) WalkDir

WalkDir walks the wrapped filesystem, skipping files that match any ignore pattern.

type PlainFilesystem

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

PlainFilesystem Simple plain filesystem that is constructed from the directory

func NewPlainFilesystem

func NewPlainFilesystem(rootPath string) PlainFilesystem

NewPlainFilesystem Get a new PlainFilesystem from rootPath

func (PlainFilesystem) Exists

func (plainFilesystem PlainFilesystem) Exists(path string) (bool, error)

Exists Check if a file at path exists in the filesystem; a path should be relative to PlainFilesystem.rootPath

func (PlainFilesystem) GetConfig

func (plainFilesystem PlainFilesystem) GetConfig() (config v1.Config, ok bool)

GetConfig A plain directory does not have a filesystem, so we return an empty object and false

func (PlainFilesystem) GetIdentifier

func (plainFilesystem PlainFilesystem) GetIdentifier() string

GetIdentifier Get a unique string for this PlainFilesystem; can be used for logging, etc.

func (PlainFilesystem) Open

func (plainFilesystem PlainFilesystem) Open(path string) (io.ReadCloser, error)

Open Read a file from this filesystem; a path should be relative to PlainFilesystem.rootPath

func (PlainFilesystem) WalkDir

func (plainFilesystem PlainFilesystem) WalkDir(fn FilePathAnalysisFunc) error

WalkDir Walk the whole PlainFilesystem using fn

Jump to

Keyboard shortcuts

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