cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.4.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

internal/config/aggregate.go

40lines · modecode

1package config
2
3import (
4 "fmt"
5 "regexp"
6
7 "github.com/cloudflare/pint/internal/checks"
8)
9
10type AggregateSettings struct {
11 Name string `hcl:",label"`
12 Keep []string `hcl:"keep,optional"`
13 Strip []string `hcl:"strip,optional"`
14 Severity string `hcl:"severity,optional"`
15}
16
17func (ag AggregateSettings) validate() error {
18 if ag.Name == "" {
19 return fmt.Errorf("empty name regex")
20 }
21
22 if ag.Severity != "" {
23 if _, err := checks.ParseSeverity(ag.Severity); err != nil {
24 return err
25 }
26 }
27
28 if _, err := regexp.Compile(ag.Name); err != nil {
29 return err
30 }
31 return nil
32}
33
34func (ag AggregateSettings) getSeverity(fallback checks.Severity) checks.Severity {
35 if ag.Severity != "" {
36 sev, _ := checks.ParseSeverity(ag.Severity)
37 return sev
38 }
39 return fallback
40}