scorecard

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigOpt             = "config"
	NamespaceOpt          = "namespace"
	KubeconfigOpt         = "kubeconfig"
	InitTimeoutOpt        = "init-timeout"
	OlmDeployedOpt        = "olm-deployed"
	CSVPathOpt            = "csv-path"
	BasicTestsOpt         = "basic-tests"
	OLMTestsOpt           = "olm-tests"
	TenantTestsOpt        = "good-tenant-tests"
	NamespacedManifestOpt = "namespace-manifest"
	GlobalManifestOpt     = "global-manifest"
	CRManifestOpt         = "cr-manifest"
	ProxyImageOpt         = "proxy-image"
	ProxyPullPolicyOpt    = "proxy-pull-policy"
	CRDsDirOpt            = "crds-dir"
	VerboseOpt            = "verbose"
)

Variables

View Source
var (
	ScorecardConf string
)

Functions

func ResultsCumulative added in v0.6.0

func ResultsCumulative(results []TestResult) (earned, max int)

ResultsCumulative will be used when multiple CRs are supported

func ResultsPassFail added in v0.6.0

func ResultsPassFail(results []TestResult) (earned, max int)

ResultsPassFail will be used when multiple CRs are supported

func ScorecardTests

func ScorecardTests(cmd *cobra.Command, args []string) error

Types

type AnnotationsContainExamplesTest added in v0.6.0

type AnnotationsContainExamplesTest struct {
	TestInfo
	OLMTestConfig
}

AnnotationsContainExamplesTest is a scorecard test that verifies that the CSV contains examples via the alm-examples annotation

func NewAnnotationsContainExamplesTest added in v0.6.0

func NewAnnotationsContainExamplesTest(conf OLMTestConfig) *AnnotationsContainExamplesTest

NewAnnotationsContainExamplesTest returns a new AnnotationsContainExamplesTest object

func (*AnnotationsContainExamplesTest) Run added in v0.6.0

Run - implements Test interface

type BasicTestConfig added in v0.6.0

type BasicTestConfig struct {
	Client   client.Client
	CR       *unstructured.Unstructured
	ProxyPod *v1.Pod
}

BasicTestConfig contains all variables required by the BasicTest TestSuite

type CRDsHaveResourcesTest added in v0.6.0

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 added in v0.6.0

func NewCRDsHaveResourcesTest(conf OLMTestConfig) *CRDsHaveResourcesTest

NewCRDsHaveResourcesTest returns a new CRDsHaveResourcesTest object

func (*CRDsHaveResourcesTest) Run added in v0.6.0

Run - implements Test interface

type CRDsHaveValidationTest added in v0.6.0

type CRDsHaveValidationTest struct {
	TestInfo
	OLMTestConfig
}

CRDsHaveValidationTest is a scorecard test that verifies that all CRDs have a validation section

func NewCRDsHaveValidationTest added in v0.6.0

func NewCRDsHaveValidationTest(conf OLMTestConfig) *CRDsHaveValidationTest

NewCRDsHaveValidationTest returns a new CRDsHaveValidationTest object

func (*CRDsHaveValidationTest) Run added in v0.6.0

Run - implements Test interface

type CheckSpecTest added in v0.6.0

type CheckSpecTest struct {
	TestInfo
	BasicTestConfig
}

CheckSpecTest is a scorecard test that verifies that the CR has a spec block

func NewCheckSpecTest added in v0.6.0

func NewCheckSpecTest(conf BasicTestConfig) *CheckSpecTest

NewCheckSpecTest returns a new CheckSpecTest object

func (*CheckSpecTest) Run added in v0.6.0

func (t *CheckSpecTest) Run(ctx context.Context) *TestResult

Run - implements Test interface

type CheckStatusTest added in v0.6.0

type CheckStatusTest struct {
	TestInfo
	BasicTestConfig
}

CheckStatusTest is a scorecard test that verifies that the CR has a status block

func NewCheckStatusTest added in v0.6.0

func NewCheckStatusTest(conf BasicTestConfig) *CheckStatusTest

NewCheckStatusTest returns a new CheckStatusTest object

func (*CheckStatusTest) Run added in v0.6.0

Run - implements Test interface

type OLMTestConfig added in v0.6.0

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 added in v0.6.0

type SpecDescriptorsTest struct {
	TestInfo
	OLMTestConfig
}

SpecDescriptorsTest is a scorecard test that verifies that all spec fields have descriptors

func NewSpecDescriptorsTest added in v0.6.0

func NewSpecDescriptorsTest(conf OLMTestConfig) *SpecDescriptorsTest

NewSpecDescriptorsTest returns a new SpecDescriptorsTest object

func (*SpecDescriptorsTest) Run added in v0.6.0

Run - implements Test interface

type StatusDescriptorsTest added in v0.6.0

type StatusDescriptorsTest struct {
	TestInfo
	OLMTestConfig
}

StatusDescriptorsTest is a scorecard test that verifies that all status fields have descriptors

func NewStatusDescriptorsTest added in v0.6.0

func NewStatusDescriptorsTest(conf OLMTestConfig) *StatusDescriptorsTest

NewStatusDescriptorsTest returns a new StatusDescriptorsTest object

func (*StatusDescriptorsTest) Run added in v0.6.0

Run - implements Test interface

type Test added in v0.6.0

type Test interface {
	GetName() string
	GetDescription() string
	IsCumulative() bool
	Run(context.Context) *TestResult
}

Test provides methods for running scorecard tests

type TestInfo added in v0.6.0

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 added in v0.6.0

func (i TestInfo) GetDescription() string

GetDescription returns the test description

func (TestInfo) GetName added in v0.6.0

func (i TestInfo) GetName() string

GetName return the test name

func (TestInfo) IsCumulative added in v0.6.0

func (i TestInfo) IsCumulative() bool

IsCumulative returns true if the test's scores are intended to be cumulative

type TestResult added in v0.6.0

type TestResult struct {
	Test          Test
	EarnedPoints  int
	MaximumPoints int
	Suggestions   []string
	Errors        []error
}

TestResult contains a test's points, suggestions, and errors

type TestSuite added in v0.6.0

type TestSuite struct {
	TestInfo
	Tests       []Test
	TestResults []*TestResult
	Weights     map[string]float64
}

TestSuite contains a list of tests and results, along with the relative weights of each test

func NewBasicTestSuite added in v0.6.0

func NewBasicTestSuite(conf BasicTestConfig) *TestSuite

NewBasicTestSuite returns a new TestSuite object containing basic, functional operator tests

func NewOLMTestSuite added in v0.6.0

func NewOLMTestSuite(conf OLMTestConfig) *TestSuite

NewOLMTestSuite returns a new TestSuite object containing CSV best practice checks

func NewTestSuite added in v0.6.0

func NewTestSuite(name, description string) *TestSuite

NewTestSuite returns a new TestSuite with a given name and description

func (*TestSuite) AddTest added in v0.6.0

func (ts *TestSuite) AddTest(t Test, weight float64)

AddTest adds a new Test to a TestSuite along with a relative weight for the new Test

func (*TestSuite) Run added in v0.6.0

func (ts *TestSuite) Run(ctx context.Context)

Run runs all Tests in a TestSuite

func (*TestSuite) TotalScore added in v0.6.0

func (ts *TestSuite) TotalScore() (score int)

TotalScore calculates and returns the total score of all run Tests in a TestSuite

type WritingIntoCRsHasEffectTest added in v0.6.0

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 added in v0.6.0

func NewWritingIntoCRsHasEffectTest(conf BasicTestConfig) *WritingIntoCRsHasEffectTest

NewWritingIntoCRsHasEffectTest returns a new WritingIntoCRsHasEffectTest object

func (*WritingIntoCRsHasEffectTest) Run added in v0.6.0

Run - implements Test interface

Jump to

Keyboard shortcuts

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