summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/dockerhub/init.go
blob: 245bee1cb9d27b20c7309f07714fd29b1cfb3703 (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
// SPDX-License-Identifier: GPL-3.0-or-later

package dockerhub

import (
	"errors"
	"github.com/netdata/netdata/go/go.d.plugin/pkg/web"
)

func (dh *DockerHub) validateConfig() error {
	if dh.URL == "" {
		return errors.New("url not set")
	}
	if len(dh.Repositories) == 0 {
		return errors.New("repositories not set")
	}
	return nil
}

func (dh *DockerHub) initApiClient() (*apiClient, error) {
	client, err := web.NewHTTPClient(dh.Client)
	if err != nil {
		return nil, err
	}
	return newAPIClient(client, dh.Request), nil
}