Documentation
¶
Overview ¶
Package dive wraps invocations of the wagoodman/dive CLI and parses its JSON analysis output.
Index ¶
Constants ¶
const DefaultTimeout = 5 * time.Minute
DefaultTimeout is used when DIVE_MCP_TIMEOUT is unset or unparsable.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileReference ¶
type FileReference struct {
Count int `json:"count"`
SizeBytes int64 `json:"sizeBytes"`
File string `json:"file"`
}
FileReference is a file that appears in more than one layer (a candidate for wasted space), along with how many times and how many bytes it costs.
func TopWasted ¶
func TopWasted(refs []FileReference, limit int) []FileReference
TopWasted returns up to limit FileReferences sorted in descending order of TotalWastedBytes. The input slice is not mutated.
func (FileReference) TotalWastedBytes ¶
func (f FileReference) TotalWastedBytes() int64
TotalWastedBytes returns Count * SizeBytes, i.e. the total bytes attributable to this file across all of its duplicated occurrences.
type ImageInfo ¶
type ImageInfo struct {
SizeBytes int64 `json:"sizeBytes"`
InefficientBytes int64 `json:"inefficientBytes"`
EfficiencyScore float64 `json:"efficiencyScore"`
FileReference []FileReference `json:"fileReference"`
}
ImageInfo summarizes the whole image, including candidate wasted files.
type Layer ¶
type Layer struct {
Index int `json:"index"`
ID string `json:"id"`
DigestID string `json:"digestId"`
SizeBytes int64 `json:"sizeBytes"`
Command string `json:"command"`
// FileList holds the (large) per-file tree for the layer. It is not
// needed by any of the dive-mcp tools, so it is captured loosely and
// never unmarshalled into a rigid struct.
FileList []json.RawMessage `json:"fileList,omitempty"`
}
Layer describes a single image layer as reported by dive.
type Runner ¶
type Runner struct {
// BinPath is the resolved path to the dive executable.
BinPath string
// Timeout bounds each invocation of dive.
Timeout time.Duration
// contains filtered or unexported fields
}
Runner locates and invokes the dive CLI, caching parsed analyses for the lifetime of the process so that multiple MCP tool calls against the same (image, source) pair only shell out to dive once.