Documentation ¶
Index ¶
- func DefaultJobIsPrunable(obj client.Object) error
- func DefaultPodIsPrunable(obj client.Object) error
- func IsUnprunable(target error) bool
- func RegisterIsPrunableFunc(gvk schema.GroupVersionKind, isPrunable IsPrunableFunc)
- type IsPrunableFunc
- type Pruner
- type PrunerOption
- type Registry
- type StrategyFunc
- type Unprunable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultJobIsPrunable ¶
DefaultJobIsPrunable is a default IsPrunableFunc to be used specifically with Job resources. It marks a Job resource as prunable if it's Status.CompletionTime value is not `nil`, indicating that the Job has completed This can be overridden by registering your own IsPrunableFunc via the RegisterIsPrunableFunc method
func DefaultPodIsPrunable ¶
DefaultPodIsPrunable is a default IsPrunableFunc to be used specifically with Pod resources. It marks a Pod resource as prunable if it's Status.Phase is "Succeeded" This can be overridden by registering your own IsPrunableFunc via the RegisterIsPrunableFunc method
func IsUnprunable ¶
IsUnprunable checks if a given error is that of Unprunable. Returns true if the given error is of type Unprunable, and false if it is not
func RegisterIsPrunableFunc ¶
func RegisterIsPrunableFunc(gvk schema.GroupVersionKind, isPrunable IsPrunableFunc)
RegisterIsPrunableFunc registers a function to check whether it is safe to prune a resource of a certain type.
Types ¶
type IsPrunableFunc ¶
IsPrunableFunc is a function that checks the data of an object to see whether or not it is safe to prune it. It should return `nil` if it is safe to prune, `Unprunable` if it is unsafe, or another error. It should safely assert the object is the expected type, otherwise it might panic.
type Pruner ¶
type Pruner struct {
// contains filtered or unexported fields
}
Pruner is an object that runs a prune job.
func NewPruner ¶
func NewPruner(prunerClient client.Client, gvk schema.GroupVersionKind, strategy StrategyFunc, opts ...PrunerOption) (*Pruner, error)
NewPruner returns a pruner that uses the given strategy to prune objects that have the given GVK
func (Pruner) GVK ¶
func (p Pruner) GVK() schema.GroupVersionKind
GVK returns the schema.GroupVersionKind that the Pruner has set
func (Pruner) Labels ¶
Labels returns the labels that the Pruner is using to find resources to prune
type PrunerOption ¶
type PrunerOption func(p *Pruner)
PrunerOption configures the pruner.
func WithLabels ¶
func WithLabels(labels map[string]string) PrunerOption
WithLabels can be used to set the Labels field when configuring a Pruner
func WithNamespace ¶
func WithNamespace(namespace string) PrunerOption
WithNamespace can be used to set the Namespace field when configuring a Pruner
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is used to register a mapping of GroupVersionKind to an IsPrunableFunc
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry is a default Registry configuration
func (*Registry) IsPrunable ¶
IsPrunable checks if an object is prunable
func (*Registry) RegisterIsPrunableFunc ¶
func (r *Registry) RegisterIsPrunableFunc(gvk schema.GroupVersionKind, isPrunable IsPrunableFunc)
RegisterIsPrunableFunc registers a function to check whether it is safe to prune a resource of a certain type.
type StrategyFunc ¶
StrategyFunc takes a list of resources and returns the subset to prune.
func NewPruneByCountStrategy ¶
func NewPruneByCountStrategy(count int) StrategyFunc
NewPruneByCountStrategy returns a StrategyFunc that will return a list of resources to prune based on a maximum count of resources allowed. If the max count of resources is exceeded, the oldest resources are prioritized for pruning
func NewPruneByDateStrategy ¶
func NewPruneByDateStrategy(date time.Time) StrategyFunc
NewPruneByDateStrategy returns a StrategyFunc that will return a list of resources to prune where the resource CreationTimestamp is after the given time.Time.
type Unprunable ¶
Unprunable indicates that it is not allowed to prune a specific object.
func (*Unprunable) Error ¶
func (e *Unprunable) Error() string
Error returns a string representation of an `Unprunable` error.