Documentation
¶
Overview ¶
Package requirements answers one question: does THIS cluster satisfy a plugin's cluster-side requirements (Kubernetes, Deckhouse and module versions)?
It has two halves:
- ClusterState / LoadClusterState - a one-shot snapshot of the cluster facts the checks need;
- Checker.Checks - the ordered, named validators that enforce a plugin contract against a snapshot.
A check failure is either a genuinely unmet requirement (IsUnmet reports true; version selection may then try an older version) or an operational error (malformed constraint, unreadable cluster fact) that must propagate.
The Manager-side concerns stay in internal/plugins: building the Kubernetes clients from flags, caching the snapshot per command run, the --skip-cluster-checks escape hatch and its error wording.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasClusterRequirements ¶
HasClusterRequirements reports whether the plugin declares any requirement that needs cluster state to verify (Kubernetes / Deckhouse / modules).
func IsGenuinePrerelease ¶
IsGenuinePrerelease reports whether a pre-release segment denotes a real pre-release (rc/alpha/beta/preview/snapshot) rather than a CI/build marker. Version selection uses the same notion to keep pre-releases out of the default pick.
Types ¶
type Check ¶
type Check struct {
Name string
Run func(*internal.Plugin, *ClusterState) error
}
Check is one named cluster-side validator. The ordered list returned by Checker.Checks is the single source of truth shared by enforcement (install/run gating) and version selection in internal/plugins, so a new check is added in one place and cannot drift between the two.
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker runs the cluster-side requirement checks. It carries only the logger used by the skip-with-a-warning paths (unknown Deckhouse version, module without a version).
func NewChecker ¶
type ClusterState ¶
type ClusterState struct {
// Kubernetes is the API server version, or nil if the cluster returned a version
// string that is not parseable as semver (a declared k8s requirement then fails).
Kubernetes *semver.Version
// Deckhouse is the platform version, or nil for a non-release build (e.g. "dev")
// or an absent annotation: Deckhouse version requirements are then skipped with
// a warning. A failure to READ the deployment is a hard error, not nil.
Deckhouse *semver.Version
// Modules maps module name -> its state; absence from the map means "not in cluster".
Modules map[string]ModuleState
}
ClusterState is a one-shot snapshot of the cluster facts needed to enforce a plugin's requirements. The caller decides when to (re)build it - typically lazily and once per command run, only when a plugin actually declares a cluster-side requirement.
func LoadClusterState ¶
func LoadClusterState(ctx context.Context, kubeCl kubernetes.Interface, dynamicCl dynamic.Interface, logger *dkplog.Logger) (*ClusterState, error)
LoadClusterState builds the snapshot from the cluster. A failure is fatal for the caller: if a plugin declares a requirement we cannot verify, it must not be installed blindly.
type ModuleState ¶
type ModuleState struct {
Enabled bool
// Version is the installed module version, or nil when the module reports none
// or a non-parseable value (some modules omit it).
Version *semver.Version
}
ModuleState is the cluster-side fact about a single Deckhouse module.