Documentation ¶
Index ¶
- Variables
- func ParseSpec(specFile string) (Specs, *CheckResult)
- func ParseSpecsDir(specsDir string) (Specs, *CheckResults, error)
- func ProcessSpecs(specs *Specs)
- type ACL
- type ACLAdminXorOpsSequenceCheck
- type ACLsHaveRolesSequenceCheck
- type Arg
- type ArgsAreNamedNodeCheck
- type ArgsExpectedUniqueNodeCheck
- type ArgsNotNilNodeCheck
- type ArgsNotRenamedTwiceNodeCheck
- type BaseCheckFactory
- type CheckFactory
- type CheckResult
- type CheckResults
- type Checker
- type ConditionalHasEqNodeCheck
- type ConditionalHasIfNodeCheck
- type ConditionalNoTypeNodeCheck
- type DefaultCheckFactory
- func (c DefaultCheckFactory) MakeNodeErrorChecks() ([]NodeCheck, error)
- func (c DefaultCheckFactory) MakeNodeWarningChecks() ([]NodeCheck, error)
- func (c DefaultCheckFactory) MakeSequenceErrorChecks() ([]SequenceCheck, error)
- func (c DefaultCheckFactory) MakeSequenceWarningChecks() ([]SequenceCheck, error)
- type DuplicateValueError
- type EachElementDoesNotDuplicateArgsExpectedNodeCheck
- type EachElementUniqueNodeCheck
- type EachIfParallelNodeCheck
- type EachListDoesNotDuplicateArgsGivenNodeCheck
- type EachNotRenamedTwiceNodeCheck
- type HasCategoryNodeCheck
- type HasNodesSequenceCheck
- type InvalidValueError
- type MissingValueError
- type NoDuplicateACLRolesSequenceCheck
- type NoDuplicateArgsSequenceCheck
- type NoExtraSequenceArgsProvidedNodeCheck
- type Node
- type NodeArg
- type NodeCheck
- type NodeSet
- type NodesSetsUniqueSequenceCheck
- type NonconditionalHasTypeNodeCheck
- type NonconditionalNoEqNodeCheck
- type NonconditionalNoIfNodeCheck
- type OptionalArgsHaveDefaultsSequenceCheck
- type OptionalArgsNamedSequenceCheck
- type RequiredArgsHaveNoDefaultsSequenceCheck
- type RequiredArgsNamedSequenceCheck
- type RequiredArgsProvidedNodeCheck
- type RetryIfRetryWaitNodeCheck
- type Sequence
- type SequenceArgs
- type SequenceCheck
- type SetsAreNamedNodeCheck
- type SetsAsUniqueNodeCheck
- type SetsNotNilNodeCheck
- type SetsNotRenamedTwiceNodeCheck
- type Specs
- type StaticArgsHaveDefaultsSequenceCheck
- type StaticArgsNamedSequenceCheck
- type SubsequencesExistNodeCheck
- type ValidCategoryNodeCheck
- type ValidEachNodeCheck
- type ValidParallelNodeCheck
- type ValidRetryWaitNodeCheck
Constants ¶
This section is empty.
Variables ¶
var NoopNode = Node{
Name: "noop",
Category: &noopCategory,
NodeType: &noopNodeType,
}
Functions ¶
func ParseSpec ¶
func ParseSpec(specFile string) (Specs, *CheckResult)
Parse a single request (YAML) file.
func ParseSpecsDir ¶
func ParseSpecsDir(specsDir string) (Specs, *CheckResults, error)
Read all specs file in indicated specs directory. CheckResults are keyed on file name.
func ProcessSpecs ¶
func ProcessSpecs(specs *Specs)
Specs require some processing after we've loaded them, but before we run the checker on them. Function modifies specs passed in.
Types ¶
type ACL ¶
type ACL struct { Role string `yaml:"role"` // user-defined role Admin bool `yaml:"admin"` // all ops allowed if true Ops []string `yaml:"ops"` // proto.REQUEST_OP_* }
A single role-based ACL entry. Every auth.Caller (from the user-provided auth plugin Authenticate method) is authorized with a matching ACL, else the request is denied with HTTP 401 unauthorized. Roles are user-defined. If Admin is true, Ops cannot be set.
type ACLAdminXorOpsSequenceCheck ¶
type ACLAdminXorOpsSequenceCheck struct{}
==========================================================================
func (ACLAdminXorOpsSequenceCheck) CheckSequence ¶
func (check ACLAdminXorOpsSequenceCheck) CheckSequence(sequence Sequence) error
'admin' and 'ops' are mutually exclusive.
type ACLsHaveRolesSequenceCheck ¶
type ACLsHaveRolesSequenceCheck struct{}
==========================================================================
func (ACLsHaveRolesSequenceCheck) CheckSequence ¶
func (check ACLsHaveRolesSequenceCheck) CheckSequence(sequence Sequence) error
ACLs must specify a role.
type Arg ¶
type Arg struct { Name *string `yaml:"name"` Desc string `yaml:"desc"` Default *string `yaml:"default"` }
A sequence's args.
type ArgsAreNamedNodeCheck ¶
type ArgsAreNamedNodeCheck struct{}
==========================================================================
func (ArgsAreNamedNodeCheck) CheckNode ¶
func (check ArgsAreNamedNodeCheck) CheckNode(node Node) error
Node 'args' must be named, i.e. include an 'expected' field.
type ArgsExpectedUniqueNodeCheck ¶
type ArgsExpectedUniqueNodeCheck struct{}
==========================================================================
func (ArgsExpectedUniqueNodeCheck) CheckNode ¶
func (check ArgsExpectedUniqueNodeCheck) CheckNode(node Node) error
Args cannot be expected multiple times by one job.
type ArgsNotNilNodeCheck ¶
type ArgsNotNilNodeCheck struct{}
==========================================================================
func (ArgsNotNilNodeCheck) CheckNode ¶
func (check ArgsNotNilNodeCheck) CheckNode(node Node) error
Node 'args' must not be nil.
type ArgsNotRenamedTwiceNodeCheck ¶
type ArgsNotRenamedTwiceNodeCheck struct{}
==========================================================================
func (ArgsNotRenamedTwiceNodeCheck) CheckNode ¶
func (check ArgsNotRenamedTwiceNodeCheck) CheckNode(node Node) error
A single arg cannot be renamed and used as multiple inputs to a node.
Example of a rename:
- expected: x given: foo
- expected: y given: foo
type BaseCheckFactory ¶
type BaseCheckFactory struct {
AllSpecs Specs // All specs in specs dir
}
The absolute minimum of checks for the RM to work properly.
func (BaseCheckFactory) MakeNodeErrorChecks ¶
func (c BaseCheckFactory) MakeNodeErrorChecks() ([]NodeCheck, error)
func (BaseCheckFactory) MakeNodeWarningChecks ¶
func (c BaseCheckFactory) MakeNodeWarningChecks() ([]NodeCheck, error)
func (BaseCheckFactory) MakeSequenceErrorChecks ¶
func (c BaseCheckFactory) MakeSequenceErrorChecks() ([]SequenceCheck, error)
func (BaseCheckFactory) MakeSequenceWarningChecks ¶
func (c BaseCheckFactory) MakeSequenceWarningChecks() ([]SequenceCheck, error)
type CheckFactory ¶
type CheckFactory interface { MakeSequenceErrorChecks() ([]SequenceCheck, error) MakeSequenceWarningChecks() ([]SequenceCheck, error) MakeNodeErrorChecks() ([]NodeCheck, error) MakeNodeWarningChecks() ([]NodeCheck, error) }
Generates static checks to be performed on sequence and node specs.
Errors are mistakes in the specs that prevent the RM from functioning properly. For example, when a field specifies an invalid value. Errors can also be used to enforce reasonable conventions. For example, sequences should have nodes. Presumably, if a sequence has no nodes, this was an oversight on the writer's part. If any error occurs, the RM will fail to boot.
Warnings identify probable mistakes in the specs. For example, an arg that is renamed twice using sets/arg/as syntax. Warnings will be logged, but will not cause the RM to fail to boot.
type CheckResult ¶
type CheckResults ¶
type CheckResults struct { Results map[string]*CheckResult AnyError bool AnyWarning bool }
func NewCheckResults ¶
func NewCheckResults() *CheckResults
func (*CheckResults) AddError ¶
func (c *CheckResults) AddError(key string, err error)
func (*CheckResults) AddResult ¶
func (c *CheckResults) AddResult(key string, result *CheckResult)
func (*CheckResults) AddWarning ¶
func (c *CheckResults) AddWarning(key string, err error)
func (*CheckResults) Get ¶
func (c *CheckResults) Get(key string) (*CheckResult, bool)
func (*CheckResults) Union ¶
func (c *CheckResults) Union(other *CheckResults)
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Runs checks on sequence and node specs.
func NewChecker ¶
func NewChecker(checkFactories []CheckFactory) (*Checker, error)
Create a new Checker with the checks specified by check factories in list.
func (*Checker) RunChecks ¶
func (checker *Checker) RunChecks(allSpecs Specs) *CheckResults
Runs checks on allSpecs.
type ConditionalHasEqNodeCheck ¶
type ConditionalHasEqNodeCheck struct{}
==========================================================================
func (ConditionalHasEqNodeCheck) CheckNode ¶
func (check ConditionalHasEqNodeCheck) CheckNode(node Node) error
Conditional nodes must specify 'eq'.
type ConditionalHasIfNodeCheck ¶
type ConditionalHasIfNodeCheck struct{}
==========================================================================
func (ConditionalHasIfNodeCheck) CheckNode ¶
func (check ConditionalHasIfNodeCheck) CheckNode(node Node) error
'Conditional nodes must specify 'if'.
type ConditionalNoTypeNodeCheck ¶
type ConditionalNoTypeNodeCheck struct{}
==========================================================================
func (ConditionalNoTypeNodeCheck) CheckNode ¶
func (check ConditionalNoTypeNodeCheck) CheckNode(node Node) error
Conditional nodes may not specify a type.
type DefaultCheckFactory ¶
type DefaultCheckFactory struct {
AllSpecs Specs // All specs in specs dir
}
Some default checks. Not strictly necessary for proper operation of RM, but generally reasonable.
func (DefaultCheckFactory) MakeNodeErrorChecks ¶
func (c DefaultCheckFactory) MakeNodeErrorChecks() ([]NodeCheck, error)
func (DefaultCheckFactory) MakeNodeWarningChecks ¶
func (c DefaultCheckFactory) MakeNodeWarningChecks() ([]NodeCheck, error)
func (DefaultCheckFactory) MakeSequenceErrorChecks ¶
func (c DefaultCheckFactory) MakeSequenceErrorChecks() ([]SequenceCheck, error)
func (DefaultCheckFactory) MakeSequenceWarningChecks ¶
func (c DefaultCheckFactory) MakeSequenceWarningChecks() ([]SequenceCheck, error)
type DuplicateValueError ¶
func (DuplicateValueError) Error ¶
func (e DuplicateValueError) Error() string
type EachElementDoesNotDuplicateArgsExpectedNodeCheck ¶
type EachElementDoesNotDuplicateArgsExpectedNodeCheck struct{}
==========================================================================
func (EachElementDoesNotDuplicateArgsExpectedNodeCheck) CheckNode ¶
func (check EachElementDoesNotDuplicateArgsExpectedNodeCheck) CheckNode(node Node) error
'element' in 'each' cannot share a name as an 'expected' job arg.
type EachElementUniqueNodeCheck ¶
type EachElementUniqueNodeCheck struct{}
==========================================================================
func (EachElementUniqueNodeCheck) CheckNode ¶
func (check EachElementUniqueNodeCheck) CheckNode(node Node) error
Each cannot repeat elements.
type EachIfParallelNodeCheck ¶
type EachIfParallelNodeCheck struct{}
==========================================================================
func (EachIfParallelNodeCheck) CheckNode ¶
func (check EachIfParallelNodeCheck) CheckNode(node Node) error
If 'parallel' is set, 'each' must be set.
type EachListDoesNotDuplicateArgsGivenNodeCheck ¶
type EachListDoesNotDuplicateArgsGivenNodeCheck struct{}
==========================================================================
func (EachListDoesNotDuplicateArgsGivenNodeCheck) CheckNode ¶
func (check EachListDoesNotDuplicateArgsGivenNodeCheck) CheckNode(node Node) error
'each' cannot take a job arg as a list if it a 'given' job arg.
type EachNotRenamedTwiceNodeCheck ¶
type EachNotRenamedTwiceNodeCheck struct{}
==========================================================================
func (EachNotRenamedTwiceNodeCheck) CheckNode ¶
func (check EachNotRenamedTwiceNodeCheck) CheckNode(node Node) error
Each cannot demux its list into differently named elements.
type HasCategoryNodeCheck ¶
type HasCategoryNodeCheck struct{}
==========================================================================
func (HasCategoryNodeCheck) CheckNode ¶
func (check HasCategoryNodeCheck) CheckNode(node Node) error
Nodes must specify a category.
type HasNodesSequenceCheck ¶
type HasNodesSequenceCheck struct{}
==========================================================================
func (HasNodesSequenceCheck) CheckSequence ¶
func (check HasNodesSequenceCheck) CheckSequence(sequence Sequence) error
Sequences must contain nodes i.e. are not empty.
type InvalidValueError ¶
func (InvalidValueError) Error ¶
func (e InvalidValueError) Error() string
type MissingValueError ¶
func (MissingValueError) Error ¶
func (e MissingValueError) Error() string
type NoDuplicateACLRolesSequenceCheck ¶
type NoDuplicateACLRolesSequenceCheck struct{}
==========================================================================
func (NoDuplicateACLRolesSequenceCheck) CheckSequence ¶
func (check NoDuplicateACLRolesSequenceCheck) CheckSequence(sequence Sequence) error
ACL roles must not be duplicated.
type NoDuplicateArgsSequenceCheck ¶
type NoDuplicateArgsSequenceCheck struct{}
==========================================================================
func (NoDuplicateArgsSequenceCheck) CheckSequence ¶
func (check NoDuplicateArgsSequenceCheck) CheckSequence(sequence Sequence) error
Args should appear once per sequence.
type NoExtraSequenceArgsProvidedNodeCheck ¶
type NoExtraSequenceArgsProvidedNodeCheck struct {
AllSpecs Specs
}
==========================================================================
func (NoExtraSequenceArgsProvidedNodeCheck) CheckNode ¶
func (check NoExtraSequenceArgsProvidedNodeCheck) CheckNode(node Node) error
Sequence and conditional nodes shouldn't provide more than the specified sequence args.
type Node ¶
type Node struct { Name string `yaml:"-"` // unique name assigned to this node Category *string `yaml:"category"` // "job", "sequence", or "conditional" NodeType *string `yaml:"type"` // the type of job or sequence to create Each []string `yaml:"each"` // arguments to repeat over Args []*NodeArg `yaml:"args"` // expected arguments Parallel *uint `yaml:"parallel"` // max number of sequences to run in parallel Sets []*NodeSet `yaml:"sets"` // expected job args to be set Dependencies []string `yaml:"deps"` // nodes with out-edges leading to this node Retry uint `yaml:"retry"` // the number of times to retry a "job" that fails RetryWait string `yaml:"retryWait"` // the time to sleep between "job" retries If *string `yaml:"if"` // the name of the jobArg to check for a conditional value Eq map[string]string `yaml:"eq"` // conditional values mapping to appropriate sequence names }
Nodes in a sequence.
func (*Node) IsConditional ¶
func (*Node) IsSequence ¶
type NodeArg ¶
type NodeArg struct { Expected *string `yaml:"expected"` // the name of the argument that this job expects Given *string `yaml:"given"` // the name of the argument that will be given to this job }
A node's args (i.e. the `args` field).
type NodeSet ¶
type NodeSet struct { Arg *string `yaml:"arg"` // the name of the argument this job outputs by default As *string `yaml:"as"` // the name of the argument this job should output }
Args set by a node (i.e. the `sets` field).
type NodesSetsUniqueSequenceCheck ¶
type NodesSetsUniqueSequenceCheck struct{}
==========================================================================
func (NodesSetsUniqueSequenceCheck) CheckSequence ¶
func (check NodesSetsUniqueSequenceCheck) CheckSequence(sequence Sequence) error
Nodes can't set the same args as other nodes, or as the sequence (args).
type NonconditionalHasTypeNodeCheck ¶
type NonconditionalHasTypeNodeCheck struct{}
==========================================================================
func (NonconditionalHasTypeNodeCheck) CheckNode ¶
func (check NonconditionalHasTypeNodeCheck) CheckNode(node Node) error
Nonconditional nodes must specify a type.
type NonconditionalNoEqNodeCheck ¶
type NonconditionalNoEqNodeCheck struct{}
==========================================================================
func (NonconditionalNoEqNodeCheck) CheckNode ¶
func (check NonconditionalNoEqNodeCheck) CheckNode(node Node) error
Nonconditional nodes may not specify 'eq'.
type NonconditionalNoIfNodeCheck ¶
type NonconditionalNoIfNodeCheck struct{}
==========================================================================
func (NonconditionalNoIfNodeCheck) CheckNode ¶
func (check NonconditionalNoIfNodeCheck) CheckNode(node Node) error
Nonconditional nodes may not specify 'if'.
type OptionalArgsHaveDefaultsSequenceCheck ¶
type OptionalArgsHaveDefaultsSequenceCheck struct{}
==========================================================================
func (OptionalArgsHaveDefaultsSequenceCheck) CheckSequence ¶
func (check OptionalArgsHaveDefaultsSequenceCheck) CheckSequence(sequence Sequence) error
Optional args must have defaults.
type OptionalArgsNamedSequenceCheck ¶
type OptionalArgsNamedSequenceCheck struct{}
==========================================================================
func (OptionalArgsNamedSequenceCheck) CheckSequence ¶
func (check OptionalArgsNamedSequenceCheck) CheckSequence(sequence Sequence) error
Sequence args must be named, i.e. include a 'name' field.
type RequiredArgsHaveNoDefaultsSequenceCheck ¶
type RequiredArgsHaveNoDefaultsSequenceCheck struct{}
==========================================================================
func (RequiredArgsHaveNoDefaultsSequenceCheck) CheckSequence ¶
func (check RequiredArgsHaveNoDefaultsSequenceCheck) CheckSequence(sequence Sequence) error
Required args must not have defaults.
type RequiredArgsNamedSequenceCheck ¶
type RequiredArgsNamedSequenceCheck struct{}
==========================================================================
func (RequiredArgsNamedSequenceCheck) CheckSequence ¶
func (check RequiredArgsNamedSequenceCheck) CheckSequence(sequence Sequence) error
Sequence args must be named, i.e. include a 'name' field.
type RequiredArgsProvidedNodeCheck ¶
type RequiredArgsProvidedNodeCheck struct {
AllSpecs Specs
}
==========================================================================
func (RequiredArgsProvidedNodeCheck) CheckNode ¶
func (check RequiredArgsProvidedNodeCheck) CheckNode(node Node) error
Sequence and conditional nodes must be provided with their required args.
type RetryIfRetryWaitNodeCheck ¶
type RetryIfRetryWaitNodeCheck struct{}
==========================================================================
func (RetryIfRetryWaitNodeCheck) CheckNode ¶
func (check RetryIfRetryWaitNodeCheck) CheckNode(node Node) error
If 'retryWait' is set, 'retry' must be set (nonzero).
type Sequence ¶
type Sequence struct { Name string `yaml:"-"` // name of the sequence Args SequenceArgs `yaml:"args"` // arguments to the sequence Nodes map[string]*Node `yaml:"nodes"` // list of nodes that are a part of the sequence Request bool `yaml:"request"` // whether or not the sequence spec is a user request ACL []ACL `yaml:"acl"` // allowed caller roles (optional) Filename string `yaml:"_"` // name of file this sequence was in }
A single sequence.
type SequenceArgs ¶
type SequenceArgs struct { Required []*Arg `yaml:"required"` Optional []*Arg `yaml:"optional"` Static []*Arg `yaml:"static"` }
A sequence's arguments. A sequence can have required arguments; any arguments on this list that are not provided by the calling sequence will result in an error from template.Grapher. A sequence can also have optional arguemnts; arguments on this list that are missing will not result in an error. Additionally optional arguments can have default values that will be used if not explicitly given.
type SequenceCheck ¶
type SetsAreNamedNodeCheck ¶
type SetsAreNamedNodeCheck struct{}
==========================================================================
func (SetsAreNamedNodeCheck) CheckNode ¶
func (check SetsAreNamedNodeCheck) CheckNode(node Node) error
Node 'sets' must be named, i.e. include an 'arg'field.
type SetsAsUniqueNodeCheck ¶
type SetsAsUniqueNodeCheck struct{}
==========================================================================
func (SetsAsUniqueNodeCheck) CheckNode ¶
func (check SetsAsUniqueNodeCheck) CheckNode(node Node) error
Args cannot be set multiple times by one job.
type SetsNotNilNodeCheck ¶
type SetsNotNilNodeCheck struct{}
==========================================================================
func (SetsNotNilNodeCheck) CheckNode ¶
func (check SetsNotNilNodeCheck) CheckNode(node Node) error
Node 'sets' must not be nil.
type SetsNotRenamedTwiceNodeCheck ¶
type SetsNotRenamedTwiceNodeCheck struct{}
==========================================================================
func (SetsNotRenamedTwiceNodeCheck) CheckNode ¶
func (check SetsNotRenamedTwiceNodeCheck) CheckNode(node Node) error
A single 'sets' arg cannot be renamed.
type Specs ¶
A collection of sequences. This can be all the sequences in a single yaml file. It is also used to hold all sequences in the specs directory. Also contains the user defined no-op job.
type StaticArgsHaveDefaultsSequenceCheck ¶
type StaticArgsHaveDefaultsSequenceCheck struct{}
==========================================================================
func (StaticArgsHaveDefaultsSequenceCheck) CheckSequence ¶
func (check StaticArgsHaveDefaultsSequenceCheck) CheckSequence(sequence Sequence) error
Static args must have defaults.
type StaticArgsNamedSequenceCheck ¶
type StaticArgsNamedSequenceCheck struct{}
==========================================================================
func (StaticArgsNamedSequenceCheck) CheckSequence ¶
func (check StaticArgsNamedSequenceCheck) CheckSequence(sequence Sequence) error
Sequence args must be named, i.e. include a 'name' field.
type SubsequencesExistNodeCheck ¶
type SubsequencesExistNodeCheck struct {
AllSpecs Specs
}
==========================================================================
func (SubsequencesExistNodeCheck) CheckNode ¶
func (check SubsequencesExistNodeCheck) CheckNode(node Node) error
All sequences called by the node exist in the specs.
type ValidCategoryNodeCheck ¶
type ValidCategoryNodeCheck struct{}
==========================================================================
func (ValidCategoryNodeCheck) CheckNode ¶
func (check ValidCategoryNodeCheck) CheckNode(node Node) error
'category: (job | sequence | conditional)'
type ValidEachNodeCheck ¶
type ValidEachNodeCheck struct{}
==========================================================================
func (ValidEachNodeCheck) CheckNode ¶
func (check ValidEachNodeCheck) CheckNode(node Node) error
'each' values must be in the format 'list:element'.
type ValidParallelNodeCheck ¶
type ValidParallelNodeCheck struct{}
==========================================================================
func (ValidParallelNodeCheck) CheckNode ¶
func (check ValidParallelNodeCheck) CheckNode(node Node) error
'parallel' > 0.
type ValidRetryWaitNodeCheck ¶
type ValidRetryWaitNodeCheck struct{}
==========================================================================
func (ValidRetryWaitNodeCheck) CheckNode ¶
func (check ValidRetryWaitNodeCheck) CheckNode(node Node) error
'retryWait' should be a valid duration.