mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
change config names to files for consistency
This commit is contained in:
parent
f55a1d463d
commit
c81b4e8a87
|
@ -604,7 +604,7 @@ func (c *DNSSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
|
|
||||||
// FileSDConfig is the configuration for file based discovery.
|
// FileSDConfig is the configuration for file based discovery.
|
||||||
type FileSDConfig struct {
|
type FileSDConfig struct {
|
||||||
Names []string `yaml:"names"`
|
Files []string `yaml:"files"`
|
||||||
RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
|
RefreshInterval model.Duration `yaml:"refresh_interval,omitempty"`
|
||||||
|
|
||||||
// Catches all undefined fields and must be empty after parsing.
|
// Catches all undefined fields and must be empty after parsing.
|
||||||
|
@ -619,10 +619,10 @@ func (c *FileSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(c.Names) == 0 {
|
if len(c.Files) == 0 {
|
||||||
return fmt.Errorf("file service discovery config must contain at least one path name")
|
return fmt.Errorf("file service discovery config must contain at least one path name")
|
||||||
}
|
}
|
||||||
for _, name := range c.Names {
|
for _, name := range c.Files {
|
||||||
if !patFileSDName.MatchString(name) {
|
if !patFileSDName.MatchString(name) {
|
||||||
return fmt.Errorf("path name %q is not valid for file discovery", name)
|
return fmt.Errorf("path name %q is not valid for file discovery", name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,11 +72,11 @@ var expectedConf = &Config{
|
||||||
|
|
||||||
FileSDConfigs: []*FileSDConfig{
|
FileSDConfigs: []*FileSDConfig{
|
||||||
{
|
{
|
||||||
Names: []string{"foo/*.slow.json", "foo/*.slow.yml", "single/file.yml"},
|
Files: []string{"foo/*.slow.json", "foo/*.slow.yml", "single/file.yml"},
|
||||||
RefreshInterval: model.Duration(10 * time.Minute),
|
RefreshInterval: model.Duration(10 * time.Minute),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Names: []string{"bar/*.yaml"},
|
Files: []string{"bar/*.yaml"},
|
||||||
RefreshInterval: model.Duration(5 * time.Minute),
|
RefreshInterval: model.Duration(5 * time.Minute),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
4
config/testdata/conf.good.yml
vendored
4
config/testdata/conf.good.yml
vendored
|
@ -24,12 +24,12 @@ scrape_configs:
|
||||||
# scheme defaults to 'http'.
|
# scheme defaults to 'http'.
|
||||||
|
|
||||||
file_sd_configs:
|
file_sd_configs:
|
||||||
- names:
|
- files:
|
||||||
- foo/*.slow.json
|
- foo/*.slow.json
|
||||||
- foo/*.slow.yml
|
- foo/*.slow.yml
|
||||||
- single/file.yml
|
- single/file.yml
|
||||||
refresh_interval: 10m
|
refresh_interval: 10m
|
||||||
- names:
|
- files:
|
||||||
- bar/*.yaml
|
- bar/*.yaml
|
||||||
|
|
||||||
target_groups:
|
target_groups:
|
||||||
|
|
|
@ -49,7 +49,7 @@ type FileDiscovery struct {
|
||||||
// NewFileDiscovery returns a new file discovery for the given paths.
|
// NewFileDiscovery returns a new file discovery for the given paths.
|
||||||
func NewFileDiscovery(conf *config.FileSDConfig) *FileDiscovery {
|
func NewFileDiscovery(conf *config.FileSDConfig) *FileDiscovery {
|
||||||
return &FileDiscovery{
|
return &FileDiscovery{
|
||||||
paths: conf.Names,
|
paths: conf.Files,
|
||||||
interval: time.Duration(conf.RefreshInterval),
|
interval: time.Duration(conf.RefreshInterval),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func testFileSD(t *testing.T, ext string) {
|
||||||
// As interval refreshing is more of a fallback, we only want to test
|
// As interval refreshing is more of a fallback, we only want to test
|
||||||
// whether file watches work as expected.
|
// whether file watches work as expected.
|
||||||
var conf config.FileSDConfig
|
var conf config.FileSDConfig
|
||||||
conf.Names = []string{"fixtures/_*" + ext}
|
conf.Files = []string{"fixtures/_*" + ext}
|
||||||
conf.RefreshInterval = model.Duration(1 * time.Hour)
|
conf.RefreshInterval = model.Duration(1 * time.Hour)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue