cleanerupper

package module
v0.0.0-...-def9dbb Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Package cleanerupper provides a library of functions to delete gcp resources in a project matching the given deletion policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDisks

func CleanDisks(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanDisks deletes all disks indicated, returning a slice of deleted partial urls and a slice of encountered errors. On dry run, returns what would have been deleted.

func CleanGuestPolicies

func CleanGuestPolicies(ctx context.Context, clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanGuestPolicies deletes all guest policies indicated, returning a slice of deleted policy names and a slice of encountered errors. On dry run, returns what would have been deleted.

func CleanImages

func CleanImages(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanImages deletes all images indicated, returning a slice of deleted partial urls and a slice of encountered errors. On dry run, returns what would have been deleted.

func CleanInstances

func CleanInstances(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanInstances deletes all instances indicated, returning a slice of deleted instance partial URLs and a slice of errors encountered. On dry run, returns what would have been deleted.

func CleanMachineImages

func CleanMachineImages(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanMachineImages deletes all machine images indicated, returning a slice of deleted partial urls and a slice of encountered errors. On dry run, returns what would have been deleted.

func CleanNetworks

func CleanNetworks(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanNetworks deletes all networks indicated, as well as all subnetworks and firewall rules that are part of the network indicated for deleted. Returns a slice of deleted partial urls and a slice of encountered errors. On dry run, returns what would have been deleted.

func CleanOSPolicyAssignments

func CleanOSPolicyAssignments(ctx context.Context, clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanOSPolicyAssignments deletes all OS policy assignments indicated, returning a slice of deleted policy assignment names and a slice of encountered errors. On dry run, returns what would have been deleted.

func CleanSnapshots

func CleanSnapshots(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)

CleanSnapshots deletes all snapshots indicated, returning a slice of deleted partial urls and a slice of encountered errors. On dry run, returns what would have been deleted.

Types

type Clients

type Clients struct {
	Daisy         daisyCompute.Client
	OSConfig      osconfigInterface
	OSConfigZonal osconfigZonalInterface
}

Clients contains all of the clients needed by cleanerupper functions.

func NewClients

func NewClients(ctx context.Context, opts ...option.ClientOption) (*Clients, error)

NewClients initializes a struct of Clients for use by CleanX functions

type PolicyFunc

type PolicyFunc func(any) bool

PolicyFunc describes a function which takes a some resource and returns a bool indicating whether it should be deleted.

func AgePolicy

func AgePolicy(t time.Time) PolicyFunc

AgePolicy takes a time.Time and returns a PolicyFunc which indicates to delete anything older than the given time. Also contains safeguards such as refusing to delete default networks or resources with a "do-not-delete" label.

func WorkflowPolicy

func WorkflowPolicy(id string) PolicyFunc

WorkflowPolicy takes a daisy workflow ID and returns a PolicyFunc which indicates to delete anything which appears to have been created by this workflow. Note that daisy does have its own resource deletion hooks, this is used in edge cases where workflow deletion hooks are unreliable. Also contains safeguards such as refusing to delete default networks or resources with a "do-not-delete" label.

Jump to

Keyboard shortcuts

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