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

//go:build linux
// +build linux

package systemdunits

import (
	"errors"
	"strings"

	"github.com/netdata/netdata/go/go.d.plugin/pkg/matcher"
)

func (s *SystemdUnits) validateConfig() error {
	if len(s.Include) == 0 {
		return errors.New("'include' option not set")
	}
	return nil
}

func (s *SystemdUnits) initSelector() (matcher.Matcher, error) {
	if len(s.Include) == 0 {
		return matcher.TRUE(), nil
	}

	expr := strings.Join(s.Include, " ")
	return matcher.NewSimplePatternsMatcher(expr)
}