-
Notifications
You must be signed in to change notification settings - Fork 35
/
policy.go
47 lines (39 loc) · 1.18 KB
/
policy.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
package build
import "sort"
const (
// TypeLength specifies a length constraint for labels.
// The Policy.Key will be "min" or "max".
TypeLength = "length"
// KeyMin specifies a mininum length constraint for a label.
KeyMin = "min"
// KeyMax specifies a maximum length constraint for a label.
KeyMax = "max"
// TypeIDNTable specifies a location for an IDN table a language or script.
TypeIDNTable = "idn-table"
// TypeIDNDisallowed specifies that IDN labels are disallowed by the operator for this zone.
TypeIDNDisallowed = "idn-disallowed"
)
// Policy represents a registry or technical policy applicable to subdomains of a zone.
type Policy struct {
Type string `json:"type"`
Key string `json:"key,omitempty"`
Value string `json:"value,omitempty"`
Comment string `json:"comment,omitempty"`
}
func sortPolicies(policies []Policy) {
sort.SliceStable(policies, func(i, j int) bool {
a := policies[i]
b := policies[j]
switch {
case a.Type != b.Type:
return a.Type < b.Type
case a.Key != b.Key:
return a.Key < b.Key
case a.Value != b.Value:
return a.Value < b.Value
case a.Comment != b.Comment:
return a.Comment < b.Comment
}
return false
})
}