Documentation ¶
Index ¶
- Constants
- type FailedAccessingDirError
- type FailedReadingFileError
- type FailedScanningResource
- type FileProcessingError
- func (e *FileProcessingError) DocumentID() (int, error)
- func (e *FileProcessingError) Error() error
- func (e *FileProcessingError) File() string
- func (e *FileProcessingError) IsFatal() bool
- func (e *FileProcessingError) IsSevere() bool
- func (e *FileProcessingError) LineNo() int
- func (e *FileProcessingError) Location() string
- type K8sObject
- type MalformedYamlDocError
- type NoK8sNetworkPolicyResourcesFoundError
- type NoK8sResourcesFoundError
- type NoK8sWorkloadResourcesFoundError
- type NoYamlsFoundError
- type NotK8sResourceError
- type ResourcesScanner
- func (sc *ResourcesScanner) FilesToObjectsList(path string) ([]K8sObject, []FileProcessingError)
- func (sc *ResourcesScanner) FilesToObjectsListFiltered(path string, podNames []types.NamespacedName) ([]K8sObject, []FileProcessingError)
- func (sc *ResourcesScanner) GetYAMLDocumentsFromPath(repoDir string) ([]YAMLDocumentIntf, []FileProcessingError)
- func (sc *ResourcesScanner) YAMLDocumentsToObjectsList(documents []YAMLDocumentIntf) ([]K8sObject, []FileProcessingError)
- type WalkFunction
- type YAMLDocumentIntf
Constants ¶
const ( Networkpolicy string = "NetworkPolicy" Namespace string = "Namespace" Pod string = "Pod" ReplicaSet string = "ReplicaSet" ReplicationController string = "ReplicationController" Deployment string = "Deployment" Statefulset string = "StatefulSet" Daemonset string = "DaemonSet" Job string = "Job" CronJob string = "CronJob" List string = "List" NamespaceList string = "NamespaceList" PodList string = "PodList" )
relevant K8s resource kinds as string values
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FailedAccessingDirError ¶
type FailedAccessingDirError struct {
// contains filtered or unexported fields
}
func (*FailedAccessingDirError) Error ¶
func (err *FailedAccessingDirError) Error() string
func (*FailedAccessingDirError) Unwrap ¶
func (err *FailedAccessingDirError) Unwrap() error
type FailedReadingFileError ¶
type FailedReadingFileError struct {
// contains filtered or unexported fields
}
func (*FailedReadingFileError) Error ¶
func (err *FailedReadingFileError) Error() string
func (*FailedReadingFileError) Unwrap ¶
func (err *FailedReadingFileError) Unwrap() error
type FailedScanningResource ¶
type FailedScanningResource struct {
// contains filtered or unexported fields
}
func (*FailedScanningResource) Error ¶
func (err *FailedScanningResource) Error() string
func (*FailedScanningResource) Unwrap ¶
func (err *FailedScanningResource) Unwrap() error
type FileProcessingError ¶
type FileProcessingError struct {
// contains filtered or unexported fields
}
FileProcessingError holds all information about a single error/warning that occurred during the discovery and processing of the connectivity of a given K8s-app.
func (*FileProcessingError) DocumentID ¶
func (e *FileProcessingError) DocumentID() (int, error)
DocumentID returns the file's YAML document ID (0-based) in which the error occurred (or an error if not applicable)
func (*FileProcessingError) Error ¶
func (e *FileProcessingError) Error() error
Error returns the actual error
func (*FileProcessingError) File ¶
func (e *FileProcessingError) File() string
File returns the file in which the error occurred (or an empty string if no file context is available)
func (*FileProcessingError) IsFatal ¶
func (e *FileProcessingError) IsFatal() bool
IsFatal returns whether the error is considered fatal (no further processing is possible)
func (*FileProcessingError) IsSevere ¶
func (e *FileProcessingError) IsSevere() bool
IsSevere returns whether the error is considered severe (further processing is possible, but results may not be useable)
func (*FileProcessingError) LineNo ¶
func (e *FileProcessingError) LineNo() int
LineNo returns the file's line-number in which the error occurred (or 0 if not applicable)
func (*FileProcessingError) Location ¶
func (e *FileProcessingError) Location() string
Location returns file location (filename, line-number, document ID) of an error (or an empty string if not applicable)
type K8sObject ¶
type K8sObject struct { Kind string // namespace object Namespace *v1.Namespace // netpol object Networkpolicy *netv1.NetworkPolicy // pod object Pod *v1.Pod // workload object Replicaset *appsv1.ReplicaSet Deployment *appsv1.Deployment Statefulset *appsv1.StatefulSet ReplicationController *v1.ReplicationController Job *batchv1.Job CronJob *batchv1.CronJob Daemonset *appsv1.DaemonSet }
K8sObject holds a an object kind and a pointer of the relevant object
type MalformedYamlDocError ¶
type MalformedYamlDocError struct {
// contains filtered or unexported fields
}
func (*MalformedYamlDocError) Error ¶
func (err *MalformedYamlDocError) Error() string
func (*MalformedYamlDocError) Unwrap ¶
func (err *MalformedYamlDocError) Unwrap() error
type NoK8sNetworkPolicyResourcesFoundError ¶ added in v0.1.3
type NoK8sNetworkPolicyResourcesFoundError struct { }
func (*NoK8sNetworkPolicyResourcesFoundError) Error ¶ added in v0.1.3
func (err *NoK8sNetworkPolicyResourcesFoundError) Error() string
type NoK8sResourcesFoundError ¶
type NoK8sResourcesFoundError struct { }
func (*NoK8sResourcesFoundError) Error ¶
func (err *NoK8sResourcesFoundError) Error() string
type NoK8sWorkloadResourcesFoundError ¶ added in v0.1.3
type NoK8sWorkloadResourcesFoundError struct { }
func (*NoK8sWorkloadResourcesFoundError) Error ¶ added in v0.1.3
func (err *NoK8sWorkloadResourcesFoundError) Error() string
type NoYamlsFoundError ¶
type NoYamlsFoundError struct { }
func (*NoYamlsFoundError) Error ¶
func (err *NoYamlsFoundError) Error() string
type NotK8sResourceError ¶
type NotK8sResourceError struct {
// contains filtered or unexported fields
}
func (*NotK8sResourceError) Error ¶
func (err *NotK8sResourceError) Error() string
func (*NotK8sResourceError) Unwrap ¶
func (err *NotK8sResourceError) Unwrap() error
type ResourcesScanner ¶
type ResourcesScanner struct {
// contains filtered or unexported fields
}
func NewResourcesScanner ¶
func NewResourcesScanner(l logger.Logger, stopOnError bool, walkFn WalkFunction) *ResourcesScanner
func (*ResourcesScanner) FilesToObjectsList ¶
func (sc *ResourcesScanner) FilesToObjectsList(path string) ([]K8sObject, []FileProcessingError)
FilesToObjectsList returns a list of K8sObject parsed from yaml files in the input dir path
func (*ResourcesScanner) FilesToObjectsListFiltered ¶
func (sc *ResourcesScanner) FilesToObjectsListFiltered(path string, podNames []types.NamespacedName) ([]K8sObject, []FileProcessingError)
FilesToObjectsListFiltered returns only K8sObjects from dir path if they match input pods namespaces (for non pod resources) and full input pods names for pod resources
func (*ResourcesScanner) GetYAMLDocumentsFromPath ¶
func (sc *ResourcesScanner) GetYAMLDocumentsFromPath(repoDir string) ([]YAMLDocumentIntf, []FileProcessingError)
GetYAMLDocumentsFromPath returns a list of YAML documents from input dir path
func (*ResourcesScanner) YAMLDocumentsToObjectsList ¶
func (sc *ResourcesScanner) YAMLDocumentsToObjectsList(documents []YAMLDocumentIntf) ([]K8sObject, []FileProcessingError)
YAMLDocumentsToObjectsList returns a list of K8sObject parsed from input YAML documents
type WalkFunction ¶
type WalkFunction func(root string, fn fs.WalkDirFunc) error
Walk function is a function for recursively scanning a directory, in the spirit of Go's native filepath.WalkDir() See https://pkg.go.dev/path/filepath#WalkDir for full description on how such file should work
type YAMLDocumentIntf ¶
type YAMLDocumentIntf interface { // Content is the string content of the YAML doc Content() string // FilePath is the file path containing the YAML doc FilePath() string // DocID is the document ID of the YAML doc within the file DocID() int }
YAMLDocumentIntf is an interface for holding YAML document