// Validates the runner config.
// Returns an error if any are found or nil if the config is valid.
// Most validation of runner should happen in validator.go instead.
Validates the runner config.
Returns an error if any are found or nil if the config is valid.
Most validation of runner should happen in validator.go instead.
// Validates the runner config . // Returns an error if any are found or nil if the config is valid . // Most validation of runner should happen in validator . go instead .
func ValidateRunnerConfig(runner avian.RunnerApplyRequest) error {
	matchRegex, err := regexp.MatchString("^[0-9]+[kKmMgG]$", runner.Xmx)
	if err != nil {
		panic("Invalid regex in code.")
	}
	if !matchRegex {
		return fmt.Errorf("Invalid value for Xmx: %s. Must be a positive integer followed by k,K,m,M,g, or G.", runner.Xmx)
	}
	if runner.CaseSettings == nil {
		return errors.New("specify caseSettings and caseLocation")
	}
	if runner.CaseSettings.CaseLocation == "" {
		return errors.New("must specify caseLocation for caseSettings")
	}
	for _, stage := range runner.Stages {
		if stage.Process != nil {
			for i, evidence := range stage.Process.EvidenceStore {
				if emptyString(evidence.Name) {
					return fmt.Errorf("must specify name for evidence: #%d", i)
				}
				if emptyString(evidence.Directory) && (evidence.Directories == nil || len(evidence.Directories) == 0) {
					return fmt.Errorf("Must specify at least one directory for evidence: #%d", i)
				}
				if evidence.Directories != nil && len(evidence.Directories) > 0 {
					for _, directory := range evidence.Directories {
						if emptyString(directory.Path) {
							return fmt.Errorf("Evidence paths may not be empty. Found in evidence #%d", i)
						}
					}
				}
			}
		}
	}
	return nil
}
func ValidateRunnerConfig ( runner avian . RunnerApplyRequest ) error { matchRegex , err := regexp . MatchString ( " " , runner . Xmx ) if err != nil { panic ( " " ) } if ! matchRegex { return fmt . Errorf ( " " , runner . Xmx ) } if runner . CaseSettings == nil { return errors . New ( " " ) } if runner . CaseSettings . CaseLocation == " " { return errors . New ( " " ) } for _ , stage := range runner . Stages { if stage . Process != nil { for i , evidence := range stage . Process . EvidenceStore { if emptyString ( evidence . Name ) { return fmt . Errorf ( " " , i ) } if emptyString ( evidence . Directory ) && ( evidence . Directories == nil || len ( evidence . Directories ) == 0 ) { return fmt . Errorf ( " " , i ) } if evidence . Directories != nil && len ( evidence . Directories ) > 0 { for _ , directory := range evidence . Directories { if emptyString ( directory . Path ) { return fmt . Errorf ( " " , i ) } } } } } } return nil }
Validates the runner config.
Validates the runner config .
// Validate Xmx. // Ensure that evidence configuration is correct. // Only relevant if stage type is process // Evidence name must be specified. // Must have at least one of evidence.Directory or at least one element in evidence.Directories. // None of the given evidence paths may be empty. // Whether the paths actually exist will be checked later.