Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayKindNode ¶
type ArrayKindNode struct { NodeData // contains filtered or unexported fields }
ArrayKindNode represents resource tree node of types reflect.Kind.Array and reflect.Kind.Slice
func (*ArrayKindNode) GetData ¶
func (a *ArrayKindNode) GetData() NodeData
GetData returns node data
type BasicTypeKindNode ¶
type BasicTypeKindNode struct { NodeData // contains filtered or unexported fields }
BasicTypeKindNode represents resource tree node of basic types like int, float, etc.
func (*BasicTypeKindNode) GetData ¶
func (b *BasicTypeKindNode) GetData() NodeData
GetData returns node data
type FieldRules ¶
FieldRules encapsulates all the field level rules defined by a repo.
func (*FieldRules) Apply ¶
func (f *FieldRules) Apply(fieldName string) bool
Apply runs all the rules defined by a repo against a field.
type NodeData ¶
type NodeData struct { // Represents the Name of the field e.g. field name inside the struct. Field string // Reference back to the resource tree. Required for cross-tree traversal(connected nodes traversal) Tree *ResourceTree // Required as type information is not available during tree traversal. FieldType reflect.Type // Path in the resource tree reaching this node. NodePath string // Link back to parent. Parent NodeInterface // Child nodes are keyed using field names(nodeData.field). Children map[string]NodeInterface // Storing this as an additional field because type-analysis determines the value, // which gets used later in value-evaluation LeafNode bool Covered bool }
NodeData is the data stored in each node of the resource tree.
type NodeInterface ¶
type NodeInterface interface { GetData() NodeData // contains filtered or unexported methods }
NodeInterface defines methods that can be performed on each node in the resource tree.
type NodeRules ¶
type NodeRules struct {
Rules []func(nodeInterface NodeInterface) bool
}
NodeRules encapsulates all the node level rules defined by a repo.
func (*NodeRules) Apply ¶
func (n *NodeRules) Apply(node NodeInterface) bool
Apply runs all the rules defined by a repo against a node.
type OtherKindNode ¶
type OtherKindNode struct {
NodeData
}
OtherKindNode represents nodes in the resource tree of types like maps, interfaces, etc
func (*OtherKindNode) GetData ¶
func (o *OtherKindNode) GetData() NodeData
GetData returns node data
type PtrKindNode ¶
type PtrKindNode struct { NodeData // contains filtered or unexported fields }
PtrKindNode represents nodes in the resource tree of type reflect.Kind.Ptr, reflect.Kind.UnsafePointer, etc.
type ResourceForest ¶
type ResourceForest struct { Version string // Key is ResourceTree.ResourceName TopLevelTrees map[string]ResourceTree // Head of the linked list keyed by nodeData.fieldType.pkg + nodeData.fieldType.Name() ConnectedNodes map[string]*list.List }
ResourceForest represents the top-level forest that contains individual resource trees for top-level resource types and all connected nodes across resource trees.
func (*ResourceForest) AddResourceTree ¶
func (r *ResourceForest) AddResourceTree(resourceName string, resourceType reflect.Type)
AddResourceTree adds a resource tree to the resource forest.
type ResourceTree ¶
type ResourceTree struct { ResourceName string Root NodeInterface Forest *ResourceForest }
ResourceTree encapsulates a tree corresponding to a resource type.
func (*ResourceTree) BuildCoverageData ¶
func (r *ResourceTree) BuildCoverageData(nodeRules NodeRules, fieldRules FieldRules, ignoredFields coveragecalculator.IgnoredFields) []coveragecalculator.TypeCoverage
BuildCoverageData calculates the coverage information for a resource tree by applying provided Node and Field rules.
func (*ResourceTree) BuildResourceTree ¶
func (r *ResourceTree) BuildResourceTree(t reflect.Type)
BuildResourceTree builds a resource tree by calling into analyzeType method starting from root.
func (*ResourceTree) UpdateCoverage ¶
func (r *ResourceTree) UpdateCoverage(v reflect.Value)
UpdateCoverage updates coverage data in the resource tree based on the provided reflect.Value
type StructKindNode ¶
type StructKindNode struct {
NodeData
}
StructKindNode represents nodes in the resource tree of type reflect.Kind.Struct
func (*StructKindNode) GetData ¶
func (s *StructKindNode) GetData() NodeData
GetData returns node data
type TimeTypeNode ¶
type TimeTypeNode struct {
NodeData
}
TimeTypeNode is a node type that encapsulates fields that are internally time based. E.g metav1.ObjectMeta.CreationTimestamp or metav1.ObjectMeta.DeletionTimestamp. These are internally of type metav1.Time which use standard time type, but their values are specified as timestamp strings with parsing logic to create time objects. For use-case we only care if the value is set, so we create TimeTypeNodes and mark them as leafnodes.