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/cost.go

33lines · modecode

1package config
2
3import (
4 "fmt"
5
6 "github.com/cloudflare/pint/internal/checks"
7)
8
9type CostSettings struct {
10 BytesPerSample int `hcl:"bytesPerSample,optional"`
11 MaxSeries int `hcl:"maxSeries,optional"`
12 Severity string `hcl:"severity,optional"`
13}
14
15func (cs CostSettings) validate() error {
16 if cs.Severity != "" {
17 if _, err := checks.ParseSeverity(cs.Severity); err != nil {
18 return err
19 }
20 }
21 if cs.MaxSeries < 0 {
22 return fmt.Errorf("maxSeries value must be >= 0")
23 }
24 return nil
25}
26
27func (cs CostSettings) getSeverity(fallback checks.Severity) checks.Severity {
28 if cs.Severity != "" {
29 sev, _ := checks.ParseSeverity(cs.Severity)
30 return sev
31 }
32 return fallback
33}