rules

package
v0.1.66 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequirementsRuleName = "requirements"
	// MinimalDeckhouseVersionForStage defines the minimum required Deckhouse version for stage usage
	MinimalDeckhouseVersionForStage = "1.68.0"
	// MinimalDeckhouseVersionForGoHooks defines the minimum required Deckhouse version for Go hooks usage
	MinimalDeckhouseVersionForGoHooks = "1.68.0"
	// MinimalDeckhouseVersionForReadinessProbes defines the minimum required Deckhouse version for readiness probes usage
	MinimalDeckhouseVersionForReadinessProbes = "1.71.0"
	// MinimalDeckhouseVersionForOptionalModules defines the minimum required Deckhouse version for optional modules usage
	MinimalDeckhouseVersionForOptionalModules = "1.73.0"

	// MinimalModuleSDKVersionRequiresDeckhouse171 defines the minimum module-sdk version that requires Deckhouse >= 1.71
	MinimalModuleSDKVersionRequiresDeckhouse171 = "0.3.0"
	// MinimalDeckhouseVersionForModuleSDK03 defines the minimum Deckhouse version required for Module-SDK >= 0.3
	MinimalDeckhouseVersionForModuleSDK03 = "1.71.0"

	// Common patterns used in Go files
	AppRunPattern = `\w+\.Run\(`
)
View Source
const (
	// Default directory permissions for test files
	DefaultDirPerm = 0755
	// Default file permissions for test files
	DefaultFilePerm = 0600
)
View Source
const (
	ValidModuleContent = `name: test-module
namespace: test`

	StageModuleContent = `name: test-module
namespace: test
stage: "General Availability"`

	StageWithRequirementsContent = `name: test-module
namespace: test
stage: "General Availability"
requirements:
  deckhouse: ">= 1.68.0"`

	GoModWithModuleSDK = `module test
require github.com/deckhouse/module-sdk v0.1.0`

	GoModWithModuleSDK03 = `module test
require github.com/deckhouse/module-sdk v0.3.0`

	MainGoWithAppRun = `package main
func main() { app.Run() }`

	MainGoWithReadiness = `package main
func main() { app.WithReadiness() }`

	MainGoEmpty = `package main
func main() { }`
)

Common test data constants

View Source
const (
	ConversionsRuleName = "conversions"
)
View Source
const (
	DefinitionFileRuleName = "definition-file"
)
View Source
const (
	HelmignoreRuleName = "helmignore"
)
View Source
const (
	LegacyReleaseFileRuleName = "legacy-release-file"
)
View Source
const (
	LicenseRuleName = "license"
)
View Source
const (
	ModuleConfigFilename = "module.yaml"
)
View Source
const (
	OSSRuleName = "oss"
)

Variables

View Source
var ValidBundles = []string{
	"Minimal",
	"Managed",
	"Default",
}

Valid bundle values

View Source
var ValidEditions = []string{
	"ce",
	"fe",
	"ee",
	"se",
	"se-plus",
	"be",
	"_default",
}

Valid edition values

Functions

func RunRequirementsCheck added in v0.1.30

func RunRequirementsCheck(modulePath string) *errors.LintRuleErrorsList

RunRequirementsCheck runs the requirements check and returns the error list

Types

type CommentStyle added in v0.1.41

type CommentStyle struct {
	LinePrefix string // Prefix for single-line comments (e.g., "//", "#")
	BlockStart string // Start of block comment (e.g., "/*", "<!--")
	BlockEnd   string // End of block comment (e.g., "*/", "-->")
	BlockLine  string // Optional prefix for lines within block (e.g., " * ")
}

CommentStyle defines how comments are formatted in different file types

type ComponentRequirement added in v0.1.30

type ComponentRequirement struct {
	ComponentType ComponentType
	MinVersion    string
	Description   string
}

ComponentRequirement defines a requirement for a specific component

type ComponentType added in v0.1.30

type ComponentType string

ComponentType represents the type of component for requirements validation

const (
	ComponentDeckhouse ComponentType = "deckhouse"
	ComponentK8s       ComponentType = "kubernetes"
	ComponentModule    ComponentType = "module"
)

type ConversionsRule

type ConversionsRule struct {
	pkg.RuleMeta
	pkg.BoolRule
}

func NewConversionsRule

func NewConversionsRule(disable bool) *ConversionsRule

func (*ConversionsRule) CheckConversions

func (r *ConversionsRule) CheckConversions(modulePath string, errorList *errors.LintRuleErrorsList)

type DeckhouseModule

type DeckhouseModule struct {
	Name          string               `json:"name"`
	Critical      bool                 `json:"critical,omitempty"`
	Namespace     string               `json:"namespace"`
	Weight        uint32               `json:"weight,omitempty"`
	Tags          []string             `json:"tags"`
	Subsystems    []string             `json:"subsystems,omitempty"`
	Stage         string               `json:"stage"`
	Description   string               `json:"description,omitempty"`
	Descriptions  ModuleDescriptions   `json:"descriptions,omitempty"`
	Requirements  *ModuleRequirements  `json:"requirements,omitempty"`
	Accessibility *ModuleAccessibility `json:"accessibility,omitempty"`
	Update        *ModuleUpdate        `json:"update,omitempty"`
}

type DefinitionFileRule

type DefinitionFileRule struct {
	pkg.RuleMeta
	pkg.BoolRule
}

func NewDefinitionFileRule

func NewDefinitionFileRule(disable bool) *DefinitionFileRule

func (*DefinitionFileRule) CheckDefinitionFile

func (r *DefinitionFileRule) CheckDefinitionFile(modulePath string, errorList *errors.LintRuleErrorsList)

type FileTypeConfig added in v0.1.41

type FileTypeConfig struct {
	Extensions    []string       // File extensions (e.g., ".go", ".py")
	CommentStyles []CommentStyle // Supported comment styles
}

FileTypeConfig defines comment styles for specific file types

type HelmignoreRule added in v0.1.28

type HelmignoreRule struct {
	pkg.RuleMeta
	pkg.BoolRule
}

func NewHelmignoreRule added in v0.1.28

func NewHelmignoreRule(disable bool) *HelmignoreRule

func (*HelmignoreRule) CheckHelmignore added in v0.1.28

func (r *HelmignoreRule) CheckHelmignore(modulePath string, errorList *errors.LintRuleErrorsList)

type LegacyReleaseFileRule added in v0.1.42

type LegacyReleaseFileRule struct {
	pkg.RuleMeta
}

func NewLegacyReleaseFileRule added in v0.1.42

func NewLegacyReleaseFileRule() *LegacyReleaseFileRule

func (*LegacyReleaseFileRule) CheckLegacyReleaseFile added in v0.1.42

func (r *LegacyReleaseFileRule) CheckLegacyReleaseFile(modulePath string, errorList *errors.LintRuleErrorsList)

type License added in v0.1.41

type License struct {
	Type        string // "CE" or "EE"
	Name        string // Human-readable name
	Template    string // License template with {{YEAR}} placeholder
	YearPattern string // Regex pattern for year validation
}

License represents a license type with its template

type LicenseInfo added in v0.1.41

type LicenseInfo struct {
	Type  string // "CE", "EE", or empty
	Year  string // Extracted year
	Valid bool   // Whether license is valid
	Error string // Error message if invalid
}

LicenseInfo contains information about parsed license

type LicenseParser added in v0.1.41

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

LicenseParser handles license parsing and validation

func NewLicenseParser added in v0.1.41

func NewLicenseParser() *LicenseParser

NewLicenseParser creates a new license parser with default configuration

func (*LicenseParser) ParseFile added in v0.1.41

func (p *LicenseParser) ParseFile(filename string) (*LicenseInfo, error)

ParseFile parses a file and extracts license information

type LicenseRule added in v0.1.3

type LicenseRule struct {
	pkg.RuleMeta
	pkg.PathRule
}

func NewLicenseRule added in v0.1.3

func NewLicenseRule(excludeFilesRules []pkg.StringRuleExclude,
	excludeDirectoryRules []pkg.PrefixRuleExclude) *LicenseRule

func (*LicenseRule) CheckFiles added in v0.1.3

func (r *LicenseRule) CheckFiles(mod *module.Module, errorList *errors.LintRuleErrorsList)

type ModuleAccessibility added in v0.1.33

type ModuleAccessibility struct {
	Editions map[string]ModuleEdition `json:"editions"`
}

type ModuleDescriptions added in v0.1.4

type ModuleDescriptions struct {
	English string `json:"en,omitempty"`
	Russian string `json:"ru,omitempty"`
}

type ModuleEdition added in v0.1.33

type ModuleEdition struct {
	Available        bool     `json:"available"`
	EnabledInBundles []string `json:"enabledInBundles"`
}

type ModulePlatformRequirements

type ModulePlatformRequirements struct {
	Deckhouse    string `json:"deckhouse,omitempty"`
	Kubernetes   string `json:"kubernetes,omitempty"`
	Bootstrapped bool   `json:"bootstrapped,omitempty"`
}

type ModuleRequirements

type ModuleRequirements struct {
	ModulePlatformRequirements `json:",inline"`
	ParentModules              map[string]string `json:"modules,omitempty"`
}

type ModuleUpdate added in v0.1.36

type ModuleUpdate struct {
	Versions []ModuleUpdateVersion `json:"versions,omitempty"`
}

type ModuleUpdateVersion added in v0.1.36

type ModuleUpdateVersion struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type OSSRule

type OSSRule struct {
	pkg.RuleMeta
	pkg.BoolRule
}

func NewOSSRule

func NewOSSRule(disable bool) *OSSRule

func (*OSSRule) OssModuleRule

func (r *OSSRule) OssModuleRule(moduleRoot string, errorList *errors.LintRuleErrorsList)

type RequirementCheck added in v0.1.30

type RequirementCheck struct {
	Name         string
	Requirements []ComponentRequirement
	Description  string
	Detector     func(modulePath string, module *DeckhouseModule) bool
}

RequirementCheck defines a single requirement check configuration Detector returns true if the rule should be applied to the module Requirements defines the minimum versions required for this rule Description is the rule description

type RequirementsRegistry added in v0.1.30

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

RequirementsRegistry holds all requirement checks

func NewRequirementsRegistry added in v0.1.30

func NewRequirementsRegistry() *RequirementsRegistry

NewRequirementsRegistry creates a new registry with default checks

func (*RequirementsRegistry) RegisterCheck added in v0.1.30

func (r *RequirementsRegistry) RegisterCheck(check RequirementCheck)

RegisterCheck adds a new requirement check to the registry

func (*RequirementsRegistry) RunAllChecks added in v0.1.30

func (r *RequirementsRegistry) RunAllChecks(modulePath string, module *DeckhouseModule, errorList *errors.LintRuleErrorsList)

RunAllChecks executes all registered requirement checks

type RequirementsRule added in v0.1.30

type RequirementsRule struct {
	pkg.RuleMeta
}

func NewRequirementsRule added in v0.1.30

func NewRequirementsRule() *RequirementsRule

func (*RequirementsRule) CheckRequirements added in v0.1.30

func (r *RequirementsRule) CheckRequirements(modulePath string, errorList *errors.LintRuleErrorsList)

type TestCase added in v0.1.30

type TestCase struct {
	Name           string
	Setup          TestSetup
	ExpectedErrors []string
	Description    string
}

TestCase represents a single test case

type TestHelper added in v0.1.30

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

TestHelper provides common testing utilities

func NewTestHelper added in v0.1.30

func NewTestHelper(t *testing.T) *TestHelper

NewTestHelper creates a new test helper

func (*TestHelper) AssertErrors added in v0.1.30

func (h *TestHelper) AssertErrors(errorList *errors.LintRuleErrorsList, expectedErrors []string)

AssertErrors asserts that the error list contains the expected errors

func (*TestHelper) CreateTempModule added in v0.1.30

func (h *TestHelper) CreateTempModule(name string) string

CreateTempModule creates a temporary module directory for testing

func (*TestHelper) RunTestCase added in v0.1.30

func (h *TestHelper) RunTestCase(tc *TestCase)

RunTestCase runs a single test case with the given setup

func (*TestHelper) SetupGoHooks added in v0.1.30

func (h *TestHelper) SetupGoHooks(modulePath, goModContent, mainGoContent string)

SetupGoHooks creates hooks directory with go.mod and main.go files

func (*TestHelper) SetupModule added in v0.1.30

func (h *TestHelper) SetupModule(modulePath, content string)

SetupModule creates module.yaml with given content

type TestSetup added in v0.1.30

type TestSetup struct {
	ModuleContent string
	SetupFiles    func(string) error
}

TestSetup represents the setup configuration for a test

Jump to

Keyboard shortcuts

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