Documentation
¶
Index ¶
- Constants
- Variables
- func RunRequirementsCheck(modulePath string) *errors.LintRuleErrorsList
- type ComponentRequirement
- type ComponentType
- type ConversionsRule
- type DeckhouseModule
- type DefinitionFileRule
- type HelmignoreRule
- 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" // MinimalModuleSDKVersionForReadiness defines the minimum module-sdk version for readiness probes MinimalModuleSDKVersionForReadiness = "0.3" // Common patterns used in Go files ReadinessProbePattern = `(\w+)\.WithReadiness` 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 (
LicenseRuleName = "license"
)
const (
ModuleConfigFilename = "module.yaml"
)
const (
OSSRuleName = "oss"
)
Variables ¶
var CELicenseRe = regexp.MustCompile(`(?s)[/#{!-]*(\s)*Copyright 202[1-9] Flant JSC[-!}\n#/]*
[/#{!-]*(\s)*Licensed under the Apache License, Version 2\.0 \(the "License"\);[-!}\n]*
[/#{!-]*(\s)*you may not use this file except in compliance with the License\.[-!}\n]*
[/#{!-]*(\s)*You may obtain a copy of the License at[-!}\n#/]*
[/#{!-]*(\s)*http://www\.apache\.org/licenses/LICENSE-2\.0[-!}\n#/]*
[/#{!-]*(\s)*Unless required by applicable law or agreed to in writing, software[-!}\n]*
[/#{!-]*(\s)*distributed under the License is distributed on an "AS IS" BASIS,[-!}\n]*
[/#{!-]*(\s)*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[-!}\n]*
[/#{!-]*(\s)*See the License for the specific language governing permissions and[-!}\n]*
[/#{!-]*(\s)*limitations under the License\.[-!}\n]*`)
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 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 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 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