files

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: UPL-1.0 Imports: 12 Imported by: 0

Documentation

Overview

Package files handles searching

Package files handles searching

Index

Constants

This section is empty.

Variables

View Source
var ZeroTime = metav1.NewTime(time.Time{})

Functions

func ExtractTimeIfPresent added in v0.14.0

func ExtractTimeIfPresent(inputText string) metav1.Time

ExtractTimeIfPresent determines if the text matches a known pattern which has a timestamp in it (such as known log formats) and will extract the timestamp into a wrappered metav1.Time. If there is no timestamp found it will return a zero time value

func FindFileInClusterRoot

func FindFileInClusterRoot(clusterRoot string, filename string) string

FindFileInClusterRoot will find filename in the cluster root

func FindFileInNamespace

func FindFileInNamespace(clusterRoot string, namespace string, filename string) string

FindFileNameInNamespace will find filename in the namespace

func FindNamespaces

func FindNamespaces(log *zap.SugaredLogger, clusterRoot string) (namespaces []string, err error)

FindNamespaces relies on the directory structure of the cluster-dump/namespaces to determine the namespaces that were found in the dump. It will return the namespace only here and not the entire path.

func FindPodLogFileName

func FindPodLogFileName(clusterRoot string, pod corev1.Pod) string

FindPodLogFileName will find the name of the log file given a pod

func GetMatchingDirectories

func GetMatchingDirectories(log *zap.SugaredLogger, rootDirectory string, fileMatchRe *regexp.Regexp) (fileMatches []string, err error)

GetMatchingDirectories returns the filenames for directories that match a regular expression.

func GetMatchingFiles

func GetMatchingFiles(log *zap.SugaredLogger, rootDirectory string, fileMatchRe *regexp.Regexp) (fileMatches []string, err error)

GetMatchingFiles returns the filenames for files that match a regular expression.

func IsInTimeRange added in v0.14.0

func IsInTimeRange(timeToCheck metav1.Time, timeRange *TimeRange) bool

IsInTimeRange will check if a specified time is within the specified range It will return true if:

  • there is no time range specified
  • a time range is specified and the time specified is in that range (see TimeRange type)

Otherwise it will return false:

  • if the time is zero and there is a range specified, it can't determine it
  • if the time is not within the range specified

Types

type TextMatch

type TextMatch struct {
	FileName    string
	FileLine    int
	Timestamp   metav1.Time
	MatchedText string
}

TextMatch supplies information about the matched text

func FindFilesAndSearch

func FindFilesAndSearch(log *zap.SugaredLogger, rootDirectory string, fileMatchRe *regexp.Regexp, searchMatchRe *regexp.Regexp, timeRange *TimeRange) (matches []TextMatch, err error)

FindFilesAndSearch will search across files that match a specified expression

func SearchFile

func SearchFile(log *zap.SugaredLogger, fileName string, searchMatchRe *regexp.Regexp, timeRange *TimeRange) (matches []TextMatch, err error)

SearchFile search a file

func SearchFiles

func SearchFiles(log *zap.SugaredLogger, rootDirectory string, files []string, searchMatchRe *regexp.Regexp, timeRange *TimeRange) (matches []TextMatch, err error)

SearchFiles will search the list of files that are already known for text that matches

func SearchMatches

func SearchMatches(log *zap.SugaredLogger, matchesToSearch []TextMatch, searchMatchRe *regexp.Regexp) (matches []TextMatch, err error)

SearchMatches will search the list of TextMatch using a search expression and will return all that match

type TimeRange added in v0.14.0

type TimeRange struct {
	StartTime metav1.Time
	EndTime   metav1.Time
}

TimeRange is used when searching requires time bounded matches Handling of a TimeRange:

if not specified, match is included
if StartTime is supplied (not zero) matches at/after that time are included
if EndTime is supplied (not zero) matches at/before that time are included

Jump to

Keyboard shortcuts

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