Documentation ¶
Index ¶
- Constants
- Variables
- func LoadFromFile(ctx context.Context, validationCfg *Config) (validators.ProcessesValidators, error)
- func RegisterFlags()
- func WrapStoreWithConfigFile(a store.Adapter, cfg *Config) (store.Adapter, error)
- type Config
- type ProcessRules
- type ProcessesRules
- type StepRules
- type StoreWithConfigFile
Constants ¶
const ( // Component name for monitoring. Component = "validation" // DefaultFilename is the default filename for the file containing // validation rules. // This is used in non-blockchain scenario. DefaultFilename = "/data/validation/rules.json" // DefaultPluginsDirectory is the default directory where validation // plugins should be stored. DefaultPluginsDirectory = "/data/validation/plugins" )
Variables ¶
var ( ErrInvalidStepValidationRules = errors.New("a step validator requires a JSON schema, a signature or a transition criteria to be valid") ErrMissingPKI = errors.New("PKI is missing from validation rules") ErrMissingTransitions = errors.New("transitions must be defined for every step") ErrInvalidTransitions = errors.New("invalid step transition") )
Errors used by the validation rules parsers.
Functions ¶
func LoadFromFile ¶
func LoadFromFile(ctx context.Context, validationCfg *Config) (validators.ProcessesValidators, error)
LoadFromFile loads the validation rules from a json file.
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags registers the command-line monitoring flags.
Types ¶
type Config ¶
Config contains the path of the rules JSON file and the directory where the validator scripts are located.
func ConfigurationFromFlags ¶
func ConfigurationFromFlags() *Config
ConfigurationFromFlags builds configuration from user-provided command-line flags.
type ProcessRules ¶
type ProcessRules struct { PKI validators.PKI `json:"pki"` Steps map[string]*StepRules `json:"steps"` Script *validators.ScriptConfig `json:"script"` }
ProcessRules contains the validation rules that apply to a specific process.
func (*ProcessRules) ValidateTransitions ¶
func (r *ProcessRules) ValidateTransitions() error
ValidateTransitions checks for human errors in the transitions definitions (for example some steps that cannot be reached).
func (*ProcessRules) Validators ¶
func (r *ProcessRules) Validators(process string, pluginsPath string) (validators.Validators, error)
Validators creates the validators corresponding to the configured process' rules.
type ProcessesRules ¶
type ProcessesRules map[string]*ProcessRules
ProcessesRules maps processes to their validation rules.
func (ProcessesRules) Validators ¶
func (r ProcessesRules) Validators(pluginsPath string) (validators.ProcessesValidators, error)
Validators creates the validators corresponding to the configured rules.
type StepRules ¶
type StepRules struct { Signatures []string `json:"signatures"` Schema map[string]interface{} `json:"schema"` Transitions []string `json:"transitions"` }
StepRules contains the validation rules that apply to a specific step inside a given process.
func (*StepRules) Validators ¶
func (r *StepRules) Validators(process, step string, pki validators.PKI) (validators.Validators, error)
Validators creates the validators corresponding to the configured step's rules.
type StoreWithConfigFile ¶
StoreWithConfigFile wraps a store adapter with a layer of validations based on a local configuration file.
func (*StoreWithConfigFile) CreateLink ¶
func (a *StoreWithConfigFile) CreateLink(ctx context.Context, link *chainscript.Link) (chainscript.LinkHash, error)
CreateLink applies validations before creating the link.