Documentation
¶
Index ¶
- Constants
- Variables
- func RunRequirementsCheck(modulePath string) *errors.LintRuleErrorsList
- type CommentStyle
- type ComponentRequirement
- type ComponentType
- type ConversionsRule
- type DeckhouseModule
- type DefinitionFileRule
- type FileTypeConfig
- type HelmignoreRule
- type LegacyReleaseFileRule
- type License
- type LicenseInfo
- type LicenseParser
- type LicenseRule
- type ModuleAccessibility
- type ModuleDescriptions
- type ModuleEdition
- type ModulePlatformRequirements
- type ModuleRequirements
- type ModuleUpdate
- type ModuleUpdateVersion
- type OSSRule
- type RequirementCheck
- type RequirementsRegistry
- type RequirementsRule
- type TestCase
- type TestHelper
- func (h *TestHelper) AssertErrors(errorList *errors.LintRuleErrorsList, expectedErrors []string)
- func (h *TestHelper) CreateTempModule(name string) string
- func (h *TestHelper) RunTestCase(tc *TestCase)
- func (h *TestHelper) SetupGoHooks(modulePath, goModContent, mainGoContent string)
- func (h *TestHelper) SetupModule(modulePath, content string)
- type TestSetup
Constants ¶
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\(` )
const ( // Default directory permissions for test files DefaultDirPerm = 0755 // Default file permissions for test files DefaultFilePerm = 0600 )
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
const (
ConversionsRuleName = "conversions"
)
const (
DefinitionFileRuleName = "definition-file"
)
const (
HelmignoreRuleName = "helmignore"
)
const (
LegacyReleaseFileRuleName = "legacy-release-file"
)
const (
LicenseRuleName = "license"
)
const (
ModuleConfigFilename = "module.yaml"
)
const (
OSSRuleName = "oss"
)
Variables ¶
var ValidBundles = []string{
"Minimal",
"Managed",
"Default",
}
Valid bundle values
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 ¶
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 ¶
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
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
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
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 ModuleEdition ¶ added in v0.1.33
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 OSSRule ¶
func NewOSSRule ¶
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
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 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