forked from toolshed/abra
		
	WARN on recipe linting errors during --chaos..
..and show multiple linting errors instead of bailing on the first one. Re #497
This commit is contained in:
		@ -108,7 +108,11 @@ checkout as-is. Recipe commit hashes are also supported as values for
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := lint.LintForErrors(app.Recipe); err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
			if internal.Chaos {
 | 
			
		||||
				log.Warn(err)
 | 
			
		||||
			} else {
 | 
			
		||||
				log.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := validateSecrets(cl, app); err != nil {
 | 
			
		||||
 | 
			
		||||
@ -184,6 +184,8 @@ var LintRules = map[string][]LintRule{
 | 
			
		||||
func LintForErrors(recipe recipe.Recipe) error {
 | 
			
		||||
	log.Debugf("linting for critical errors in %s configs", recipe.Name)
 | 
			
		||||
 | 
			
		||||
	var errors string
 | 
			
		||||
 | 
			
		||||
	for level := range LintRules {
 | 
			
		||||
		if level != "error" {
 | 
			
		||||
			continue
 | 
			
		||||
@ -196,14 +198,18 @@ func LintForErrors(recipe recipe.Recipe) error {
 | 
			
		||||
 | 
			
		||||
			ok, err := rule.Function(recipe)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return fmt.Errorf("lint %s: %s", rule.Ref, err)
 | 
			
		||||
				errors += fmt.Sprintf("\nlint %s: %s", rule.Ref, err)
 | 
			
		||||
			}
 | 
			
		||||
			if !ok {
 | 
			
		||||
				return fmt.Errorf("lint error in %s configs: \"%s\" failed lint checks (%s)", recipe.Name, rule.Description, rule.Ref)
 | 
			
		||||
				errors += fmt.Sprintf("\nlint error in %s configs: \"%s\" failed lint checks (%s)", recipe.Name, rule.Description, rule.Ref)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (len(errors) > 0) {
 | 
			
		||||
		return fmt.Errorf(errors[1:])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Debugf("linting successful, %s is well configured", recipe.Name)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user