filesystem

package
v0.0.0-...-1e0f2b1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileStats is the name of the file where the scan stats are saved to.
	FileStats = "stats.json"

	// FileErrors is the name of the file where the scan errors are saved to.
	FileErrors = "errors.json"

	// FileMatches is the name of the file where the scan matches are saved to.
	FileMatches = "matches.json"

	// FileTasks is the name of the file where the scan tasks are saved to.
	FileTasks = "tasks.json"

	// FileTemplates is the name of the file where the scan templates are saved to.
	FileTemplates = "templates.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Afero

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

Afero is a scan.FileSystem implementation that uses the afero.Fs interface under the hood. So, it can rely on the afero package abstractions to either use a regular (disk-based) file-system, or a virtual one (like in-memory).

func New

func New(fs afero.Fs, basePath string) (*Afero, error)

New creates a new Afero instance, using the given afero.Fs and the base path.

func (*Afero) Cleanup

func (a *Afero) Cleanup(ctx context.Context) error

Cleanup removes all the files from the file system.

func (*Afero) ErrorsIterator

func (a *Afero) ErrorsIterator(ctx context.Context) (chan scan.Error, scan.CloseFunc, error)

ErrorsIterator returns a channel that iterates over the scan.Error instances.

It also returns a function that can be used to close the iterator (see scan.CloseFunc). The channel is closed when the iterator is done (no more elements), when the scan.CloseFunc is called, or when the context is canceled. Thus, the context cancellation can also be used to stop the iteration.

It is the "streaming fashion" equivalent of [LoadErrors()].

func (*Afero) LoadErrors

func (a *Afero) LoadErrors(ctx context.Context) ([]scan.Error, error)

LoadErrors loads the scan.Error instances from the file system.

func (*Afero) LoadMatches

func (a *Afero) LoadMatches(ctx context.Context) ([]scan.Match, error)

LoadMatches loads the scan.Match instances from the file system.

func (*Afero) LoadStats

func (a *Afero) LoadStats(ctx context.Context) (*scan.Stats, error)

LoadStats loads the scan.Stats from the file system.

func (*Afero) LoadTasksSummaries

func (a *Afero) LoadTasksSummaries(ctx context.Context) ([]scan.TaskSummary, error)

LoadTasksSummaries loads the scan.TaskSummary instances from the file system.

func (*Afero) LoadTemplates

func (a *Afero) LoadTemplates(ctx context.Context) ([]scan.Template, error)

LoadTemplates loads the scan.Template instances from the file system.

func (*Afero) MatchesIterator

func (a *Afero) MatchesIterator(ctx context.Context) (chan scan.Match, scan.CloseFunc, error)

MatchesIterator returns a channel that iterates over the scan.Match instances.

It also returns a function that can be used to close the iterator (see scan.CloseFunc). The channel is closed when the iterator is done (no more elements), when the scan.CloseFunc is called, or when the context is canceled. Thus, the context cancellation can also be used to stop the iteration.

It is the "streaming fashion" equivalent of [LoadMatches()].

func (*Afero) StoreError

func (a *Afero) StoreError(ctx context.Context, scanError scan.Error) error

StoreError stores the given scan.Error into the file system.

func (*Afero) StoreMatch

func (a *Afero) StoreMatch(ctx context.Context, scanMatch scan.Match) error

StoreMatch stores the given scan.Match into the file system.

func (*Afero) StoreStats

func (a *Afero) StoreStats(ctx context.Context, stats *scan.Stats) error

StoreStats stores the given scan.Stats into the file system.

func (*Afero) StoreTaskSummary

func (a *Afero) StoreTaskSummary(ctx context.Context, scanTaskSummary scan.TaskSummary) error

StoreTaskSummary stores the given scan.TaskSummary into the file system.

func (*Afero) StoreTemplate

func (a *Afero) StoreTemplate(ctx context.Context, scanTemplate scan.Template) error

StoreTemplate stores the given scan.Template into the file system.

func (*Afero) TasksSummariesIterator

func (a *Afero) TasksSummariesIterator(ctx context.Context) (chan scan.TaskSummary, scan.CloseFunc, error)

TasksSummariesIterator returns a channel that iterates over the scan.TaskSummary instances.

It also returns a function that can be used to close the iterator (see scan.CloseFunc). The channel is closed when the iterator is done (no more elements), when the scan.CloseFunc is called, or when the context is canceled. Thus, the context cancellation can also be used to stop the iteration.

It is the "streaming fashion" equivalent of [LoadTasksSummaries()].

func (*Afero) TemplatesIterator

func (a *Afero) TemplatesIterator(ctx context.Context) (chan scan.Template, error)

TemplatesIterator returns a channel that iterates over the scan.Template instances.

It also returns a function that can be used to close the iterator (see scan.CloseFunc). The channel is closed when the iterator is done (no more elements), when the scan.CloseFunc is called, or when the context is canceled. Thus, the context cancellation can also be used to stop the iteration.

It is the "streaming fashion" equivalent of [LoadTemplates()].

Jump to

Keyboard shortcuts

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