manifestcomparators

package
v0.0.0-...-573763d Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTestsInDirForComparator

func AllTestsInDirForComparator(comparator CRDComparator, directory string) ([]*simpleComparatorTest, error)

func AllTestsInDirForComparators

func AllTestsInDirForComparators(comparators []CRDComparator, directory string) ([]*simpleComparatorTest, error)

func AllTestsInDirForRegistry

func AllTestsInDirForRegistry(registry CRDComparatorRegistry, directory string) ([]*simpleComparatorTest, error)

func GetVersionByName

GetVersionByName can be nil if the version doesn't exist

func RunAllTestsInDirForComparator

func RunAllTestsInDirForComparator(t *testing.T, comparator CRDComparator, directory string)

func RunAllTestsInDirForComparators

func RunAllTestsInDirForComparators(t *testing.T, comparators []CRDComparator, directory string)

func RunAllTestsInDirForRegistry

func RunAllTestsInDirForRegistry(t *testing.T, registry CRDComparatorRegistry, directory string)

func SchemaHas

func SchemaHas(s *apiextensionsv1.JSONSchemaProps, fldPath, simpleLocation *field.Path, ancestry []*apiextensionsv1.JSONSchemaProps, pred SchemaWalkerFunc) bool

SchemaHas recursively traverses the Schema and calls the `pred` predicate to see if the schema contains specific values.

The predicate MUST NOT keep a copy of the json schema NOR modify the schema.

Types

type CRDComparator

type CRDComparator interface {
	Name() string
	WhyItMatters() string
	Compare(existingCRD, newCRD *apiextensionsv1.CustomResourceDefinition) (ComparisonResults, error)
}

func ConditionsMustHaveProperSSATags

func ConditionsMustHaveProperSSATags() CRDComparator

func ListsMustHaveSSATags

func ListsMustHaveSSATags() CRDComparator

func MustHaveStatus

func MustHaveStatus() CRDComparator

func MustNotExceedCostBudget

func MustNotExceedCostBudget() CRDComparator

func NoBools

func NoBools() CRDComparator

func NoEnumRemoval

func NoEnumRemoval() CRDComparator

func NoFieldRemoval

func NoFieldRemoval() CRDComparator

func NoFloats

func NoFloats() CRDComparator

func NoMaps

func NoMaps() CRDComparator

func NoNewRequiredFields

func NoNewRequiredFields() CRDComparator

func NoUints

func NoUints() CRDComparator

type CRDComparatorRegistry

type CRDComparatorRegistry interface {
	AddComparator(comparator CRDComparator) error
	GetComparator(name string) (CRDComparator, error)

	KnownComparators() []string
	AllComparators() []CRDComparator

	Compare(existingCRD, newCRD *apiextensionsv1.CustomResourceDefinition, names ...string) ([]ComparisonResults, []error)
}

func NewRegistry

func NewRegistry() CRDComparatorRegistry

type ComparatorTest

type ComparatorTest struct {
	Name        string
	ExistingCRD *apiextensionsv1.CustomResourceDefinition
	NewCRD      *apiextensionsv1.CustomResourceDefinition

	ExpectedResults []ComparisonResults
	ExpectedErrors  []string
}

ComparatorTest represents the directory style test we have.

func AllTestsInDir

func AllTestsInDir(directory string) ([]ComparatorTest, error)

func TestInDir

func TestInDir(testName, directory string) (ComparatorTest, error)

func (*ComparatorTest) Test

func (tc *ComparatorTest) Test(t *testing.T, actualResults []ComparisonResults, actualErrors []error)

type ComparisonResults

type ComparisonResults struct {
	Name         string `yaml:"name"`
	WhyItMatters string `yaml:"whyItMatters"`

	Errors   []string `yaml:"errors"`
	Warnings []string `yaml:"warnings"`
	Infos    []string `yaml:"infos"`
}

func RatchetCompare

func RatchetCompare(validator SingleCRDValidator, existingCRD, newCRD *apiextensionsv1.CustomResourceDefinition) (ComparisonResults, error)

type ComparisonResultsList

type ComparisonResultsList struct {
	Items []ComparisonResults `yaml:"items"`
}

type SchemaWalkerFunc

type SchemaWalkerFunc func(s *apiextensionsv1.JSONSchemaProps, fldPath, simpleLocation *field.Path, ancestry []*apiextensionsv1.JSONSchemaProps) bool

ancestry is an order list of ancestors of s, where index 0 is the root and index len-1 is the direct parent

type SingleCRDValidator

type SingleCRDValidator interface {
	Validate(crd *apiextensionsv1.CustomResourceDefinition) (ComparisonResults, error)
}

Jump to

Keyboard shortcuts

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