Documentation ¶
Overview ¶
Package cleanerupper provides a library of functions to delete gcp resources in a project matching the given deletion policy.
Index ¶
- func CleanDisks(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)
- func CleanGuestPolicies(ctx context.Context, clients Clients, project string, delete PolicyFunc, ...) ([]string, []error)
- func CleanImages(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)
- func CleanInstances(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)
- func CleanMachineImages(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)
- func CleanNetworks(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)
- func CleanOSPolicyAssignments(ctx context.Context, clients Clients, project string, delete PolicyFunc, ...) ([]string, []error)
- func CleanSnapshots(clients Clients, project string, delete PolicyFunc, dryRun bool) ([]string, []error)
- type Clients
- type PolicyFunc
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 ¶
NewClients initializes a struct of Clients for use by CleanX functions
type PolicyFunc ¶
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.