From 83731be8646747bc9463f95c592dd880cddf24ad Mon Sep 17 00:00:00 2001 From: Vemund Gaukstad Date: Mon, 9 Aug 2021 14:02:31 +0200 Subject: [PATCH] Add LGTM analysis and fix alerts (#6) * Add LGTM badge and analysis * remove LGTM warnings --- README.md | 6 ++++-- main.go | 7 ------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4c1c3ae..58211bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # linkerd-cert-notifier -[![Go Report Card](https://goreportcard.com/badge/github.com/tjololo/linkerd-cert-notifier)](https://goreportcard.com/report/github.com/tjololo/linkerd-cert-notifier) -[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/tjololo/linkerd-cert-notifier.svg)](https://github.com/tjololo/linkerd-cert-notifier) +[![Go Report Card](https://goreportcard.com/badge/github.com/tjololo/linkerd-cert-notifier)](https://goreportcard.com/report/github.com/tjololo/linkerd-cert-notifier) +[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/tjololo/linkerd-cert-notifier.svg)](https://github.com/tjololo/linkerd-cert-notifier) +[![CodeQL](https://github.com/tjololo/linkerd-cert-notifier/workflows/CodeQL/badge.svg)](https://github.com/tjololo/linkerd-cert-notifier/actions?query=workflow%3ACodeQL "Code quality workflow status") +[![Total alerts](https://img.shields.io/lgtm/alerts/g/tjololo/linkerd-cert-notifier.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/tjololo/linkerd-cert-notifier/alerts/) Get notified before linkerd certificates expires. diff --git a/main.go b/main.go index 420af19..dd02262 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log" - "os" "github.com/spf13/viper" "github.com/tjololo/linkerd-cert-notifier/pkg/certificate" @@ -22,19 +21,16 @@ func main() { config, err := rest.InClusterConfig() if err != nil { zap.L().Fatal(fmt.Sprintf("Failed to get kubernetes config. %s", err)) - os.Exit(1) } client, err := kubernetes.NewForConfig(config) if err != nil { zap.L().Fatal(fmt.Sprintf("Failed to get kubernetes client. %s", err)) - os.Exit(1) } lr := linkerd.Reader{Client: client} ctx := context.Background() pem, err := lr.FetchTrustAnchor(ctx, "linkerd") if err != nil { zap.L().Fatal(fmt.Sprintf("Failed to retrive trustAnchorPEM. %s", err)) - os.Exit(1) } expiring, date, err := certificate.AboutToExpire(pem, viper.GetString("earlyexpire.anchor")) if err != nil { @@ -49,7 +45,6 @@ func main() { }) if err != nil { zap.L().Fatal(fmt.Sprintf("Failed to send message to slack. %s", err)) - os.Exit(1) } } else { zap.L().Info(fmt.Sprintf("trust anchor cert not about to expire. Expiring: %s", date)) @@ -58,7 +53,6 @@ func main() { pem, err = lr.FetchIssuerCert(ctx, "linkerd") if err != nil { zap.L().Fatal(fmt.Sprintf("Failed to retrive issuerPEM. %s", err)) - os.Exit(1) } expiring, date, err = certificate.AboutToExpire(pem, viper.GetString("earlyexpire.issuer")) if err != nil { @@ -73,7 +67,6 @@ func main() { }) if err != nil { zap.L().Fatal(fmt.Sprintf("Failed to send message to slack. %s", err)) - os.Exit(1) } } else { zap.L().Info(fmt.Sprintf("issuer cert not about to expire. Expiring: %s", date))