Documentation
¶
Index ¶
- type AutoCollector
- type CollectorSource
- type CollectorSpec
- type CollectorType
- type Discoverer
- func (d *Discoverer) AugmentWithFoundational(ctx context.Context, yamlCollectors []CollectorSpec, opts DiscoveryOptions) ([]CollectorSpec, error)
- func (d *Discoverer) DiscoverFoundational(ctx context.Context, opts DiscoveryOptions) ([]CollectorSpec, error)
- func (d *Discoverer) ValidatePermissions(ctx context.Context, resources []Resource) ([]Resource, error)
- type DiscoveryOptions
- type ExpansionContext
- type ExpansionRule
- type FoundationalCollectors
- type NamespaceInfo
- type NamespaceScanner
- func (ns *NamespaceScanner) FilterNamespacesByLabel(ctx context.Context, namespaces []string, labelSelector string) ([]string, error)
- func (ns *NamespaceScanner) GetNamespacesByResourceActivity(ctx context.Context, opts ScanOptions) ([]NamespaceInfo, error)
- func (ns *NamespaceScanner) GetTargetNamespaces(ctx context.Context, requestedNamespaces []string, opts ScanOptions) ([]string, error)
- func (ns *NamespaceScanner) ScanNamespaces(ctx context.Context, opts ScanOptions) ([]NamespaceInfo, error)
- type RBACChecker
- func (r *RBACChecker) CheckBulkPermissions(ctx context.Context, resources []Resource) (map[string]bool, error)
- func (r *RBACChecker) CheckPermission(ctx context.Context, resource Resource) (bool, error)
- func (r *RBACChecker) FilterByPermissions(ctx context.Context, resources []Resource) ([]Resource, error)
- type Resource
- type ResourceCount
- type ResourceExpander
- func (re *ResourceExpander) DeduplicateCollectors(collectors []CollectorSpec) []CollectorSpec
- func (re *ResourceExpander) ExpandToCollectors(ctx context.Context, namespaces []string, opts DiscoveryOptions) ([]CollectorSpec, error)
- func (re *ResourceExpander) FilterCollectorsByNamespace(collectors []CollectorSpec, targetNamespaces []string) []CollectorSpec
- func (re *ResourceExpander) GetCollectorPriority(collectorType CollectorType) int
- func (re *ResourceExpander) GetCollectorTypesForNamespace(namespace string, opts DiscoveryOptions) []CollectorType
- func (re *ResourceExpander) GetRequiredPermissions(collectorType CollectorType) []ResourcePermission
- func (re *ResourceExpander) RegisterRule(collectorType CollectorType, rule ExpansionRule)
- func (re *ResourceExpander) ValidateCollectorDependencies(collectors []CollectorSpec) error
- type ResourcePermission
- type ScanOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoCollector ¶
type AutoCollector interface {
// DiscoverFoundational discovers foundational collectors based on cluster state (Path 1)
DiscoverFoundational(ctx context.Context, opts DiscoveryOptions) ([]CollectorSpec, error)
// AugmentWithFoundational augments existing YAML collectors with foundational collectors (Path 2)
AugmentWithFoundational(ctx context.Context, yamlCollectors []CollectorSpec, opts DiscoveryOptions) ([]CollectorSpec, error)
// ValidatePermissions validates RBAC permissions for discovered resources
ValidatePermissions(ctx context.Context, resources []Resource) ([]Resource, error)
}
AutoCollector defines the interface for automatic collector discovery
type CollectorSource ¶
type CollectorSource string
CollectorSource indicates the origin of a collector
const ( SourceFoundational CollectorSource = "foundational" SourceYAML CollectorSource = "yaml" SourceAugmented CollectorSource = "augmented" )
type CollectorSpec ¶
type CollectorSpec struct {
// Type of collector (logs, clusterResources, secret, etc.)
Type CollectorType
// Name of the collector for identification
Name string
// Namespace for namespaced resources
Namespace string
// Spec contains the actual collector configuration
Spec interface{}
// Priority for deduplication (higher wins)
Priority int
// Source indicates where this collector came from (foundational, yaml, etc.)
Source CollectorSource
}
CollectorSpec represents a collector specification that can be converted to troubleshootv1beta2.Collect
func (CollectorSpec) GetUniqueKey ¶
func (c CollectorSpec) GetUniqueKey() string
GetUniqueKey returns a unique identifier for deduplication
func (CollectorSpec) ToTroubleshootCollect ¶
func (c CollectorSpec) ToTroubleshootCollect() (*troubleshootv1beta2.Collect, error)
ToTroubleshootCollect converts a CollectorSpec to a troubleshootv1beta2.Collect
type CollectorType ¶
type CollectorType string
CollectorType represents the type of data being collected
const ( CollectorTypePods CollectorType = "pods" CollectorTypeDeployments CollectorType = "deployments" CollectorTypeServices CollectorType = "services" CollectorTypeConfigMaps CollectorType = "configmaps" CollectorTypeSecrets CollectorType = "secrets" CollectorTypeEvents CollectorType = "events" CollectorTypeLogs CollectorType = "logs" CollectorTypeClusterInfo CollectorType = "clusterInfo" CollectorTypeClusterResources CollectorType = "clusterResources" CollectorTypeImageFacts CollectorType = "imageFacts" )
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer implements the AutoCollector interface
func NewDiscoverer ¶
func NewDiscoverer(clientConfig *rest.Config, client kubernetes.Interface) (*Discoverer, error)
NewDiscoverer creates a new autodiscovery discoverer
func (*Discoverer) AugmentWithFoundational ¶
func (d *Discoverer) AugmentWithFoundational(ctx context.Context, yamlCollectors []CollectorSpec, opts DiscoveryOptions) ([]CollectorSpec, error)
AugmentWithFoundational augments existing YAML collectors with foundational collectors (Path 2)
func (*Discoverer) DiscoverFoundational ¶
func (d *Discoverer) DiscoverFoundational(ctx context.Context, opts DiscoveryOptions) ([]CollectorSpec, error)
DiscoverFoundational discovers foundational collectors based on cluster state (Path 1)
func (*Discoverer) ValidatePermissions ¶
func (d *Discoverer) ValidatePermissions(ctx context.Context, resources []Resource) ([]Resource, error)
ValidatePermissions validates RBAC permissions for discovered resources
type DiscoveryOptions ¶
type DiscoveryOptions struct {
// Target namespaces for discovery (empty = all accessible namespaces)
Namespaces []string
// Include container image metadata collection
IncludeImages bool
// Perform RBAC permission checking
RBACCheck bool
// Maximum discovery depth for resource relationships
MaxDepth int
// Path 1: Only collect foundational data
FoundationalOnly bool
// Path 2: Add foundational to existing YAML specs
AugmentMode bool
// Timeout for discovery operations
Timeout time.Duration
}
DiscoveryOptions configures the autodiscovery behavior
type ExpansionContext ¶
type ExpansionContext struct {
Namespace string
Options DiscoveryOptions
Resources []Resource
Metadata map[string]interface{}
}
ExpansionContext provides context for resource expansion
type ExpansionRule ¶
type ExpansionRule struct {
// CollectorType is the type of collector this rule creates
CollectorType CollectorType
// Priority determines the order of collectors (higher = more important)
Priority int
// RequiredPermissions lists the RBAC permissions needed
RequiredPermissions []ResourcePermission
// ExpansionFunc creates the actual collector spec
ExpansionFunc func(context.Context, ExpansionContext) ([]CollectorSpec, error)
// Dependencies lists other collector types this depends on
Dependencies []CollectorType
}
ExpansionRule defines how a resource type should be expanded into collectors
type FoundationalCollectors ¶
type FoundationalCollectors struct {
// Core Kubernetes resources always collected
Pods []CollectorSpec
Deployments []CollectorSpec
Services []CollectorSpec
ConfigMaps []CollectorSpec
Secrets []CollectorSpec
Events []CollectorSpec
Logs []CollectorSpec
ClusterInfo []CollectorSpec
ClusterResources []CollectorSpec
// Container image metadata
ImageFacts []CollectorSpec
}
FoundationalCollectors represents the set of collectors that are always included
type NamespaceInfo ¶
type NamespaceInfo struct {
Name string
Labels map[string]string
// IsSystem indicates if this is a system namespace
IsSystem bool
// ResourceCount provides counts of key resources in the namespace
ResourceCount ResourceCount
}
NamespaceInfo contains information about a discovered namespace
type NamespaceScanner ¶
type NamespaceScanner struct {
// contains filtered or unexported fields
}
NamespaceScanner handles namespace discovery and filtering
func NewNamespaceScanner ¶
func NewNamespaceScanner(client kubernetes.Interface) *NamespaceScanner
NewNamespaceScanner creates a new namespace scanner
func (*NamespaceScanner) FilterNamespacesByLabel ¶
func (ns *NamespaceScanner) FilterNamespacesByLabel(ctx context.Context, namespaces []string, labelSelector string) ([]string, error)
FilterNamespacesByLabel filters namespaces using a label selector
func (*NamespaceScanner) GetNamespacesByResourceActivity ¶
func (ns *NamespaceScanner) GetNamespacesByResourceActivity(ctx context.Context, opts ScanOptions) ([]NamespaceInfo, error)
GetNamespacesByResourceActivity returns namespaces sorted by resource activity
func (*NamespaceScanner) GetTargetNamespaces ¶
func (ns *NamespaceScanner) GetTargetNamespaces(ctx context.Context, requestedNamespaces []string, opts ScanOptions) ([]string, error)
GetTargetNamespaces returns a list of namespace names to target for collection
func (*NamespaceScanner) ScanNamespaces ¶
func (ns *NamespaceScanner) ScanNamespaces(ctx context.Context, opts ScanOptions) ([]NamespaceInfo, error)
ScanNamespaces discovers and returns information about accessible namespaces
type RBACChecker ¶
type RBACChecker struct {
// contains filtered or unexported fields
}
RBACChecker handles RBAC permission validation
func NewRBACChecker ¶
func NewRBACChecker(client kubernetes.Interface) (*RBACChecker, error)
NewRBACChecker creates a new RBAC checker
func (*RBACChecker) CheckBulkPermissions ¶
func (r *RBACChecker) CheckBulkPermissions(ctx context.Context, resources []Resource) (map[string]bool, error)
CheckBulkPermissions checks multiple permissions efficiently using batch operations
func (*RBACChecker) CheckPermission ¶
CheckPermission checks if the current user has permission to access a specific resource
func (*RBACChecker) FilterByPermissions ¶
func (r *RBACChecker) FilterByPermissions(ctx context.Context, resources []Resource) ([]Resource, error)
FilterByPermissions filters resources based on RBAC permissions
type ResourceCount ¶
ResourceCount tracks resource counts in a namespace
type ResourceExpander ¶
type ResourceExpander struct {
// contains filtered or unexported fields
}
ResourceExpander handles converting discovered resources to collector specifications
func NewResourceExpander ¶
func NewResourceExpander() *ResourceExpander
NewResourceExpander creates a new resource expander with default rules
func (*ResourceExpander) DeduplicateCollectors ¶
func (re *ResourceExpander) DeduplicateCollectors(collectors []CollectorSpec) []CollectorSpec
DeduplicateCollectors removes duplicate collectors based on their unique key
func (*ResourceExpander) ExpandToCollectors ¶
func (re *ResourceExpander) ExpandToCollectors(ctx context.Context, namespaces []string, opts DiscoveryOptions) ([]CollectorSpec, error)
ExpandToCollectors converts discovered resources to collector specifications
func (*ResourceExpander) FilterCollectorsByNamespace ¶
func (re *ResourceExpander) FilterCollectorsByNamespace(collectors []CollectorSpec, targetNamespaces []string) []CollectorSpec
FilterCollectorsByNamespace filters collectors to only include those for specified namespaces
func (*ResourceExpander) GetCollectorPriority ¶
func (re *ResourceExpander) GetCollectorPriority(collectorType CollectorType) int
GetCollectorPriority returns the priority for a collector type
func (*ResourceExpander) GetCollectorTypesForNamespace ¶
func (re *ResourceExpander) GetCollectorTypesForNamespace(namespace string, opts DiscoveryOptions) []CollectorType
GetCollectorTypesForNamespace returns the collector types that should be generated for a namespace
func (*ResourceExpander) GetRequiredPermissions ¶
func (re *ResourceExpander) GetRequiredPermissions(collectorType CollectorType) []ResourcePermission
GetRequiredPermissions returns the RBAC permissions required for a collector type
func (*ResourceExpander) RegisterRule ¶
func (re *ResourceExpander) RegisterRule(collectorType CollectorType, rule ExpansionRule)
RegisterRule registers a new expansion rule
func (*ResourceExpander) ValidateCollectorDependencies ¶
func (re *ResourceExpander) ValidateCollectorDependencies(collectors []CollectorSpec) error
ValidateCollectorDependencies ensures all collector dependencies are satisfied
type ResourcePermission ¶
type ResourcePermission struct {
APIVersion string
Kind string
Verbs []string // get, list, watch, etc.
}
ResourcePermission represents a required RBAC permission
type ScanOptions ¶
type ScanOptions struct {
// IncludePatterns are glob patterns for namespaces to include
IncludePatterns []string
// ExcludePatterns are glob patterns for namespaces to exclude
ExcludePatterns []string
// LabelSelector filters namespaces by labels
LabelSelector string
// IncludeSystemNamespaces includes system namespaces like kube-system
IncludeSystemNamespaces bool
}
ScanOptions configures namespace scanning behavior