calculate

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagNameID       = "id"
	FlagNameIndexTag = "index-tag"
)

Variables

This section is empty.

Functions

func AddCalculateFlags

func AddCalculateFlags(flagSet *flag.FlagSet, commandFlags map[string]interface{})

AddCalculateFlags returns the flags required to calculate a resource's index in the order:

id: The ID of the resource
index tag: The index tag to filter the resource group using
random sleep: The maximum random number of seconds to sleep before calculating the index

func FetchAndCalculateResourceIndex

func FetchAndCalculateResourceIndex(commandFlags map[string]interface{}) (int, error)

func GetNewResourceIndex

func GetNewResourceIndex(
	resourceID *string,
	indexTag *string,
	resources []*types.InfraResource) (int, error)

GetNewResourceIndex calculates the new index for the resource with the ID specified in resourceID. An error will be returned if:

  • No resource with the ID specified in resourceID is found in resourceMap
  • The new index is not different from the current index of the resource

Types

type Calculate

type Calculate struct {
	// contains filtered or unexported fields
}

Calculate determines whether a resource needs a new index. Exit codes are:

	0 - If the resource needs a new index (proposed index is returned)
 1 - If a command execution error occurs
 2 - If a command processing error occurs (e.g if an unavailable flag is provided by the user)
 3 - If the resource doesn't need a new index (whatever index it has right now is just fine)

func (*Calculate) GetDescription

func (calculate *Calculate) GetDescription() string

GetDescription returns the description for the calculate command

func (*Calculate) GetFlagSet

func (calculate *Calculate) GetFlagSet() *flag.FlagSet

GetFlagSet returns a pointer to the flag.FlagSet associated to the command

func (*Calculate) GetHelpFlag

func (calculate *Calculate) GetHelpFlag() *bool

GetHelpFlag returns a pointer to the initialized help flag for the command

func (*Calculate) GetName

func (calculate *Calculate) GetName() string

GetName returns the value of the name constant

func (*Calculate) GetSubCommands

func (calculate *Calculate) GetSubCommands() []cli.Command

GetSubCommands returns a slice of subcommands under the calculate command (expect empty slice if none)

func (*Calculate) Init

func (calculate *Calculate) Init(helpFlagName string, helpFlagDescription string)

Init initializes the command object

func (*Calculate) Process

func (calculate *Calculate) Process()

Process calculates whether a resource needs to be assigned a new index and sends the index to configured notification channels or exit with an exit code 3 if the resource doesn't need to be assigned a new index

Jump to

Keyboard shortcuts

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