forked from zachomedia/cert-manager-webhook-pdns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
36 lines (29 loc) · 837 Bytes
/
utils.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
package main
import (
"fmt"
"github.com/joeig/go-powerdns/v3"
)
// findRRSet searches through te list of rrsets for a matching entry
// based on type and name.
func findRRSet(rrsets []powerdns.RRset, rrtype powerdns.RRType, name string) *powerdns.RRset {
for _, rrset := range rrsets {
if (rrset.Type != nil && *rrset.Type == powerdns.RRTypeTXT) &&
(rrset.Name != nil && *rrset.Name == name) {
return &rrset
}
}
return nil
}
// findRecord locates the record entry with the matching content.
func findRecord(records []powerdns.Record, content string) (int, bool) {
for indx, record := range records {
if record.Content != nil && *record.Content == content {
return indx, true
}
}
return -1, false
}
// quote quotes the provide value
func quote(value string) string {
return fmt.Sprintf("\"%s\"", value)
}