rules

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadRules

func LoadRules() error

LoadRules loads exclude rules into memory. It is abstracted as a different function because at the time of calling init, config values have not been loaded yet

func ParseRule

func ParseRule(rule Rule) error

ParseRule Get the rule to use for a particular condition

func ShouldInitiateDestruction

func ShouldInitiateDestruction(tags resource.Tags) bool

ShouldInitiateDestruction checks if the tags to initiate destruction are valid at the time of execution

func ShouldInitiateResumption

func ShouldInitiateResumption(tag resource.Tags) bool

ShouldInitiateResumption checks if the tags to initiate destruction are valid at the time of execution

func ShouldInitiateStopping

func ShouldInitiateStopping(tag resource.Tags) bool

ShouldInitiateStopping checks if the tags to initiate destruction are valid at the time of execution

Types

type Action

type Action int

Action : The Action to be applied to the resources matching a particular rule

const (
	DoNothing Action = iota
	Stop
	Resume
	Destroy
)

func ActionString

func ActionString(s string) (Action, error)

ActionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ActionValues

func ActionValues() []Action

ActionValues returns all values of the enum

func GetResourceAction

func GetResourceAction(res *resource.Resource) Action

GetResourceAction get action to be performed on a resource

func (Action) IsAAction

func (i Action) IsAAction() bool

IsAAction returns "true" if the value is listed in the enum definition. "false" otherwise

func (Action) String

func (i Action) String() string

type ActiveDurationRule

type ActiveDurationRule struct {
	*Rule
	StartTime time.Time
	StopTime  time.Time
}

ActiveDurationRule defines the period within which a resource should be active. Any time Outside the duration, the resource is stopped and resumed again when period is active

func (ActiveDurationRule) CheckResource

func (r ActiveDurationRule) CheckResource(res *resource.Resource) Action

CheckResource Returns a list of resources activeDuration is valid

type Rule

type Rule struct {
	*config.Rule
}

Rule that can be defined for resources

type Ruler

type Ruler interface {
	CheckResource(*resource.Resource) Action
	String() string
	// contains filtered or unexported methods
}

Ruler interface for all rules

func GetRules

func GetRules() []Ruler

GetRules : Return an array of created Rules

type TerminationDateRule

type TerminationDateRule struct {
	*Rule
	Date time.Time
}

TerminationDateRule defines rule that sets when a resource should be terminated based on termination-date rule set in config file. This rule checks if the set termination-date is past and activates destroy on the instance

func (TerminationDateRule) CheckResource

func (r TerminationDateRule) CheckResource(res *resource.Resource) Action

CheckResource Returns a list of resources whose termination Date is exceeed

type TerminationPolicyRule

type TerminationPolicyRule struct {
	*Rule
	Policy string
}

TerminationPolicyRule defines rule that sets when a resource should be terminated.

func (TerminationPolicyRule) CheckResource

func (r TerminationPolicyRule) CheckResource(res *resource.Resource) Action

CheckResource Returns a list of resources whose termination Date is exceeed

Jump to

Keyboard shortcuts

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