scopes

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: 25 Imported by: 0

Documentation

Overview

Package scopes defines the verification scopes dmt lints in.

A scope is a source a module is read from, and it decides both which linters run and which of their rules each one is asked for. Linters and rules know nothing about scopes: a linter is handed its config and a set of rule IDs, and that is the whole of what a scope tells it. Which rules run is therefore a property of the tool, not of a module — .dmtlint.yaml tunes severities and can silence a rule with an ignored impact, but it cannot switch one on or off.

This mirrors internal/verify/lint in d8-package-plugin with the declaration inverted: there every linter exports its own scope table and gates its rules itself, so each linter has to know the scopes it lives in. Here the scope owns both tables, which is what keeps the linters unaware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Linter

type Linter interface {
	GetName() string
	Lint(ctx context.Context)
}

Linter is the common interface implemented by all lint passes. Everything a linter needs — its config, the rule IDs the scope asked it for, the module it inspects and the error list it reports into — is supplied to its constructor, so Lint takes only a context.

type Scope

type Scope string

Scope names one verification target: the source a module is read from.

const (
	Static  Scope = "static"
	Release Scope = "release"
	Bundle  Scope = "bundle"
)

Static lints a module directory on disk, i.e. the full source tree as committed. Release and Bundle lint the two images a published module consists of, unpacked from the registry: the bundle is the packaged module itself, the release is the metadata Deckhouse reads to decide whether to install a version.

func (Scope) Linters

func (s Scope) Linters(m *modules.Module, errList *errors.LintRuleErrorsList) []Linter

Linters returns the linters this scope runs over the module, each already carrying the set of rule IDs the scope asked it for.

It takes *modules.Module rather than pkg.Module because GetModuleConfig lives on the concrete type only. That is deliberate: slicing the config per linter is the scope's job, and a linter must not be able to reach a sibling's settings.

func (Scope) Settings added in v0.2.4

func (s Scope) Settings(cfg *config.RootConfig) *global.Linters

Settings returns the linter settings that configure this scope. Each scope reads its own section of .dmtlint.yaml — `linters-settings` under `global` for the source tree, `remote.bundle` and `remote.release` for the two published images — so the same rule can carry a different severity depending on where it is checked. The sections are independent: an image is not linted with the severities the source tree was tuned to, and a section left out means the built-in defaults.

Jump to

Keyboard shortcuts

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