Skip to content

Commit

Permalink
Print error message when filedeps not found
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortejoso authored Oct 20, 2023
1 parent de6fa72 commit f40e0f3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ import (
)

func main() {
http.HandleFunc("/mutate", mutateHandler)
cert := "/etc/image-annotator-webhook/tls/tls.crt"
key := "/etc/image-annotator-webhook/tls/tls.key"
port := 8443

lvl, ok := os.LookupEnv("LOG_LEVEL")
if !ok {
lvl = "debug"
Expand All @@ -32,6 +27,17 @@ func main() {
}
logrus.SetLevel(level)

http.HandleFunc("/mutate", mutateHandler)
port := 8443
cert := "/etc/image-annotator-webhook/tls/tls.crt"
if _, err := os.Stat(cert); os.IsNotExist(err) {
logrus.Fatal("TLS certificate not found. Please mount it to /etc/image-annotator-webhook/tls/tls.crt")
}
key := "/etc/image-annotator-webhook/tls/tls.key"
if _, err := os.Stat(key); os.IsNotExist(err) {
logrus.Fatal("TLS key not found. Please mount it to /etc/image-annotator-webhook/tls/tls.key")
}

logrus.Print("Listening on port 8443...")
http.ListenAndServeTLS(fmt.Sprintf(":%d", port), cert, key, nil)
}
Expand Down

0 comments on commit f40e0f3

Please sign in to comment.