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

38lines · modecode

1package config
2
3import "regexp"
4
5type PrometheusConfig struct {
6 Name string `hcl:",label"`
7 URI string `hcl:"uri"`
8 Timeout string `hcl:"timeout"`
9 Paths []string `hcl:"paths,optional"`
10}
11
12func (pc PrometheusConfig) validate() error {
13 if _, err := parseDuration(pc.Timeout); err != nil {
14 return err
15 }
16
17 for _, path := range pc.Paths {
18 if _, err := regexp.Compile(path); err != nil {
19 return err
20 }
21
22 }
23
24 return nil
25}
26
27func (pc PrometheusConfig) isEnabledForPath(path string) bool {
28 if len(pc.Paths) == 0 {
29 return true
30 }
31 for _, pattern := range pc.Paths {
32 re := strictRegex(pattern)
33 if re.MatchString(path) {
34 return true
35 }
36 }
37 return false
38}
39