From 6fa6ab98680394c7a71835e12ccbb2aa998de12a Mon Sep 17 00:00:00 2001 From: Marc Tuduri Date: Mon, 16 Oct 2023 15:12:44 +0200 Subject: [PATCH] Use types from discovery Hetzner when converting configs --- component/discovery/hetzner/hetzner.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/component/discovery/hetzner/hetzner.go b/component/discovery/hetzner/hetzner.go index 341ff4b3ccf8..61d0b9be4f22 100644 --- a/component/discovery/hetzner/hetzner.go +++ b/component/discovery/hetzner/hetzner.go @@ -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", @@ -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) } @@ -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 }