Skip to content

Commit

Permalink
feat: Add log level option, default to json prod log level (#35)
Browse files Browse the repository at this point in the history
* feat: Add log level option, default to json prod log level

* Update suite_test.go

* Update manager.yaml

* Update README.md
  • Loading branch information
samirtahir91 authored Apr 9, 2024
1 parent dbe08c7 commit 6f1cfe4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ Key features:
- It will default to `15m` if not set
- Optionally, you can enable rolling upgrade to deployments in the same namespace as the `GithubApp` that match any of the labels you define in `spec.rolloutDeployment.labels`
- This is useful where pods need to be recreated to pickup the new secret data.
- By default the logs are json formatted and log level is set to info and error, you can set `DEBUG_LOG` to `true` in the manager deployment environment variable for debug level logs.
- The CRD has additional data printed with `kubectl get`:
- APP ID
- INSTALL ID
- EXPIRES AT
- ERROR
- Events are recorded for:
- Any error on reconcile for a GithubApp
- Creation of an access token secret
- Updating an access token secret
- Updating a deployment for rolling upgrade

## Example creating a secret to hold a GitHub App private key
- Get your GithubApp private key and encode to base64
Expand Down
9 changes: 8 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"crypto/tls"
"flag"
"os"
"strconv"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand Down Expand Up @@ -66,8 +67,14 @@ func main() {
"If set the metrics endpoint is served securely")
flag.BoolVar(&enableHTTP2, "enable-http2", false,
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
// Read DEBUG_LOG from env var
debugLog, logVarErr := strconv.ParseBool(os.Getenv("DEBUG_LOG"))
if logVarErr != nil {
// Default to false
debugLog = false
}
opts := zap.Options{
Development: true,
Development: debugLog,
}
opts.BindFlags(flag.CommandLine)
flag.Parse()
Expand Down
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@ spec:
value: "5m"
- name: EXPIRY_THRESHOLD
value: "15m"
- name: DEBUG_LOG
value: false
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
2 changes: 2 additions & 0 deletions internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ var _ = BeforeSuite(func() {
Expect(osEnvErr).NotTo(HaveOccurred())
osEnvErr = os.Setenv("EXPIRY_THRESHOLD", "15m")
Expect(osEnvErr).NotTo(HaveOccurred())
osEnvErr = os.Setenv("DEBUG_LOG", "true")
Expect(osEnvErr).NotTo(HaveOccurred())

var err error
// cfg is defined in this file globally.
Expand Down

0 comments on commit 6f1cfe4

Please sign in to comment.