From 86938d1bb7e1f0a8d41aa921d9caf2d3b7cb4e92 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Mon, 4 Dec 2023 13:10:09 +0000 Subject: [PATCH] fix: correct lint issues --- internal/client/client.go | 1 + internal/client/config.go | 18 +++++++++--------- internal/client/metric.go | 1 + internal/cmd/root.go | 4 ++-- internal/telemetry/metric/server.go | 1 + 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/internal/client/client.go b/internal/client/client.go index fd04c71..c8bef4a 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -44,6 +44,7 @@ type Message struct { // New creates a new mqtt client with given configuration. // isSubscribe for ping message. +// nolint: funlen func New(ctx context.Context, cfg Config, logger *zap.Logger, diff --git a/internal/client/config.go b/internal/client/config.go index babc59b..ece75dc 100644 --- a/internal/client/config.go +++ b/internal/client/config.go @@ -5,13 +5,13 @@ import ( ) type Config struct { - URL string `koanf:"url"` - ClientID string `koanf:"clientid"` - Username string `koanf:"username"` - Password string `koanf:"password"` - KeepAlive time.Duration `koanf:"keepalive"` - PingTimeout time.Duration `koanf:"ping_timeout"` - AutoReconnect bool `koanf:"auto_reconnect"` - QoS int `koanf:"qos"` - Retained bool `koanf:"retained"` + URL string `json:"url,omitempty" koanf:"url"` + ClientID string `json:"client_id,omitempty" koanf:"clientid"` + Username string `json:"username,omitempty" koanf:"username"` + Password string `json:"password,omitempty" koanf:"password"` + KeepAlive time.Duration `json:"keep_alive,omitempty" koanf:"keepalive"` + PingTimeout time.Duration `json:"ping_timeout,omitempty" koanf:"ping_timeout"` + AutoReconnect bool `json:"auto_reconnect,omitempty" koanf:"auto_reconnect"` + QoS int `json:"qo_s,omitempty" koanf:"qos"` + Retained bool `json:"retained,omitempty" koanf:"retained"` } diff --git a/internal/client/metric.go b/internal/client/metric.go index 102f98a..0725f11 100644 --- a/internal/client/metric.go +++ b/internal/client/metric.go @@ -88,6 +88,7 @@ func NewMetrics() Metrics { Help: "total number of received pongs", ConstLabels: nil, }), + // nolint: exhaustruct PingDuration: newHistogram(prometheus.HistogramOpts{ Namespace: Namespace, Subsystem: Subsystem, diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 96f1fab..ac04114 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -23,11 +23,11 @@ func Execute() { tracer := trace.New(cfg.Telemetry.Trace) metric.NewServer(cfg.Telemetry.Metric).Start(logger.Named("metric")) - // nolint: exhaustivestruct + // nolint: exhaustruct root := &cobra.Command{ Use: "mqtt-blackbox-exporter", Short: "ping pong with mqtt broker", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { main(cfg, logger, tracer) }, } diff --git a/internal/telemetry/metric/server.go b/internal/telemetry/metric/server.go index b7f30ce..fcfe49a 100644 --- a/internal/telemetry/metric/server.go +++ b/internal/telemetry/metric/server.go @@ -35,6 +35,7 @@ func NewServer(cfg config.Metric) Server { // nolint: gomnd func (s Server) Start(logger *zap.Logger) { go func() { + // nolint: exhaustruct srv := http.Server{ Addr: s.address, Handler: s.srv,