manager

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func New added in v0.2.4

func New(cfg *config.RootConfig, src Source) *Manager

func (*Manager) ApplyFixes added in v0.1.82

func (m *Manager) ApplyFixes()

ApplyFixes is the single entry point for the --fix flag. It runs every fix attached to a collected finding. Findings whose fix succeeds are marked Fixed and subsequently dropped by GetErrors; findings whose fix fails are kept, and PrintResult reports the failure via the finding's FixError.

func (*Manager) Close added in v0.2.4

func (m *Manager) Close()

Close releases the source's resources. It must be called after the findings are printed: a source may be holding the directory the run linted.

func (*Manager) GetErrors added in v0.1.77

func (m *Manager) GetErrors() []pkg.LinterError

GetErrors returns all findings collected during the run. It is primarily intended for tests (e.g. the e2e framework) that need to assert on the structured findings produced by the linters.

func (*Manager) HasCriticalErrors added in v0.1.0

func (m *Manager) HasCriticalErrors() bool

func (*Manager) MetricsSections added in v0.2.4

func (m *Manager) MetricsSections() []*global.Linters

MetricsSections returns the config sections this run linted with, in the form metrics.Flush takes. They follow from the source's scopes — `linters-settings` for a source tree, `remote.bundle` and `remote.release` for the published images — so the caller does not have to know which run it started.

func (*Manager) PrintResult added in v0.1.0

func (m *Manager) PrintResult()

func (*Manager) PrintStatistics added in v0.1.103

func (m *Manager) PrintStatistics()

PrintStatistics prints the end-of-lint statistics as a framed summary block styled identically to the deckhouse-cli mirror summaries. It is meant to be called after PrintResult, once all findings have been listed.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run lints the targets the source pushes. The returned error is the source's: the findings collected before it are still on the Manager, so the caller prints them first and reports the error afterwards.

type Source added in v0.2.4

type Source interface {
	// ConfigDir is the directory .dmtlint.yaml is looked up from and the metrics
	// labels are derived from. It is read before Targets, to load the config Targets
	// is then handed.
	ConfigDir() string
	// Scopes are the scopes this source produces targets in. Answered without loading
	// anything, so a run that finds no modules still reports the sections it would
	// have linted with.
	Scopes() []scopes.Scope
	// Targets loads the modules to lint, handing each to yield as soon as it is
	// built. Targets are pushed rather than returned as a slice because a --matrix
	// run expands one module into many renders: yield blocks while the worker pool
	// is full, so the source builds the next render only once an earlier one has
	// been linted and freed, and a module that expands to thousands of renders never
	// has more than the worker count of them resident. A false from yield means the
	// run is over and the source must stop.
	//
	// Findings made while loading go into errorList; a returned error is one the run
	// could not fold into a finding, e.g. a registry failure, and is reported after
	// the findings are printed rather than instead of them.
	Targets(
		ctx context.Context,
		cfg *config.RootConfig,
		errorList *errors.LintRuleErrorsList,
		yield func(Target) bool,
	) error
	// Close releases what the source allocated, e.g. image extraction directories.
	// It runs after the findings are printed, so a finding must never name a path
	// that only exists until Close.
	Close()
}

Source supplies the modules a run lints. It is the only thing that differs between linting a source tree and linting the images a release published: everything after the modules exist — running the linters, printing, statistics, metrics — is the Manager's, and identical for both.

type Target added in v0.2.4

type Target struct {
	Module *modules.Module
	Scope  scopes.Scope
	// ModuleID is what the source calls one module. Targets sharing it count as one
	// module in the summary, which is how a remote run reports the two images it read
	// as the single module they are. It is not the module's name: a tree can hold two
	// directories declaring the same name, and those are two modules.
	ModuleID string
	// ObjectID tags this target's findings. The remote source sets the scope name so
	// bundle and release findings stay apart in the output; empty means no tag.
	ObjectID string
	// Variant marks this target as one of several renders of the same module, which
	// is what a --matrix run produces. It turns on deduplication for the whole run:
	// a finding that does not depend on the value combination being rendered is
	// produced once per combination, and only one of those is worth printing.
	Variant bool
}

Target is one unit of work: a module and the scope it is linted in. The unit is a pair rather than a module because a remote run reads one module from two images and lints each in its own scope.

Jump to

Keyboard shortcuts

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