Documentation ¶
Index ¶
- Constants
- Variables
- func HttpCommand(c *RunCommand) *httpCommand
- func KVStore(store map[string]interface{}) *kvStore
- func Off() bool
- func On() bool
- func RunAlways() *runAlways
- func StoreCommand(s BucketStorageCondition) *storeCommand
- func StoreCommandCondition(s BucketStorage, c RunCondition) *storeCommand
- type Bucket
- type BucketStorage
- type BucketStorageCondition
- type IDMapper
- type Interface
- type RunCommand
- func Command() *RunCommand
- func WithAction(given *RunCommand, action RunCommandAction) (updated *RunCommand)
- func WithCategory(given *RunCommand, category RunCommandCategory) (updated *RunCommand)
- func WithData(given *RunCommand, name string, d RunCommandData) (updated *RunCommand)
- func WithSelect(given *RunCommand, paths []string) (updated *RunCommand)
- func (c *RunCommand) AddError(err error) (u *RunCommand)
- func (c *RunCommand) CreateAction() (u *RunCommand)
- func (c *RunCommand) DeleteAction() (u *RunCommand)
- func (c *RunCommand) Enable(p RunPredicate) (u *RunCommand)
- func (c *RunCommand) GetAction() (u *RunCommand)
- func (c *RunCommand) IsRun() bool
- func (c *RunCommand) ListAction() (u *RunCommand)
- func (c *RunCommand) PatchAction() (u *RunCommand)
- func (c *RunCommand) PostAction() (u *RunCommand)
- func (c *RunCommand) PutAction() (u *RunCommand)
- func (c *RunCommand) Result(result interface{}) (r RunCommandResult)
- func (c *RunCommand) Run() (r RunCommandResult)
- func (c *RunCommand) SelfInfo() (me string)
- func (c *RunCommand) String() string
- func (c *RunCommand) UpdateAction() (u *RunCommand)
- type RunCommandAction
- type RunCommandCategory
- type RunCommandCategoryList
- func (l RunCommandCategoryList) Contains(given RunCommandCategory) (no bool)
- func (l RunCommandCategoryList) IsCstorSnapshot() (no bool)
- func (l RunCommandCategoryList) IsCstorVolume() (no bool)
- func (l RunCommandCategoryList) IsEmpty() (empty bool)
- func (l RunCommandCategoryList) IsHttpReq() (no bool)
- func (l RunCommandCategoryList) IsJivaVolume() (no bool)
- func (l RunCommandCategoryList) IsValid() (no bool)
- func (l RunCommandCategoryList) String() string
- type RunCommandData
- type RunCommandDataMap
- type RunCommandMiddleware
- type RunCommandMiddlewareList
- type RunCommandResult
- type RunCondition
- type RunPredicate
- type Runner
- type SelectPathAliasDelimiter
- type SelectPaths
- type Storage
- type StoreKey
Constants ¶
const ( // SkipExecutionMessage will skip run command execution SkipExecutionMessage string = "will skip run command execution" )
Variables ¶
var ( ErrorNotSupportedCategory = errors.New("not supported category: invalid run command") ErrorNotSupportedAction = errors.New("not supported action: invalid run command") ErrorInvalidCategory = errors.New("invalid categories: invalid run command") ErrorEmptyCategory = errors.New("missing categories: invalid run command") )
These represents error messages
var ( // ErrorCanNotRunDueToFailedCondition is an error object that indicates that command could not be executed due to failed condition. ErrorCanNotRunDueToFailedCondition = errors.New("run condition failed: can not execute run command") )
Functions ¶
func HttpCommand ¶
func HttpCommand(c *RunCommand) *httpCommand
HttpCommand returns a new instance of httpCommand
func KVStore ¶
func KVStore(store map[string]interface{}) *kvStore
KVStore returns a new instance of kvStore
func StoreCommand ¶
func StoreCommand(s BucketStorageCondition) *storeCommand
StoreCommand returns a new instance of storeCommand
func StoreCommandCondition ¶
func StoreCommandCondition(s BucketStorage, c RunCondition) *storeCommand
StoreCommandCondition returns a new instance of storeCommand
Types ¶
type BucketStorage ¶
BucketStorage abstracts storing one or more run command results into buckets
type BucketStorageCondition ¶
type BucketStorageCondition interface { BucketStorage RunCondition }
BucketStorageCondition abstracts saving of run command results and also abstracts the evaluation of whether the run command should get executed or skipped in the first place
type IDMapper ¶
type IDMapper interface { ID() string Map(id string, r *RunCommand) }
IDMapper abstracts mapping of a RunCommand instance against an id
type Interface ¶
type Interface interface { IDMapper Runner RunCondition }
Interface abstracts execution run command
type RunCommand ¶
type RunCommand struct { ID string // uniquely identifies a run command WillRun bool // flags if this run command should get executed or not Action RunCommandAction // represents the run command's action Category RunCommandCategoryList // classification of run command Data RunCommandDataMap // input data required to execute run command Selects SelectPaths // paths whose values will be retrieved after run command execution *msg.Msgs // store and retrieve info, warns, errors, etc occurred during execution }
RunCommand represent a run command
func WithAction ¶
func WithAction(given *RunCommand, action RunCommandAction) (updated *RunCommand)
WithAction updates the given RunCommand instance with provided action
func WithCategory ¶
func WithCategory(given *RunCommand, category RunCommandCategory) (updated *RunCommand)
WithCategory updates the given RunCommand instance with provided category
func WithData ¶
func WithData(given *RunCommand, name string, d RunCommandData) (updated *RunCommand)
WithData updates the given RunCommand instance with provided input data
func WithSelect ¶
func WithSelect(given *RunCommand, paths []string) (updated *RunCommand)
WithSelect updates the given RunCommand instance with provided select paths
func (*RunCommand) AddError ¶
func (c *RunCommand) AddError(err error) (u *RunCommand)
AddError updates RunCommand instance with given error
func (*RunCommand) CreateAction ¶
func (c *RunCommand) CreateAction() (u *RunCommand)
CreateAction updates RunCommand instance with create action
func (*RunCommand) DeleteAction ¶
func (c *RunCommand) DeleteAction() (u *RunCommand)
DeleteAction updates RunCommand instance with delete action
func (*RunCommand) Enable ¶
func (c *RunCommand) Enable(p RunPredicate) (u *RunCommand)
Enable enables or disables execution of RunCommand instance based on the outcome of given predicate
func (*RunCommand) GetAction ¶
func (c *RunCommand) GetAction() (u *RunCommand)
GetAction updates RunCommand instance with get action
func (*RunCommand) IsRun ¶
func (c *RunCommand) IsRun() bool
IsRun flags if this run command will get executed or not
func (*RunCommand) ListAction ¶
func (c *RunCommand) ListAction() (u *RunCommand)
ListAction updates RunCommand instance with list action
func (*RunCommand) PatchAction ¶
func (c *RunCommand) PatchAction() (u *RunCommand)
PatchAction updates RunCommand instance with patch action
func (*RunCommand) PostAction ¶
func (c *RunCommand) PostAction() (u *RunCommand)
PostAction updates RunCommand instance with post action
func (*RunCommand) PutAction ¶
func (c *RunCommand) PutAction() (u *RunCommand)
PutAction updates RunCommand instance with put action
func (*RunCommand) Result ¶
func (c *RunCommand) Result(result interface{}) (r RunCommandResult)
Result is the name of method on RunCommand
func (*RunCommand) Run ¶
func (c *RunCommand) Run() (r RunCommandResult)
Run finds the specific run command implementation and executes the same
func (*RunCommand) SelfInfo ¶
func (c *RunCommand) SelfInfo() (me string)
SelfInfo returns this instance of RunCommand as a string format
func (*RunCommand) String ¶
func (c *RunCommand) String() string
func (*RunCommand) UpdateAction ¶
func (c *RunCommand) UpdateAction() (u *RunCommand)
UpdateAction updates RunCommand instance with update action
type RunCommandAction ¶
type RunCommandAction string
RunCommandAction determines the kind of action that gets executed by run task command
const ( // DeleteCommandAction represents a run command as a delete action DeleteCommandAction RunCommandAction = "delete" // CreateCommandAction represents a run command as a create action CreateCommandAction RunCommandAction = "create" // PostCommandAction represents a run command as a post action PostCommandAction RunCommandAction = "post" // GetCommandAction represents a run command as a get action GetCommandAction RunCommandAction = "get" // ListCommandAction represents a run command as a list action ListCommandAction RunCommandAction = "list" // PatchCommandAction represents a run command as a patch action PatchCommandAction RunCommandAction = "patch" // UpdateCommandAction represents a run command as a update action UpdateCommandAction RunCommandAction = "update" // PutCommandAction represents a run command as a put action PutCommandAction RunCommandAction = "put" )
type RunCommandCategory ¶
type RunCommandCategory string
RunCommandCategory represents the category of the run command. It helps in determining the exact entity or feature this run command is targeting.
NOTE:
A run command can have more than one categories to determine an entity
const ( // JivaCommandCategory categorises the run command as jiva based JivaCommandCategory RunCommandCategory = "jiva" // CstorCommandCategory categorises the run command as cstor based CstorCommandCategory RunCommandCategory = "cstor" // VolumeCommandCategory categorises the run command as volume based VolumeCommandCategory RunCommandCategory = "volume" // PoolCommandCategory categorises the run command as pool based PoolCommandCategory RunCommandCategory = "pool" // HttpCommandCategory categorises the run command as http based HttpCommandCategory RunCommandCategory = "http" // SnapshotCommandCategory categorises the run command as snapshot based SnapshotCommandCategory RunCommandCategory = "snapshot" )
type RunCommandCategoryList ¶
type RunCommandCategoryList []RunCommandCategory
RunCommandCategoryList represents a list of RunCommandCategory
func (RunCommandCategoryList) Contains ¶
func (l RunCommandCategoryList) Contains(given RunCommandCategory) (no bool)
Contains returns true if this list has the given category
func (RunCommandCategoryList) IsCstorSnapshot ¶
func (l RunCommandCategoryList) IsCstorSnapshot() (no bool)
IsCstorSnapshot returns true if this list has both cstor and snapshot as its category items
func (RunCommandCategoryList) IsCstorVolume ¶
func (l RunCommandCategoryList) IsCstorVolume() (no bool)
IsCstorVolume returns true if this list has both cstor and volume as its category items
func (RunCommandCategoryList) IsEmpty ¶
func (l RunCommandCategoryList) IsEmpty() (empty bool)
IsEmpty returns true if no category is set
func (RunCommandCategoryList) IsHttpReq ¶
func (l RunCommandCategoryList) IsHttpReq() (no bool)
IsHttpReq returns true if this list points to a http based request
func (RunCommandCategoryList) IsJivaVolume ¶
func (l RunCommandCategoryList) IsJivaVolume() (no bool)
IsJivaVolume returns true if this list has both jiva and volume as its category items
func (RunCommandCategoryList) IsValid ¶
func (l RunCommandCategoryList) IsValid() (no bool)
IsValid returns true if category list is valid
TODO Move volume specific validations to volume command file
func (RunCommandCategoryList) String ¶
func (l RunCommandCategoryList) String() string
String implements Stringer interface
type RunCommandData ¶
type RunCommandData interface{}
RunCommandData represents data provided to the run command before its execution i.e. input data
type RunCommandDataMap ¶
type RunCommandDataMap map[string]RunCommandData
RunCommandDataMap represents a map of input data required to execute run command
func (RunCommandDataMap) String ¶
func (m RunCommandDataMap) String() string
String implements Stringer interface
type RunCommandMiddleware ¶
type RunCommandMiddleware func(given *RunCommand) (updated *RunCommand)
RunCommandMiddleware abstracts updating the given RunCommand instance
func CstorCategory ¶
func CstorCategory() RunCommandMiddleware
CstorCategory updates RunCommand instance with cstor as the run command's category
func HttpCategory ¶
func HttpCategory() RunCommandMiddleware
HttpCategory updates RunCommand instance with http as the run command's category
func JivaCategory ¶
func JivaCategory() RunCommandMiddleware
JivaCategory updates RunCommand instance with jiva as the run command's category
func Select ¶
func Select(paths []string) RunCommandMiddleware
Select updates the RunCommand instance with paths whose values will be extracted after execution of run command
func SnapshotCategory ¶
func SnapshotCategory() RunCommandMiddleware
SnapshotCategory updates RunCommand instance with snapshot as the runtask command's category
func VolumeCategory ¶
func VolumeCategory() RunCommandMiddleware
VolumeCategory updates RunCommand instance with volume as the run command's category
type RunCommandMiddlewareList ¶
type RunCommandMiddlewareList []RunCommandMiddleware
RunCommandMiddlewareList represents a list of RunCommandMiddleware
func (RunCommandMiddlewareList) Update ¶
func (l RunCommandMiddlewareList) Update(given *RunCommand) (updated *RunCommand)
Update updates the given RunCommand instance through all the middlewares
type RunCommandResult ¶
type RunCommandResult struct { Res interface{} `json:"result"` // result of run command execution Err error `json:"error"` // root cause of issue; error if any during run command execution Extras msg.AllMsgs `json:"debug,omitempty"` // debug details i.e. errors, warnings, information, etc during execution }
RunCommandResult holds the result and execution info of a run command
func NewRunCommandResult ¶
func NewRunCommandResult(result interface{}, extras msg.AllMsgs) (r RunCommandResult)
NewRunCommandResult returns a new RunCommandResult struct
func (RunCommandResult) Debug ¶
func (r RunCommandResult) Debug() msg.AllMsgs
Debug returns the debug info gathered during execution of run command's result
func (RunCommandResult) Error ¶
func (r RunCommandResult) Error() error
Error returns the error if any from the run command's result
func (RunCommandResult) GoString ¶
func (r RunCommandResult) GoString() string
GoString implements GoStringer interface
func (RunCommandResult) Result ¶
func (r RunCommandResult) Result() interface{}
Result returns the expected output if any from the run command's result
func (RunCommandResult) String ¶
func (r RunCommandResult) String() string
String implements Stringer interface
type RunCondition ¶
RunCondition abstracts evaluating the condition to run or skip executing a run command
type RunPredicate ¶
type RunPredicate func() bool
RunPredicate abstracts evaluation of executing or skipping execution of a runner instance
type Runner ¶
type Runner interface {
Run() (r RunCommandResult)
}
Runner abstracts execution of command
type SelectPathAliasDelimiter ¶
type SelectPathAliasDelimiter string
SelectPathAliasDelimiter is used to delimit a select path from its alias
e.g.
".metadata.namespace as namespace" implies - '.metadata.namespace' is the path - ' as ' is the delimiter - 'namespace' is the alias
const ( // AsSelectDelimiter represents " as " as the delimiter AsSelectDelimiter SelectPathAliasDelimiter = " as " )
type SelectPaths ¶
type SelectPaths []string
SelectPaths holds all the select paths specified in a run command
func (SelectPaths) QueryCommandResult ¶
func (s SelectPaths) QueryCommandResult(r RunCommandResult) (u RunCommandResult)
QueryCommandResult queries the run command's result based on the select paths
func (SelectPaths) String ¶
func (s SelectPaths) String() (str string)
String implements Stringer interface
type Storage ¶
type Storage interface {
Store(key StoreKey, data interface{})
}
Storage abstracts saving run command results
type StoreKey ¶
type StoreKey string
StoreKey represents supported keys to store run command's execution results
const ( // ResultStoreKey stores the run commands results ResultStoreKey StoreKey = "result" //DebugStoreKey stores the debug results DebugStoreKey StoreKey = "debug" //ErrorStoreKey stores the errors after the run command ErrorStoreKey StoreKey = "error" //RootCauseStoreKey stores the rootCause of the errors RootCauseStoreKey StoreKey = "rootCause" )