test

package
v1.8.63 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ViolationsFoundError = errors.New("")

Functions

func LoadVersionMessages

func LoadVersionMessages(ctx *TestCommandContext, args []string, cmd *cobra.Command) error

func New

func New(ctx *TestCommandContext) *cobra.Command

func SetSilentMode

func SetSilentMode(cmd *cobra.Command)

func TestWrapper added in v1.5.19

func TestWrapper(ctx *TestCommandContext, args []string, testCommandFlags *TestCommandFlags) error

Types

type CliClient

type CliClient interface {
	RequestEvaluationPrerunData(token string, isCi bool) (*cliClient.EvaluationPrerunDataResponse, error)
	AddFlags(flags map[string]interface{})
}

type EvaluationPrinter

type EvaluationPrinter interface {
	GetWarningsText(warnings []printer.Warning, quiet bool) string
	GetSummaryTableText(summary printer.Summary) string
	PrintMessage(messageText string, messageColor string)
	PrintError(messageText string, messageColor string)
	PrintPromptMessage(promptMessage string)
	GetEvaluationSummaryText(evaluationSummary printer.EvaluationSummary, k8sVersion string) string
	SetTheme(theme *printer.Theme)
}

type EvaluationResultData

type EvaluationResultData struct {
	ValidationManager   *ValidationManager
	RulesCount          int
	FormattedResults    evaluation.FormattedResults
	AdditionalJUnitData evaluation.AdditionalJUnitData
	PromptMessage       string
}

type Evaluator

type Evaluator interface {
	Evaluate(policyCheckData evaluation.PolicyCheckData) (evaluation.PolicyCheckResultData, error)
	SendEvaluationResult(evaluationRequestData evaluation.EvaluationRequestData) (*cliClient.SendEvaluationResultsResponse, error)
}

type K8sValidator

type K8sValidator interface {
	ValidateResources(filesConfigurations chan *extractor.FileConfigurations, concurrency int, skipSchemaValidation bool) (chan *extractor.FileConfigurations, chan *extractor.InvalidFile, chan *validation.FileWithWarning)
	InitClient(k8sVersion string, ignoreMissingSchemas bool, schemaLocations []string, permissiveSchema bool)
	GetK8sFiles(filesConfigurationsChan chan *extractor.FileConfigurations, concurrency int) (chan *extractor.FileConfigurations, chan *extractor.FileConfigurations)
}

type LocalConfig

type LocalConfig interface {
	GetLocalConfiguration() (*localConfig.LocalConfig, error)
}

type Messager

type Messager interface {
	LoadVersionMessages(cliVersion string) chan *messager.VersionMessage
}

type Reader

type Reader interface {
	FilterFiles(paths []string) ([]string, error)
}

type TestCommandContext

type TestCommandContext struct {
	CliVersion         string
	CiContext          *ciContext.CIContext
	LocalConfig        LocalConfig
	Evaluator          Evaluator
	Messager           Messager
	K8sValidator       K8sValidator
	Printer            EvaluationPrinter
	Reader             Reader
	CliClient          CliClient
	FilesExtractor     files.FilesExtractorInterface
	StartTime          time.Time
	OpenBrowserContext utils.OpenBrowserContext
}

type TestCommandData

type TestCommandData struct {
	Output                string
	K8sVersion            string
	IgnoreMissingSchemas  bool
	OnlyK8sFiles          bool
	Verbose               bool
	NoRecord              bool
	Policy                policy_factory.Policy
	SchemaLocations       []string
	Token                 string
	RegistrationURL       string
	PromptRegistrationURL string
	ClientId              string
	SkipSchemaValidation  bool
	SaveRendered          bool
	PermissiveSchema      bool
	Quiet                 bool
	IsOffline             bool
}

func GenerateTestCommandData

func GenerateTestCommandData(testCommandFlags *TestCommandFlags, localConfigContent *localConfig.LocalConfig, evaluationPrerunDataResp *cliClient.EvaluationPrerunDataResponse) (*TestCommandData, error)

type TestCommandFlags

type TestCommandFlags struct {
	Output               string
	K8sVersion           string
	IgnoreMissingSchemas bool
	OnlyK8sFiles         bool
	Verbose              bool
	PolicyName           string
	SchemaLocations      []string
	PolicyConfig         string
	NoRecord             bool
	SkipValidation       string
	SaveRendered         bool
	PermissiveSchema     bool
	Quiet                bool
}

func NewTestCommandFlags

func NewTestCommandFlags() *TestCommandFlags

TestCommandFlags constructor

func (*TestCommandFlags) AddFlags

func (flags *TestCommandFlags) AddFlags(cmd *cobra.Command)

AddFlags registers flags for a cli

func (*TestCommandFlags) ToMapping

func (flags *TestCommandFlags) ToMapping() map[string]interface{}

func (*TestCommandFlags) Validate

func (flags *TestCommandFlags) Validate() error

type ValidationManager

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

func NewValidationManager

func NewValidationManager() *ValidationManager

func (*ValidationManager) AggregateIgnoredYamlFiles

func (v *ValidationManager) AggregateIgnoredYamlFiles(ignoredFilesChan chan *extractor.FileConfigurations, wg *sync.WaitGroup)

func (*ValidationManager) AggregateInvalidK8sFiles

func (v *ValidationManager) AggregateInvalidK8sFiles(invalidFilesChan chan *extractor.InvalidFile, wg *sync.WaitGroup)

func (*ValidationManager) AggregateInvalidYamlFiles

func (v *ValidationManager) AggregateInvalidYamlFiles(invalidFilesChan chan *extractor.InvalidFile, wg *sync.WaitGroup)

func (*ValidationManager) AggregateK8sValidationWarningsPerValidFile

func (v *ValidationManager) AggregateK8sValidationWarningsPerValidFile(filesWithWarningsChan chan *validation.FileWithWarning, wg *sync.WaitGroup)

func (*ValidationManager) AggregateValidK8sFiles

func (v *ValidationManager) AggregateValidK8sFiles(validK8sFilesConfigurationsChan chan *extractor.FileConfigurations, wg *sync.WaitGroup)

func (*ValidationManager) GetK8sValidationSummaryStr

func (v *ValidationManager) GetK8sValidationSummaryStr(filesCount int) string

func (*ValidationManager) GetK8sValidationWarningPerValidFile

func (v *ValidationManager) GetK8sValidationWarningPerValidFile() validation.K8sValidationWarningPerValidFile

func (*ValidationManager) IgnoredFiles

func (v *ValidationManager) IgnoredFiles() []*extractor.FileConfigurations

func (*ValidationManager) IgnoredFilesCount

func (v *ValidationManager) IgnoredFilesCount() int

func (*ValidationManager) InvalidK8sFiles

func (v *ValidationManager) InvalidK8sFiles() []*extractor.InvalidFile

func (*ValidationManager) InvalidK8sFilesCount

func (v *ValidationManager) InvalidK8sFilesCount() int

func (*ValidationManager) InvalidYamlFiles

func (v *ValidationManager) InvalidYamlFiles() []*extractor.InvalidFile

func (*ValidationManager) InvalidYamlFilesCount

func (v *ValidationManager) InvalidYamlFilesCount() int

func (*ValidationManager) ValidK8sConfigurationsCount

func (v *ValidationManager) ValidK8sConfigurationsCount() int

func (*ValidationManager) ValidK8sFilesConfigurationsCount

func (v *ValidationManager) ValidK8sFilesConfigurationsCount() int

func (*ValidationManager) ValidOrSkippedK8sFilesConfigurations added in v1.6.32

func (v *ValidationManager) ValidOrSkippedK8sFilesConfigurations() []*extractor.FileConfigurations

Jump to

Keyboard shortcuts

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