cloudflare/pint

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.15.3

Branches

Tags

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

Clone

HTTPS

Download ZIP

internal/config/ci.go

26lines · modecode

1package config
2
3import (
4 "errors"
5 "regexp"
6)
7
8type CI struct {
9 Include []string `hcl:"include,optional" json:"include,omitempty"`
10 MaxCommits int `hcl:"maxCommits,optional" json:"maxCommits,omitempty"`
11 BaseBranch string `hcl:"baseBranch,optional" json:"baseBranch,omitempty"`
12}
13
14func (ci CI) validate() error {
15 if ci.MaxCommits <= 0 {
16 return errors.New("maxCommits cannot be <= 0")
17 }
18
19 for _, pattern := range ci.Include {
20 _, err := regexp.Compile(pattern)
21 if err != nil {
22 return err
23 }
24 }
25 return nil
26}
27