cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

internal/config/annotation.go

36lines · modecode

1package config
2
3import (
4 "regexp"
5
6 "github.com/cloudflare/pint/internal/checks"
7)
8
9type AnnotationSettings struct {
10 Key string `hcl:",label"`
11 Value string `hcl:"value,optional"`
12 Required bool `hcl:"required,optional"`
13 Severity string `hcl:"severity,optional"`
14}
15
16func (as AnnotationSettings) validate() error {
17 if as.Severity != "" {
18 if _, err := checks.ParseSeverity(as.Severity); err != nil {
19 return err
20 }
21 }
22
23 if _, err := regexp.Compile(as.Value); err != nil {
24 return err
25 }
26
27 return nil
28}
29
30func (as AnnotationSettings) getSeverity(fallback checks.Severity) checks.Severity {
31 if as.Severity != "" {
32 sev, _ := checks.ParseSeverity(as.Severity)
33 return sev
34 }
35 return fallback
36}
37