From 0196902b2e51a27325d2e2e6c03a2fac8de7be07 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 15 Jan 2024 17:11:45 +0200 Subject: [PATCH] lib/promscrape/discovery/hetzner: fix golangci-lint warnings after 03a97dc6784b37a8e211fc44d9f8857abfbc1df1 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5550 --- lib/promscrape/discovery/hetzner/hcloud.go | 6 ++++-- lib/promscrape/discovery/hetzner/hcloud_test.go | 2 +- lib/promscrape/discovery/hetzner/hetzner.go | 4 +++- lib/promscrape/discovery/hetzner/robot.go | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/promscrape/discovery/hetzner/hcloud.go b/lib/promscrape/discovery/hetzner/hcloud.go index 86c5994c0..f7fde4070 100644 --- a/lib/promscrape/discovery/hetzner/hcloud.go +++ b/lib/promscrape/discovery/hetzner/hcloud.go @@ -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)) diff --git a/lib/promscrape/discovery/hetzner/hcloud_test.go b/lib/promscrape/discovery/hetzner/hcloud_test.go index ce6c706aa..d4903e2af 100644 --- a/lib/promscrape/discovery/hetzner/hcloud_test.go +++ b/lib/promscrape/discovery/hetzner/hcloud_test.go @@ -273,7 +273,7 @@ func TestParseHcloudServerListResponse(t *testing.T) { ServerType: ServerType{ Name: "cx11", Cores: 1, - CpuType: "shared", + CPUType: "shared", Memory: 1.0, Disk: 25, }, diff --git a/lib/promscrape/discovery/hetzner/hetzner.go b/lib/promscrape/discovery/hetzner/hetzner.go index 364739b97..9662f3887 100644 --- a/lib/promscrape/discovery/hetzner/hetzner.go +++ b/lib/promscrape/discovery/hetzner/hetzner.go @@ -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"` diff --git a/lib/promscrape/discovery/hetzner/robot.go b/lib/promscrape/discovery/hetzner/robot.go index a67d2f659..3cbb74075 100644 --- a/lib/promscrape/discovery/hetzner/robot.go +++ b/lib/promscrape/discovery/hetzner/robot.go @@ -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"`