From e4a09f2b4b4772a886a694eb29a90712d41d63df Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Wed, 8 Jun 2022 11:29:44 +0200 Subject: [PATCH] uyuni: Use default HTTP client and set relative paths (#10814) Signed-off-by: Julien Pivotto --- config/config_test.go | 13 +++++++------ discovery/uyuni/uyuni.go | 12 +++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index acf339393..dc8ab742b 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -989,12 +989,13 @@ var expectedConf = &Config{ Scheme: DefaultScrapeConfig.Scheme, ServiceDiscoveryConfigs: discovery.Configs{ &uyuni.SDConfig{ - Server: "https://localhost:1234", - Username: "gopher", - Password: "hole", - Entitlement: "monitoring_entitled", - Separator: ",", - RefreshInterval: model.Duration(60 * time.Second), + Server: "https://localhost:1234", + Username: "gopher", + Password: "hole", + Entitlement: "monitoring_entitled", + Separator: ",", + RefreshInterval: model.Duration(60 * time.Second), + HTTPClientConfig: config.DefaultHTTPClientConfig, }, }, }, diff --git a/discovery/uyuni/uyuni.go b/discovery/uyuni/uyuni.go index f9630ce35..e37acbf98 100644 --- a/discovery/uyuni/uyuni.go +++ b/discovery/uyuni/uyuni.go @@ -52,9 +52,10 @@ const ( // DefaultSDConfig is the default Uyuni SD configuration. var DefaultSDConfig = SDConfig{ - Entitlement: "monitoring_entitled", - Separator: ",", - RefreshInterval: model.Duration(1 * time.Minute), + Entitlement: "monitoring_entitled", + Separator: ",", + RefreshInterval: model.Duration(1 * time.Minute), + HTTPClientConfig: config.DefaultHTTPClientConfig, } func init() { @@ -117,6 +118,11 @@ func (c *SDConfig) NewDiscoverer(opts discovery.DiscovererOptions) (discovery.Di return NewDiscovery(c, opts.Logger) } +// SetDirectory joins any relative file paths with dir. +func (c *SDConfig) SetDirectory(dir string) { + c.HTTPClientConfig.SetDirectory(dir) +} + // UnmarshalYAML implements the yaml.Unmarshaler interface. func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { *c = DefaultSDConfig