reaper

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReaperConfig

func NewReaperConfig(resources []*reaperconfig.ResourceConfig, schedule, projectID, uuid string) *reaperconfig.ReaperConfig

NewReaperConfig constructs a new ReaperConfig.

func NewResourceConfig

func NewResourceConfig(resourceType reaperconfig.ResourceType, zones []string, nameFilter, skipFilter, ttl string) *reaperconfig.ResourceConfig

NewResourceConfig constructs a new ResourceConfig.

Types

type Clock

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

func (*Clock) Now

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

type Reaper

type Reaper struct {
	UUID      string
	ProjectID string
	Watchlist []*resources.WatchedResource
	Schedule  cron.Schedule

	*Clock
	// contains filtered or unexported fields
}

Reaper represents the resource reaper for a single GCP project. The reaper will run on a given schedule defined in cron time format.

func NewReaper

func NewReaper() *Reaper

NewReaper constructs a new reaper.

func (*Reaper) FreezeClock

func (reaper *Reaper) FreezeClock(instant time.Time)

func (*Reaper) FreezeTime

func (reaper *Reaper) FreezeTime(instant time.Time)

FreezeTime is a helper method for freezing the clocks of all resources in a reaper's Watchlist to a given instant.

func (*Reaper) GetResources

func (reaper *Reaper) GetResources(ctx context.Context, clientOptions ...option.ClientOption)

GetResources gets all the GCP resources defined in the ReaperConfig, and adds them to the reaper's Watchlist. Note, if the same resource is referenced by multiple ResourceConfigs, then the TTL of that resource will be the one that deletes the resource the latest.

func (*Reaper) RunOnSchedule

func (reaper *Reaper) RunOnSchedule(ctx context.Context, clientOptions ...option.ClientOption) bool

RunOnSchedule updates the reaper's watchlist and runs a sweep if the current time is equal to or after the next schedule run time.

func (*Reaper) SweepThroughResources

func (reaper *Reaper) SweepThroughResources(ctx context.Context, clientOptions ...option.ClientOption)

SweepThroughResources goes through all the resources in the reaper's Watchlist, and for each resource determines if it needs to be deleted. The necessary resources are deleted from GCP and the reaper's Watchlist is updated accordingly.

func (*Reaper) UpdateReaperConfig

func (reaper *Reaper) UpdateReaperConfig(config *reaperconfig.ReaperConfig) error

UpdateReaperConfig updates the reaper from a given ReaperConfig proto.

func (*Reaper) WatchlistString

func (reaper *Reaper) WatchlistString() string

WatchlistString returns a near sting of the reaper's Watchlist.

Jump to

Keyboard shortcuts

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