blob: fe533b974adf92917cfbbed24396b67b3143a000 (
plain)
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
|
// SPDX-License-Identifier: GPL-3.0-or-later
package bind
import (
"errors"
"fmt"
"net/http"
"strings"
"github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/matcher"
)
func (b *Bind) validateConfig() error {
if b.URL == "" {
return errors.New("url not set")
}
return nil
}
func (b *Bind) initPermitViewMatcher() (matcher.Matcher, error) {
if b.PermitView == "" {
return nil, nil
}
return matcher.NewSimplePatternsMatcher(b.PermitView)
}
func (b *Bind) initBindApiClient(httpClient *http.Client) (bindAPIClient, error) {
switch {
case strings.HasSuffix(b.URL, "/xml/v3"): // BIND 9.9+
return newXML3Client(httpClient, b.Request), nil
case strings.HasSuffix(b.URL, "/json/v1"): // BIND 9.10+
return newJSONClient(httpClient, b.Request), nil
default:
return nil, fmt.Errorf("URL %s is wrong, supported endpoints: `/xml/v3`, `/json/v1`", b.URL)
}
}
|