Documentation ¶
Overview ¶
Package nuke provides the framework for scanning for resources and then iterating over said resources to determine if they should be removed or not and in what order.
Index ¶
- type INuke
- type ListCache
- type Nuke
- func (n *Nuke) Filter(item *queue.Item) error
- func (n *Nuke) HandleQueue(ctx context.Context)
- func (n *Nuke) HandleRemove(ctx context.Context, item *queue.Item)
- func (n *Nuke) HandleWait(ctx context.Context, item *queue.Item, cache ListCache)
- func (n *Nuke) HandleWaitDependency(ctx context.Context, item *queue.Item)
- func (n *Nuke) Prompt() error
- func (n *Nuke) RegisterPrompt(prompt func() error)
- func (n *Nuke) RegisterResourceTypes(scope registry.Scope, resourceTypes ...string)
- func (n *Nuke) RegisterScanner(scope registry.Scope, instance *scanner.Scanner) error
- func (n *Nuke) RegisterValidateHandler(handler func() error)
- func (n *Nuke) RegisterVersion(version string)
- func (n *Nuke) Run(ctx context.Context) error
- func (n *Nuke) Scan(ctx context.Context) error
- func (n *Nuke) SetLogger(logger *logrus.Entry)
- func (n *Nuke) SetRunSleep(duration time.Duration)
- func (n *Nuke) Validate() error
- func (n *Nuke) Version()
- type Parameters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Nuke ¶
type Nuke struct { Parameters *Parameters // Parameters is a collection of common variables used to configure the before of the Nuke instance. Filters filter.Filters // Filters is the collection of filters that will be used to filter resources Settings *libsettings.Settings // Settings is the collection of settings that will be used to control resource behavior ValidateHandlers []func() error ResourceTypes map[registry.Scope]types.Collection Scanners map[registry.Scope][]*scanner.Scanner Queue *queue.Queue // Queue is the queue of resources that will be processed // contains filtered or unexported fields }
Nuke is the main struct for the library. It is used to register resource types, scanners, filters and validation handlers.
func New ¶
func New(params *Parameters, filters filter.Filters, settings *libsettings.Settings) *Nuke
New returns an instance of nuke that is properly configured for initial use
func (*Nuke) Filter ¶
Filter is used to filter resources. It will run the filters that were registered with the instance of Nuke and set the state of the resource to filtered if it matches the filter.
func (*Nuke) HandleQueue ¶
HandleQueue is used to handle the queue of resources. It will iterate over the queue and trigger the appropriate handlers based on the state of the resource.
func (*Nuke) HandleRemove ¶
HandleRemove is used to handle the removal of a resource. It will remove the resource and set the state of the resource to pending if it was successful or failed if it was not.
func (*Nuke) HandleWait ¶
HandleWait is used to handle the waiting of a resource. It will check if the resource has been removed. If it has, it will set the state of the resource to finished. If it has not, it will set the state of the resource to waiting.
func (*Nuke) HandleWaitDependency ¶
HandleWaitDependency is used to handle the waiting of a resource. It will check if the resource has any dependencies and if it does, it will check if the dependencies have been removed. If they have, it will trigger the remove handler.
func (*Nuke) RegisterPrompt ¶
RegisterPrompt is used to register the prompt function that used to prompt the user for input, usually to confirm if the nuke process should continue or not.
func (*Nuke) RegisterResourceTypes ¶
RegisterResourceTypes is used to register resource types against a scope. A scope is a string that is used to group resource types together. For example, you could have a scope of "aws" and register all AWS resource types. For Azure, you have to register resources by tenant or subscription or even resource group.
func (*Nuke) RegisterScanner ¶
RegisterScanner is used to register a scanner against a scope. A scope is a string that is used to group resource types together. A scanner is what is responsible for actually querying the API for resources and adding them to the queue for processing.
func (*Nuke) RegisterValidateHandler ¶
RegisterValidateHandler allows the tool instantiating the library to register a validation handler. It is optional.
func (*Nuke) RegisterVersion ¶
RegisterVersion allows the tool instantiating the library to register its version so there's consist output of the version information across all tools. It is optional.
func (*Nuke) Run ¶
Run is the main entry point for the library. It will run the validation handlers, prompt the user, scan for resources, filter them and then process them.
func (*Nuke) Scan ¶
Scan is used to scan for resources. It will run the scanners that were registered with the library by the invoking tool. It will also filter the resources based on the filters that were registered. It will also print the current status of the resources.
func (*Nuke) SetLogger ¶
SetLogger allows the tool instantiating the library to set the logger that is used for the library. It is optional.
func (*Nuke) SetRunSleep ¶
SetRunSleep allows the tool instantiating the library to set the sleep duration between runs of the queue. It is optional.
type Parameters ¶
type Parameters struct { NoDryRun bool // NoDryRun instructs Run to actually perform the remove function Force bool // Force instructs Run to proceed without confirmation from user ForceSleep int // ForceSleep indicates how long of a delay before proceeding with confirmation Quiet bool // Quiet will hide resources if they have been filtered MaxWaitRetries int // MaxWaitRetries is the total number of times a resource will be retried during wait state // WaitOnDependencies controls whether resources will be removed after their dependencies. It is important to note // that it does not currently track direct dependencies but instead dependent resources. For example if ResourceA // depends on ResourceB, all ResourceB has to be in a completed state (removed or failed) before ResourceA will be // processed WaitOnDependencies bool // Includes is a list of resource types that are to be included during the nuke process. If a resource type is // listed in both the Includes and Excludes fields then the Excludes field will take precedence. Includes []string // Excludes is a list of resource types that are to be excluded during the nuke process. If a resource type is // listed in both the Includes and Excludes fields then the Excludes field will take precedence. Excludes []string // Alternatives is a list of resource types that are to be used instead of the default resource. The primary use // case for this is AWS Cloud Control API resources. Alternatives []string }
Parameters is a collection of common variables used to configure the before of the Nuke instance.