Documentation
¶
Index ¶
- func InitializeClient(ctx context.Context, l logr.Logger, c client.Client, numOfWorker int)
- type CollectMethod
- type CollectionType
- type Collector
- func (d *Collector) CleanOldCollections(storage, requestorName string, collectionType CollectionType, limit int32, ...) error
- func (d *Collector) CleanupEntries(storage, requestorName string, collectionType CollectionType) error
- func (d *Collector) Collect(ctx context.Context, requestorName string, collectionType CollectionType, ...) error
- func (d *Collector) DumpObject(resource client.Object, logPath string, logger logr.Logger) error
- func (d *Collector) DumpPodLogs(ctx context.Context, clientSet *kubernetes.Clientset, logPath string, ...) error
- func (d *Collector) GetClusterResources(folder, kind string, logger logr.Logger) ([]*unstructured.Unstructured, error)
- func (d *Collector) GetFolder(storage, requestorName string, collectionType CollectionType, ...) (*string, error)
- func (d *Collector) GetFolderPath(storage, requestorName string, collectionType CollectionType, t time.Time) string
- func (d *Collector) GetNamespacedResources(folder, kind string, logger logr.Logger) (map[string][]*unstructured.Unstructured, error)
- func (d *Collector) GetResult(ctx context.Context, requestorName string, collectionType CollectionType) Result
- func (d *Collector) GetUnstructured(object []byte) (*unstructured.Unstructured, error)
- func (d *Collector) IsInProgress(requestorName string, collectionType CollectionType) bool
- func (d *Collector) ListCollections(storage, requestorName string, collectionType CollectionType, ...) ([]string, error)
- func (d *Collector) TarDir(src string, logger logr.Logger) error
- type CollectorInterface
- type Result
- type ResultStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CollectMethod ¶
type Collector ¶
Collector represents a client implementing the CollectorInterface
func GetClient ¶
func GetClient() *Collector
GetClient return a collector client, implementing the CollectorInterface
func (*Collector) CleanOldCollections ¶
func (*Collector) CleanupEntries ¶
func (d *Collector) CleanupEntries(storage, requestorName string, collectionType CollectionType) error
func (*Collector) Collect ¶
func (d *Collector) Collect(ctx context.Context, requestorName string, collectionType CollectionType, collectMethd CollectMethod) error
func (*Collector) DumpObject ¶
DumpObject is a helper function to generically dump resource definition given the resource reference and file path for dumping location.
func (*Collector) DumpPodLogs ¶
func (d *Collector) DumpPodLogs(ctx context.Context, clientSet *kubernetes.Clientset, logPath string, since *int64, pod *corev1.Pod) error
DumpPodLogs collects logs for all containers in a pod and store them. If pod has restarted, it will try to collect log from previous run as well.
func (*Collector) GetClusterResources ¶
func (d *Collector) GetClusterResources(folder, kind string, logger logr.Logger, ) ([]*unstructured.Unstructured, error)
func (*Collector) GetFolderPath ¶
func (*Collector) GetNamespacedResources ¶
func (d *Collector) GetNamespacedResources(folder, kind string, logger logr.Logger, ) (map[string][]*unstructured.Unstructured, error)
func (*Collector) GetUnstructured ¶
func (d *Collector) GetUnstructured(object []byte) (*unstructured.Unstructured, error)
GetUnstructured returns an unstructured given a []bytes containing it
func (*Collector) IsInProgress ¶
func (d *Collector) IsInProgress(requestorName string, collectionType CollectionType) bool
func (*Collector) ListCollections ¶
type CollectorInterface ¶
type CollectorInterface interface {
// RegisterMethod registers a collection method
RegisterMethod(m CollectMethod)
// Collect creates a request to collect resources for requestorName
// When worker is available to fulfill such request, the CollectMethod registered
// will be invoked in the worker context.
// requestorName is the name of the instance making this request.
Collect(ctx context.Context, requestorName string,
collectionType CollectionType, collectMethd CollectMethod) error
// IsInProgress returns true if requestorName's request to collect is currently in progress.
IsInProgress(requestorName string, collectionType CollectionType) bool
// GetResult returns result for requestorName's request
GetResult(ctx context.Context, requestorName string, collectionType CollectionType) Result
// ListCollections returns list all collections taken for a given requestorName
ListCollections(storage, requestorName string, collectionType CollectionType,
logger logr.Logger) ([]string, error)
// GetFolderPath returns the path of folder where resources can be stored
GetFolderPath(storage, requestorName string, collectionType CollectionType) string
// GetFolder returns the artifact folder where all collections for a given
// requestorName are stored
GetFolder(storage, requestorName string, collectionType CollectionType,
logger logr.Logger) (*string, error)
// CleanupEntries removes any entry (from any internal data structure) for
// given requestorName
CleanupEntries(storage, requestorName string, collectionType CollectionType) error
// GetNamespacedResources returns all namespaced resources contained in the
// folder.
// Returns a map with:
// - key: <namespace name>
// - value: list of resources of the Kind specified
GetNamespacedResources(folder, kind string, logger logr.Logger) (map[string][]*unstructured.Unstructured, error)
// GetClusterResources returns all cluster resources contained in the folder
GetClusterResources(folder, kind string, logger logr.Logger) ([]*unstructured.Unstructured, error)
// CleanOldCollections removes old collection for requestorName. If more than limit collections
// are present, the oldest ones are remove up till there are only limit-1 collections left.
CleanOldCollections(storage, requestorName string, collectionType CollectionType,
limit int32, logger logr.Logger) error
// DumpObject is a helper function to generically dump resource definition
// given the resource reference and file path for dumping location.
DumpObject(resource client.Object, logPath string, logger logr.Logger) error
}
type Result ¶
type Result struct {
ResultStatus
Err error
}
type ResultStatus ¶
type ResultStatus int64
const ( Collected ResultStatus = iota InProgress Failed )
func (ResultStatus) String ¶
func (r ResultStatus) String() string
Click to show internal directories.
Click to hide internal directories.