github.com/netdata/go.d.plugin@v0.58.1/modules/filecheck/init.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package filecheck 4 5 import ( 6 "errors" 7 8 "github.com/netdata/go.d.plugin/agent/module" 9 ) 10 11 func (fc Filecheck) validateConfig() error { 12 if len(fc.Files.Include) == 0 && len(fc.Dirs.Include) == 0 { 13 return errors.New("both 'files->include' and 'dirs->include' are empty") 14 } 15 return nil 16 } 17 18 func (fc Filecheck) initCharts() (*module.Charts, error) { 19 charts := &module.Charts{} 20 21 if len(fc.Files.Include) > 0 { 22 if err := charts.Add(*fileCharts.Copy()...); err != nil { 23 return nil, err 24 } 25 } 26 27 if len(fc.Dirs.Include) > 0 { 28 if err := charts.Add(*dirCharts.Copy()...); err != nil { 29 return nil, err 30 } 31 if !fc.Dirs.CollectDirSize { 32 if err := charts.Remove(dirSizeChart.ID); err != nil { 33 return nil, err 34 } 35 } 36 } 37 38 if len(*charts) == 0 { 39 return nil, errors.New("empty charts") 40 } 41 return charts, nil 42 }