Skip to content

Commit

Permalink
Use types from discovery Hetzner when converting configs (#5485)
Browse files Browse the repository at this point in the history
  • Loading branch information
marctc authored Nov 1, 2023
1 parent a84f949 commit f959470
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions component/discovery/hetzner/hetzner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import (
prom_discovery "github.com/prometheus/prometheus/discovery/hetzner"
)

// TODO(marctc): hetzner role constants are not exported, we need to manual create them
// Remove once this is merged: https://github.com/prometheus/prometheus/pull/12620
const (
hetznerRoleRobot string = "robot"
hetznerRoleHcloud string = "hcloud"
)

func init() {
component.Register(component.Registration{
Name: "discovery.hetzner",
Expand Down Expand Up @@ -51,7 +44,7 @@ func (args *Arguments) SetToDefault() {
// Validate implements river.Validator.
func (args *Arguments) Validate() error {
switch args.Role {
case hetznerRoleRobot, hetznerRoleHcloud:
case string(prom_discovery.HetznerRoleRobot), string(prom_discovery.HetznerRoleHcloud):
default:
return fmt.Errorf("unknown role %s, must be one of robot or hcloud", args.Role)
}
Expand All @@ -65,13 +58,7 @@ func (args *Arguments) Convert() *prom_discovery.SDConfig {
RefreshInterval: model.Duration(args.RefreshInterval),
Port: args.Port,
HTTPClientConfig: *httpClient.Convert(),
}
// TODO(marctc): hetzner.role is not exported, we need to manual convert it
// Remove once this is merged: https://github.com/prometheus/prometheus/pull/12620
if args.Role == hetznerRoleRobot {
cfg.Role = "robot"
} else if args.Role == hetznerRoleHcloud {
cfg.Role = "hcloud"
Role: prom_discovery.Role(args.Role),
}
return cfg
}
Expand Down

0 comments on commit f959470

Please sign in to comment.