version

package
v1.77.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Getter

type Getter func() (*semver.Version, error)

Getter retrieves the current version from the system. Examples:

  • Kubernetes version from API server
  • Deckhouse version from deployment
  • Module version from registry

type Rule

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

Rule validates version constraints using semantic versioning. It is a pure gate: it either has no opinion (Undefined) or hard-vetoes (Forbid) — it never turns a package on, so a satisfied version check cannot override an intent rule.

func NewRule

func NewRule(getter Getter, constraints *semver.Constraints, subject, reason string) *Rule

NewRule creates a new version rule with the given getter and constraints.

Example constraints:

  • ">=1.21" - Minimum version 1.21
  • ">=1.21, <2.0" - Range from 1.21 to 2.0
  • "~1.21" - Patch releases of 1.21
  • "^1.21" - Minor releases of 1.x

subject names what the version belongs to ("Kubernetes", "Deckhouse"). It carries the same information as reason, but in a form fit for a message shown to the user: the reason is a Kubernetes condition reason and is dropped on the admission path, where the message is all the user gets.

func (*Rule) Decide

func (r *Rule) Decide() rule.Decision

Decide retrieves the current version and validates it against constraints. Returns Forbid if:

  • Version getter fails (network error, API error, etc.)
  • Version doesn't satisfy constraints

Otherwise it returns Undefined (no opinion): the gate is satisfied.

Jump to

Keyboard shortcuts

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