resources

package
v0.0.0-...-60cae77 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldAddResourceToWatchlist

func ShouldAddResourceToWatchlist(resource *Resource, nameFilter, skipFilter string) bool

ShouldAddResourceToWatchlist determines whether a Resource should be watched by checking if its name matches the skip filter or name filter regex from the ResourceConfig and ReaperConfig. If a resource matches both the skip filter and name filter, then the skip filter wins and the resource will NOT be watched. An empty string for the skip filter will be interpreted as unset, and therefore will not match any resources.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is a mock struct for handling time dependency for tests.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the either time frozen time that was set for testing purposes, or the current time.

type Resource

type Resource struct {
	Name        string
	Zone        string
	TimeCreated time.Time
	Type        reaperconfig.ResourceType
}

A Resource represents a single GCP resource instance of any type supported by the Reaper.

func NewResource

func NewResource(name, zone string, timeCreated time.Time, resourceType reaperconfig.ResourceType) *Resource

NewResource constructs a Resource struct.

func (*Resource) TimeAlive

func (resource *Resource) TimeAlive() float64

TimeAlive returns how long a resource has been running.

type WatchedResource

type WatchedResource struct {
	*Resource
	TTL string
	// contains filtered or unexported fields
}

WatchedResource represents a resource that the Reaper is monitoring.

func CreateWatchlist

func CreateWatchlist(resources []*Resource, ttl string) []*WatchedResource

CreateWatchlist creates a list of WatchedResources with a given time to live (TTL).

func NewWatchedResource

func NewWatchedResource(resource *Resource, ttl string) *WatchedResource

NewWatchedResource constructs a WatchedResource.

func (*WatchedResource) FreezeClock

func (resource *WatchedResource) FreezeClock(instant time.Time)

FreezeClock sets the clock's current time to instant. This is to be used during testing.

func (*WatchedResource) GetDeletionTime

func (resource *WatchedResource) GetDeletionTime() (time.Time, error)

func (*WatchedResource) IsReadyForDeletion

func (resource *WatchedResource) IsReadyForDeletion() bool

IsReadyForDeletion returns if a WatchedResource is past its time to live (TTL) based of the current time of the Clock.

Jump to

Keyboard shortcuts

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