Skip to content

Commit

Permalink
Add LGTM analysis and fix alerts (#6)
Browse files Browse the repository at this point in the history
* Add LGTM badge and analysis

* remove LGTM warnings
  • Loading branch information
tjololo authored Aug 9, 2021
1 parent cbc646c commit 83731be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
7 changes: 0 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"os"

"github.com/spf13/viper"
"github.com/tjololo/linkerd-cert-notifier/pkg/certificate"
Expand All @@ -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 {
Expand All @@ -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))
Expand All @@ -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 {
Expand All @@ -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))
Expand Down

0 comments on commit 83731be

Please sign in to comment.