-
Notifications
You must be signed in to change notification settings - Fork 1
/
releaseconfig.go
62 lines (51 loc) · 1.43 KB
/
releaseconfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"log"
"regexp"
)
// ReleaseConfig is used for configuration options which can be set and managed
// on a per-release basis. For instance, we may wish to vary the list of pgp
// keys used to verify uploads to a release over time.
type ReleaseConfig struct {
VerifyChanges bool
VerifyChangesSufficient bool
VerifyDebs bool
AcceptLoneDebs bool
PoolPattern string
AutoTrim bool
AutoTrimLength int
PruneRules string
PublicKeyIDs []StoreID `json:",omitempty"`
SigningKeyID StoreID `json:",omitempty"`
pruneRules *PruneRuleSet
poolRegex *regexp.Regexp
}
// MakeTrimmer returns a trimmer that will implement the
// trimming configuration
func (r *ReleaseConfig) MakeTrimmer() Trimmer {
return MakeLengthTrimmer(r.AutoTrimLength)
}
// MakePruner returns a pruner that will implement
// the pruning configuration
func (r *ReleaseConfig) MakePruner() Pruner {
if r.pruneRules == nil {
rules, err := ParsePruneRules(r.PruneRules)
if err != nil {
log.Println("Error parsing stored prune rules", err)
}
r.pruneRules = &rules
}
return r.pruneRules.MakePruner()
}
// PoolRegexp returns a regexp of the configured
// pool regex
func (r *ReleaseConfig) PoolRegexp() *regexp.Regexp {
if r.poolRegex == nil {
var err error
r.poolRegex, err = regexp.Compile(r.PoolPattern)
if err != nil {
log.Println("Error parsing stored pool pattern", err)
}
}
return r.poolRegex
}