mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape/discovery/hetzner: fix golangci-lint warnings after 03a97dc678
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5550
This commit is contained in:
parent
e14e3d9c8c
commit
4b42c8abbb
4 changed files with 11 additions and 6 deletions
|
@ -26,6 +26,7 @@ type HcloudServer struct {
|
|||
Labels map[string]string `json:"labels"`
|
||||
}
|
||||
|
||||
// Datacenter represents the Hetzner datacenter.
|
||||
type Datacenter struct {
|
||||
Name string `json:"name"`
|
||||
Location DatacenterLocation `json:"location"`
|
||||
|
@ -71,7 +72,7 @@ type IPv6 struct {
|
|||
type ServerType struct {
|
||||
Name string `json:"name"`
|
||||
Cores int `json:"cores"`
|
||||
CpuType string `json:"cpu_type"`
|
||||
CPUType string `json:"cpu_type"`
|
||||
Memory float32 `json:"memory"`
|
||||
Disk int `json:"disk"`
|
||||
}
|
||||
|
@ -82,6 +83,7 @@ type HcloudNetwork struct {
|
|||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
// HcloudNetworksList represents the hetzner cloud networks list.
|
||||
type HcloudNetworksList struct {
|
||||
Networks []HcloudNetwork `json:"networks"`
|
||||
}
|
||||
|
@ -167,7 +169,7 @@ func (server *HcloudServer) appendTargetLabels(ms []*promutils.Labels, port int,
|
|||
m.Add("__meta_hetzner_hcloud_datacenter_location_network_zone", server.Datacenter.Location.NetworkZone)
|
||||
m.Add("__meta_hetzner_hcloud_server_type", server.ServerType.Name)
|
||||
m.Add("__meta_hetzner_hcloud_cpu_cores", fmt.Sprintf("%d", server.ServerType.Cores))
|
||||
m.Add("__meta_hetzner_hcloud_cpu_type", server.ServerType.CpuType)
|
||||
m.Add("__meta_hetzner_hcloud_cpu_type", server.ServerType.CPUType)
|
||||
m.Add("__meta_hetzner_hcloud_memory_size_gb", fmt.Sprintf("%d", int(server.ServerType.Memory)))
|
||||
m.Add("__meta_hetzner_hcloud_disk_size_gb", fmt.Sprintf("%d", server.ServerType.Disk))
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ func TestParseHcloudServerListResponse(t *testing.T) {
|
|||
ServerType: ServerType{
|
||||
Name: "cx11",
|
||||
Cores: 1,
|
||||
CpuType: "shared",
|
||||
CPUType: "shared",
|
||||
Memory: 1.0,
|
||||
Disk: 25,
|
||||
},
|
||||
|
|
|
@ -9,13 +9,15 @@ import (
|
|||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/proxy"
|
||||
) //
|
||||
)
|
||||
|
||||
// SDCheckInterval defines interval for targets refresh.
|
||||
var SDCheckInterval = flag.Duration("promscrape.hetznerSDCheckInterval", time.Minute, "Interval for checking for changes in hetzner. "+
|
||||
"This works only if hetzner_sd_configs is configured in '-promscrape.config' file. "+
|
||||
"See https://docs.victoriametrics.com/sd_configs.html#hetzner_sd_configs for details")
|
||||
|
||||
// SDConfig represents service discovery config for Hetzner.
|
||||
//
|
||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#hetzner_sd_config
|
||||
type SDConfig struct {
|
||||
Role string `yaml:"role,omitempty"`
|
||||
|
|
|
@ -14,11 +14,12 @@ type robotServersList struct {
|
|||
Servers []RobotServerResponse
|
||||
}
|
||||
|
||||
// RobotServerResponse represents hetzner robot server response.
|
||||
type RobotServerResponse struct {
|
||||
Server RobotServer `json:"server"`
|
||||
}
|
||||
|
||||
// HcloudServer represents the structure of hetzner robot server data.
|
||||
// RobotServer represents the structure of hetzner robot server data.
|
||||
type RobotServer struct {
|
||||
ServerIP string `json:"server_ip"`
|
||||
ServerIPV6 string `json:"server_ipv6_net"`
|
||||
|
@ -31,7 +32,7 @@ type RobotServer struct {
|
|||
Subnet []RobotSubnet `json:"subnet"`
|
||||
}
|
||||
|
||||
// HcloudServer represents the structure of hetzner robot subnet data.
|
||||
// RobotSubnet represents the structure of hetzner robot subnet data.
|
||||
type RobotSubnet struct {
|
||||
IP string `json:"ip"`
|
||||
Mask string `json:"mask"`
|
||||
|
|
Loading…
Reference in a new issue