detect

package
v0.196.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package detect turns on the controls a descriptor's repositories call for, for a descriptor that sets config.detect: the ones a scan with no descriptor turns on for the same files.

Every command that acts on a descriptor goes through Apply, so a scan, `draugr doctor` and the MCP server's scan agree about what a descriptor turns on. `draugr validate` does not: it checks what the file says, and what the file says is `detect: true`.

Index

Constants

View Source
const UnreadReason = "not a directory on this machine, so config.detect read none of its files"

UnreadReason is why a repository was not read, in the words the run prints.

A remote repository is fetched by the scan's jobs, which start once the controls are decided, so there is no copy of it to read while deciding them. Reading it here would mean a second clone of every remote repository on every command that loads the descriptor, doctor included.

Variables

This section is empty.

Functions

func Layer

func Layer(detected, written map[string]saga.ControllerSettings) map[string]saga.ControllerSettings

Layer lays the controls a descriptor writes over the ones detected: each control the descriptor names keeps every setting it writes, `enabled: false` included, and takes the detected settings it does not write. A control it does not name stays as detected.

func Merge

func Merge(trees ...inventory.Tree) inventory.Tree

Merge is one tree holding what each of trees holds, for deciding what they call for together.

Every list in a Tree is appended, by reflection rather than by name, so a kind of file the inventory learns to find reaches detect without anybody remembering to add it here. The paths stay relative to their own repository, which is enough for what is decided from them: whether a kind of file is there, and how a requirements file is named.

Types

type Repository

type Repository struct {
	// URL is the repository as the descriptor names it.
	URL string
	// Components are the components naming it, in the descriptor's order.
	Components []string
	// Tree is what the repository holds.
	Tree inventory.Tree
}

Repository is one repository detect read, and the components that name it.

type Result

type Result struct {
	// Read are the local repositories, each once, in the order the descriptor first names them.
	Read []Repository
	// Unread are the repositories detect could not read, each once.
	Unread []Unread
	// Written is the descriptor's own controls and reachability analysis, as it wrote them.
	Written saga.Config
}

Result is what detect read, and what the descriptor wrote itself before anything was detected.

func Apply

func Apply(m *saga.Model) (*Result, error)

Apply turns on what m's local repositories call for, beneath the controls m writes itself, and returns what it read. A model that does not set config.detect is left as it is, with a nil Result: a descriptor written without the field runs the controls it names and nothing else.

func ApplyWith

func ApplyWith(m *saga.Model, read func(string) inventory.Tree) (*Result, error)

ApplyWith is Apply reading each local repository with read, for a caller that has already read the tree and a test that hands one over.

The controls are one set for the whole descriptor, as config.controls is: a scanner one repository's files call for runs on every repository, and reads nothing where it has nothing to read. Each repository is read whole, whatever paths: and ignore: narrow a component to, because a control turned on for the descriptor runs on every component anyway.

func (*Result) AsWritten

func (r *Result) AsWritten(m *saga.Model) *saga.Model

AsWritten is m with the controls and reachability analysis its descriptor wrote, before detect added to them. A scanner a scan of it would run is one the descriptor asked for by name.

type Unread

type Unread struct {
	// URL is the repository as the descriptor names it.
	URL string
	// Components are the components naming it, in the descriptor's order.
	Components []string
}

Unread is a repository detect did not read: one that is not a directory on this machine.

Directories

Path Synopsis
Package chosen is what config.detect chose for a descriptor's files, and what becomes of a scanner it chose that this machine cannot run.
Package chosen is what config.detect chose for a descriptor's files, and what becomes of a scanner it chose that this machine cannot run.

Jump to

Keyboard shortcuts

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