diff options
Diffstat (limited to '')
-rw-r--r-- | src/go/plugin/go.d/modules/bind/init.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/bind/init.go b/src/go/plugin/go.d/modules/bind/init.go new file mode 100644 index 000000000..fe533b974 --- /dev/null +++ b/src/go/plugin/go.d/modules/bind/init.go @@ -0,0 +1,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) + } +} |