Documentation ¶
Index ¶
- Constants
- func CalculateResult(tests []scapiv1alpha1.ScorecardTestResult) scapiv1alpha1.ScorecardSuiteResult
- func CombineScorecardOutput(outputs []scapiv1alpha1.ScorecardOutput, log string) scapiv1alpha1.ScorecardOutput
- func ScorecardTests(cmd *cobra.Command, args []string) error
- func TestResultToScorecardTestResult(tr TestResult) scapiv1alpha1.ScorecardTestResult
- func TestSuitesToScorecardOutput(suites []TestSuite, log string) scapiv1alpha1.ScorecardOutput
- func UpdateState(res scapiv1alpha1.ScorecardTestResult) scapiv1alpha1.ScorecardTestResult
- func UpdateSuiteStates(suite scapiv1alpha1.ScorecardSuiteResult) scapiv1alpha1.ScorecardSuiteResult
- type AnnotationsContainExamplesTest
- type BasicTestConfig
- type CRDsHaveResourcesTest
- type CRDsHaveValidationTest
- type CheckSpecTest
- type CheckStatusTest
- type OLMTestConfig
- type SpecDescriptorsTest
- type StatusDescriptorsTest
- type Test
- type TestInfo
- type TestResult
- type TestSuite
- type WritingIntoCRsHasEffectTest
Constants ¶
const ( ConfigOpt = "config" NamespaceOpt = "namespace" KubeconfigOpt = "kubeconfig" InitTimeoutOpt = "init-timeout" OlmDeployedOpt = "olm-deployed" CSVPathOpt = "csv-path" BasicTestsOpt = "basic-tests" OLMTestsOpt = "olm-tests" NamespacedManifestOpt = "namespaced-manifest" GlobalManifestOpt = "global-manifest" CRManifestOpt = "cr-manifest" ProxyImageOpt = "proxy-image" ProxyPullPolicyOpt = "proxy-pull-policy" CRDsDirOpt = "crds-dir" OutputFormatOpt = "output" PluginDirOpt = "plugin-dir" JSONOutputFormat = "json" HumanReadableOutputFormat = "human-readable" )
Variables ¶
This section is empty.
Functions ¶
func CalculateResult ¶
func CalculateResult(tests []scapiv1alpha1.ScorecardTestResult) scapiv1alpha1.ScorecardSuiteResult
CalculateResult returns a ScorecardSuiteResult with the state and Tests fields set based on a slice of ScorecardTestResults
func CombineScorecardOutput ¶
func CombineScorecardOutput(outputs []scapiv1alpha1.ScorecardOutput, log string) scapiv1alpha1.ScorecardOutput
func TestResultToScorecardTestResult ¶
func TestResultToScorecardTestResult(tr TestResult) scapiv1alpha1.ScorecardTestResult
TestResultToScorecardTestResult is a helper function for converting from the TestResult type to the ScorecardTestResult type
func TestSuitesToScorecardOutput ¶
func TestSuitesToScorecardOutput(suites []TestSuite, log string) scapiv1alpha1.ScorecardOutput
TestSuitesToScorecardOutput takes an array of test suites and generates a v1alpha1 ScorecardOutput object with the provided name, description, and log
func UpdateState ¶
func UpdateState(res scapiv1alpha1.ScorecardTestResult) scapiv1alpha1.ScorecardTestResult
UpdateState updates the state of a TestResult.
func UpdateSuiteStates ¶
func UpdateSuiteStates(suite scapiv1alpha1.ScorecardSuiteResult) scapiv1alpha1.ScorecardSuiteResult
UpdateSuiteStates update the state of each test in a suite and updates the count to the suite's states to match
Types ¶
type AnnotationsContainExamplesTest ¶
type AnnotationsContainExamplesTest struct { TestInfo OLMTestConfig }
AnnotationsContainExamplesTest is a scorecard test that verifies that the CSV contains examples via the alm-examples annotation
func NewAnnotationsContainExamplesTest ¶
func NewAnnotationsContainExamplesTest(conf OLMTestConfig) *AnnotationsContainExamplesTest
NewAnnotationsContainExamplesTest returns a new AnnotationsContainExamplesTest object
func (*AnnotationsContainExamplesTest) Run ¶
func (t *AnnotationsContainExamplesTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type BasicTestConfig ¶
type BasicTestConfig struct { Client client.Client CR *unstructured.Unstructured ProxyPod *v1.Pod }
BasicTestConfig contains all variables required by the BasicTest TestSuite
type CRDsHaveResourcesTest ¶
type CRDsHaveResourcesTest struct { TestInfo OLMTestConfig }
CRDsHaveResourcesTest is a scorecard test that verifies that the CSV lists used resources in its owned CRDs secyion
func NewCRDsHaveResourcesTest ¶
func NewCRDsHaveResourcesTest(conf OLMTestConfig) *CRDsHaveResourcesTest
NewCRDsHaveResourcesTest returns a new CRDsHaveResourcesTest object
func (*CRDsHaveResourcesTest) Run ¶
func (t *CRDsHaveResourcesTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type CRDsHaveValidationTest ¶
type CRDsHaveValidationTest struct { TestInfo OLMTestConfig }
CRDsHaveValidationTest is a scorecard test that verifies that all CRDs have a validation section
func NewCRDsHaveValidationTest ¶
func NewCRDsHaveValidationTest(conf OLMTestConfig) *CRDsHaveValidationTest
NewCRDsHaveValidationTest returns a new CRDsHaveValidationTest object
func (*CRDsHaveValidationTest) Run ¶
func (t *CRDsHaveValidationTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type CheckSpecTest ¶
type CheckSpecTest struct { TestInfo BasicTestConfig }
CheckSpecTest is a scorecard test that verifies that the CR has a spec block
func NewCheckSpecTest ¶
func NewCheckSpecTest(conf BasicTestConfig) *CheckSpecTest
NewCheckSpecTest returns a new CheckSpecTest object
func (*CheckSpecTest) Run ¶
func (t *CheckSpecTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type CheckStatusTest ¶
type CheckStatusTest struct { TestInfo BasicTestConfig }
CheckStatusTest is a scorecard test that verifies that the CR has a status block
func NewCheckStatusTest ¶
func NewCheckStatusTest(conf BasicTestConfig) *CheckStatusTest
NewCheckStatusTest returns a new CheckStatusTest object
func (*CheckStatusTest) Run ¶
func (t *CheckStatusTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type OLMTestConfig ¶
type OLMTestConfig struct { Client client.Client CR *unstructured.Unstructured CSV *olmapiv1alpha1.ClusterServiceVersion CRDsDir string ProxyPod *v1.Pod }
OLMTestConfig contains all variables required by the OLMTest TestSuite
type SpecDescriptorsTest ¶
type SpecDescriptorsTest struct { TestInfo OLMTestConfig }
SpecDescriptorsTest is a scorecard test that verifies that all spec fields have descriptors
func NewSpecDescriptorsTest ¶
func NewSpecDescriptorsTest(conf OLMTestConfig) *SpecDescriptorsTest
NewSpecDescriptorsTest returns a new SpecDescriptorsTest object
func (*SpecDescriptorsTest) Run ¶
func (t *SpecDescriptorsTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type StatusDescriptorsTest ¶
type StatusDescriptorsTest struct { TestInfo OLMTestConfig }
StatusDescriptorsTest is a scorecard test that verifies that all status fields have descriptors
func NewStatusDescriptorsTest ¶
func NewStatusDescriptorsTest(conf OLMTestConfig) *StatusDescriptorsTest
NewStatusDescriptorsTest returns a new StatusDescriptorsTest object
func (*StatusDescriptorsTest) Run ¶
func (t *StatusDescriptorsTest) Run(ctx context.Context) *TestResult
Run - implements Test interface
type Test ¶
type Test interface { GetName() string GetDescription() string IsCumulative() bool Run(context.Context) *TestResult }
Test provides methods for running scorecard tests
type TestInfo ¶
type TestInfo struct { Name string Description string // If a test is set to cumulative, the scores of multiple runs of the same test on separate CRs are added together for the total score. // If cumulative is false, if any test failed, the total score is 0/1. Otherwise 1/1. Cumulative bool }
TestInfo contains information about the scorecard test
func (TestInfo) GetDescription ¶
GetDescription returns the test description
func (TestInfo) IsCumulative ¶
IsCumulative returns true if the test's scores are intended to be cumulative
type TestResult ¶
type TestResult struct { State scapiv1alpha1.State Test Test EarnedPoints int MaximumPoints int Suggestions []string Errors []error }
TestResult contains a test's points, suggestions, and errors
func ResultsCumulative ¶
func ResultsCumulative(results []TestResult) (TestResult, error)
ResultsCumulative takes multiple TestResults and returns a single TestResult with MaximumPoints equal to the sum of the MaximumPoints of the input and EarnedPoints as the sum of EarnedPoints of the input
func ResultsPassFail ¶
func ResultsPassFail(results []TestResult) (TestResult, error)
ResultsPassFail combines multiple test results and returns a single test results with 1 maximum point and either 0 or 1 earned points
type TestSuite ¶
type TestSuite struct { TestInfo Tests []Test TestResults []TestResult Weights map[string]float64 Log string }
TestSuite contains a list of tests and results, along with the relative weights of each test. Also can optionally contain a log
func MergeSuites ¶
MergeSuites takes an array of TestSuites and combines all suites with the same name
func NewBasicTestSuite ¶
func NewBasicTestSuite(conf BasicTestConfig) *TestSuite
NewBasicTestSuite returns a new TestSuite object containing basic, functional operator tests
func NewOLMTestSuite ¶
func NewOLMTestSuite(conf OLMTestConfig) *TestSuite
NewOLMTestSuite returns a new TestSuite object containing CSV best practice checks
func NewTestSuite ¶
NewTestSuite returns a new TestSuite with a given name and description
func (*TestSuite) AddTest ¶
AddTest adds a new Test to a TestSuite along with a relative weight for the new Test
func (*TestSuite) TotalScore ¶
TotalScore calculates and returns the total score of all run Tests in a TestSuite
type WritingIntoCRsHasEffectTest ¶
type WritingIntoCRsHasEffectTest struct { TestInfo BasicTestConfig }
WritingIntoCRsHasEffectTest is a scorecard test that verifies that the operator is making PUT and/or POST requests to the API server
func NewWritingIntoCRsHasEffectTest ¶
func NewWritingIntoCRsHasEffectTest(conf BasicTestConfig) *WritingIntoCRsHasEffectTest
NewWritingIntoCRsHasEffectTest returns a new WritingIntoCRsHasEffectTest object
func (*WritingIntoCRsHasEffectTest) Run ¶
func (t *WritingIntoCRsHasEffectTest) Run(ctx context.Context) *TestResult
Run - implements Test interface