Documentation ¶
Index ¶
- func NewReaperConfig(resources []*reaperconfig.ResourceConfig, schedule, projectID, uuid string) *reaperconfig.ReaperConfig
- func NewResourceConfig(resourceType reaperconfig.ResourceType, zones []string, ...) *reaperconfig.ResourceConfig
- type Clock
- type Reaper
- func (reaper *Reaper) FreezeClock(instant time.Time)
- func (reaper *Reaper) FreezeTime(instant time.Time)
- func (reaper *Reaper) GetResources(ctx context.Context, clientOptions ...option.ClientOption)
- func (reaper *Reaper) RunOnSchedule(ctx context.Context, clientOptions ...option.ClientOption) bool
- func (reaper *Reaper) SweepThroughResources(ctx context.Context, clientOptions ...option.ClientOption)
- func (reaper *Reaper) UpdateReaperConfig(config *reaperconfig.ReaperConfig) error
- func (reaper *Reaper) WatchlistString() string
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 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 (*Reaper) FreezeClock ¶
func (*Reaper) FreezeTime ¶
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 ¶
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 ¶
WatchlistString returns a near sting of the reaper's Watchlist.