Skip to content

Commit

Permalink
fix build after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Aug 21, 2024
1 parent 8920686 commit e78630a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 43 deletions.
26 changes: 13 additions & 13 deletions receiver/prometheusreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ func (cfg *PromConfig) Validate() error {
return nil
}

func unmarshalYAML(in map[string]any, out any) error {
yamlOut, err := yaml.Marshal(in)
if err != nil {
return fmt.Errorf("prometheus receiver: failed to marshal config to yaml: %w", err)
}

err = yaml.UnmarshalStrict(yamlOut, out)
if err != nil {
return fmt.Errorf("prometheus receiver: failed to unmarshal yaml to prometheus config object: %w", err)
}
return nil
}

func validateHTTPClientConfig(cfg *commonconfig.HTTPClientConfig) error {
if cfg.Authorization != nil {
if err := checkFile(cfg.Authorization.CredentialsFile); err != nil {
Expand Down Expand Up @@ -135,16 +148,3 @@ func checkTLSConfig(tlsConfig commonconfig.TLSConfig) error {
}
return nil
}

func unmarshalYAML(in map[string]any, out any) error {
yamlOut, err := yaml.Marshal(in)
if err != nil {
return fmt.Errorf("prometheus receiver: failed to marshal config to yaml: %w", err)
}

err = yaml.UnmarshalStrict(yamlOut, out)
if err != nil {
return fmt.Errorf("prometheus receiver: failed to unmarshal yaml to prometheus config object: %w", err)
}
return nil
}
38 changes: 8 additions & 30 deletions receiver/prometheusreceiver/targetallocator/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,33 +657,11 @@ func TestTargetAllocatorJobRetrieval(t *testing.T) {
},
},
cfg: &Config{
PrometheusConfig: &PromConfig{
ScrapeConfigs: []*promconfig.ScrapeConfig{
{
JobName: "job1",
HonorTimestamps: true,
ScrapeInterval: model.Duration(30 * time.Second),
ScrapeTimeout: model.Duration(30 * time.Second),
ScrapeProtocols: promconfig.DefaultScrapeProtocols,
MetricsPath: "/metrics",
Scheme: "http",
MetricRelabelConfigs: []*relabel.Config{
{
Separator: ";",
Regex: relabel.MustNewRegexp("(.*)"),
Action: relabel.Keep,
},
},
},
},
},
TargetAllocator: &TargetAllocator{
Interval: 10 * time.Second,
CollectorID: "collector-1",
HTTPSDConfig: &PromHTTPSDConfig{
HTTPClientConfig: commonconfig.HTTPClientConfig{},
RefreshInterval: model.Duration(60 * time.Second),
},
Interval: 10 * time.Second,
CollectorID: "collector-1",
HTTPSDConfig: &PromHTTPSDConfig{
HTTPClientConfig: commonconfig.HTTPClientConfig{},
RefreshInterval: model.Duration(60 * time.Second),
},
},
want: expectedTestResult{
Expand Down Expand Up @@ -756,7 +734,7 @@ func TestTargetAllocatorJobRetrieval(t *testing.T) {
s.Labels["__meta_url"] = model.LabelValue(sdConfig.URL)
require.Equal(t, s.Labels, group.Labels)
if s.MetricRelabelConfig != nil {
for _, sc := range receiver.cfg.PrometheusConfig.ScrapeConfigs {
for _, sc := range manager.promCfg.ScrapeConfigs {
if sc.JobName == s.MetricRelabelConfig.JobName {
for _, mc := range sc.MetricRelabelConfigs {
require.Equal(t, s.MetricRelabelConfig.MetricRelabelRegex, mc.Regex)
Expand All @@ -774,7 +752,7 @@ func TestTargetAllocatorJobRetrieval(t *testing.T) {
}

func TestConfigureSDHTTPClientConfigFromTA(t *testing.T) {
ta := &TargetAllocator{}
ta := &Config{}
ta.TLSSetting = configtls.ClientConfig{
InsecureSkipVerify: true,
ServerName: "test.server",
Expand Down Expand Up @@ -813,7 +791,7 @@ func TestConfigureSDHTTPClientConfigFromTA(t *testing.T) {
assert.Equal(t, commonconfig.URL{URL: parsedProxyURL}, httpSD.HTTPClientConfig.ProxyURL)

// Test case with empty TargetAllocator
emptyTA := &TargetAllocator{}
emptyTA := &Config{}
emptyHTTPSD := &promHTTP.SDConfig{RefreshInterval: model.Duration(30 * time.Second)}

err = configureSDHTTPClientConfigFromTA(emptyHTTPSD, emptyTA)
Expand Down

0 comments on commit e78630a

Please sign in to comment.