Documentation
¶
Overview ¶
Package source defines the Source abstraction over scan targets (ARCHITECTURE.md §7): a Source couples a Walker (push-style, ignore-aware enumeration feeding phase 1), a Resolver (pull-style access for phase-2 project detectors), content identity (image digest, git HEAD, dir realpath), layer IDs for blob-cache granularity, and SourceInfo provenance.
The interface is shaped by the WORST source — a squashed OCI tar stream: sequential, non-seekable, consume-during-walk; the directory case is the easy specialization. Concrete implementations live in the dirsource, gitsource, imagesource, and k8ssource subpackages. One resolver abstraction keeps every detector — including third-party — automatically source-agnostic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Ref classify.FileRef
Open func() (io.ReadCloser, error)
ReaderAt func() (ReaderAtCloser, error)
}
Entry is one enumerated file: classified identity plus lazy content access. For dir sources Open is reusable and ReaderAt is available; for stream sources Open is one-shot (spool-backed) and ReaderAt is nil.
type Info ¶
Info is the provenance root for a scan's output (§7). Phase 6 sources extend it with git/image/k8s fields.
type ReaderAtCloser ¶
ReaderAtCloser is random access with explicit ownership: whoever obtains one closes it.
type Resolver ¶
type Resolver interface {
FilesByGlob(ctx context.Context, patterns ...string) ([]classify.FileRef, error)
Open(path string) (io.ReadCloser, error)
Stat(path string) (classify.FileRef, error)
}
Resolver is the pull-side file query API (§6.1, §7). Paths are source-root-relative with forward slashes. Implementations honor the same ignore rules as Walk.
type Source ¶
type Source interface {
Name() string
Kind() Kind
// ID is the source's content identity (dir realpath; later: image
// digest, git HEAD) — a cache-key ingredient.
ID() string
// Walk streams entries (ignore-aware, files only). It returns after
// every callback has returned; walk-level failures are recorded as
// Unknowns, not errors (P6) — the returned error is reserved for
// cancellation and catastrophic source failure.
Walk(ctx context.Context, fn WalkFunc) error
// WalkUnknowns returns the walk-level Unknown records accumulated by
// the most recent Walk. Valid after Walk returns.
WalkUnknowns() []Unknown
// WalkStats returns the most recent Walk's exclusion accounting: what the
// walk deliberately did not enumerate. Sources with no ignore rules
// (image archives, rendered manifests) return the zero value, which is
// the honest answer: nothing was excluded.
WalkStats() WalkStats
// Resolver is the pull-style query API for phase-2 project detectors.
Resolver() Resolver
Info() Info
Close() error
}
Source is the engine-facing contract every acquisition implements (§7).
type TargetKind ¶
type TargetKind string
TargetKind is the result of `airom scan` scheme auto-detection (docs/cli.md). It is deliberately narrower than the full set of source implementations: k8s has its own command and never comes through Detect.
const ( TargetDir TargetKind = "dir" TargetRepo TargetKind = "repo" TargetImage TargetKind = "image" )
The three kinds `airom scan` can auto-detect (docs/cli.md).
func DetectTarget ¶
func DetectTarget(target string) (TargetKind, string, error)
DetectTarget implements the `airom scan` scheme auto-detection order from docs/cli.md:
- Explicit prefix (dir:, repo:, image:) forces the kind.
- An existing local path is a filesystem scan.
- A git-shaped URL is a repo scan.
- Anything else is treated as an image reference.
It returns the detected kind and the target with any forcing prefix stripped.
type Unknown ¶
Unknown records a file or directory the walk could not fully process (permission denied, races, IO errors) — surfaced in the output, never silently dropped (invariant P6).
type WalkFunc ¶
WalkFunc receives entries during a streaming walk. Returning an error aborts the walk with that error. The callback may be invoked from multiple goroutines (fastwalk); the engine's task channel serializes downstream.
type WalkStats ¶ added in v0.4.2
WalkStats is a Walk's exclusion accounting, feeding the scan assurance block (ScanStats): FilesIgnored counts files the ignore rules excluded; DirsPruned counts directories excluded whole, whose contents were never enumerated — one line per directory, because the walker cannot count what it never listed.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dirsource implements the filesystem source (ARCHITECTURE.md §7): streaming enumeration with a nested per-directory .gitignore/.airomignore stack, non-overridable default skips, user --ignore globs, and an ignore-honoring resolver for the phase-2 pull API.
|
Package dirsource implements the filesystem source (ARCHITECTURE.md §7): streaming enumeration with a nested per-directory .gitignore/.airomignore stack, non-overridable default skips, user --ignore globs, and an ignore-honoring resolver for the phase-2 pull API. |
|
Package gitsource implements the remote-repository Source (ARCHITECTURE.md §7): git clone --depth=1 --single-branch --no-tags via an exec-git fast path when a git binary is available, with a go-git v6 fallback (decision D14: go-git's shallow-clone inefficiency is documented; established scanners shell out too).
|
Package gitsource implements the remote-repository Source (ARCHITECTURE.md §7): git clone --depth=1 --single-branch --no-tags via an exec-git fast path when a git binary is available, with a go-git v6 fallback (decision D14: go-git's shallow-clone inefficiency is documented; established scanners shell out too). |
|
Package imagesource implements the container-image Source (ARCHITECTURE.md §7, decision D11): go-containerregistry resolves a v1.Image through the remote → daemon → tarball → OCI-layout fallback chain, and the squashed tar from mutate.Extract is streamed exactly once.
|
Package imagesource implements the container-image Source (ARCHITECTURE.md §7, decision D11): go-containerregistry resolves a v1.Image through the remote → daemon → tarball → OCI-layout fallback chain, and the squashed tar from mutate.Extract is streamed exactly once. |
|
Package k8ssource implements the Kubernetes Source (ARCHITECTURE.md §7).
|
Package k8ssource implements the Kubernetes Source (ARCHITECTURE.md §7). |