Skip to content

Commit

Permalink
fix: linting and error handling
Browse files Browse the repository at this point in the history
Signed-off-by: Clément Nussbaumer <[email protected]>
  • Loading branch information
clementnuss committed Dec 27, 2023
1 parent 68bf7ce commit 1057536
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions internal/kubenurse/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package kubenurse
import (
"context"
"fmt"
"log"
"net/http"
"os"
"strconv"
Expand Down Expand Up @@ -55,7 +56,7 @@ type Server struct {
// * KUBENURSE_CHECK_ME_SERVICE
// * KUBENURSE_CHECK_NEIGHBOURHOOD
// * KUBENURSE_CHECK_INTERVAL
func New(ctx context.Context, k8s kubernetes.Interface) (*Server, error) {
func New(ctx context.Context, k8s kubernetes.Interface) (*Server, error) { //nolint:funlen // TODO: use a flag parsing library (e.g. ff) to reduce complexity
mux := http.NewServeMux()

checkInterval := defaultCheckInterval
Expand Down Expand Up @@ -107,20 +108,15 @@ func New(ctx context.Context, k8s kubernetes.Interface) (*Server, error) {
var histogramBuckets []float64

if bucketsString := os.Getenv("KUBENURSE_HISTOGRAM_BUCKETS"); bucketsString != "" {
var buckets []float64

for _, bucketStr := range strings.Split(bucketsString, ",") {
bucket, err := strconv.ParseFloat(bucketStr, 64)
bucket, e := strconv.ParseFloat(bucketStr, 64)

if err != nil {
buckets = nil
break
if e != nil {
log.Fatalf("couldn't parse one of the custom histogram buckets. error:\n%v", e)
}

buckets = append(buckets, bucket)
histogramBuckets = append(histogramBuckets, bucket)
}

histogramBuckets = buckets
}

if histogramBuckets == nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/servicecheck/servicecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (

// New configures the checker with a httpClient and a cache timeout for check
// results. Other parameters of the Checker struct need to be configured separately.
func New(ctx context.Context, discovery *kubediscovery.Client, promRegistry *prometheus.Registry,
func New(_ context.Context, discovery *kubediscovery.Client, promRegistry *prometheus.Registry,
allowUnschedulable bool, cacheTTL time.Duration, durationHistogramBuckets []float64) (*Checker, error) {
errorCounter := prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand Down

0 comments on commit 1057536

Please sign in to comment.