mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-03 00:23:27 +02:00
Increase log verbosity, namely for object updates.
- add a new environment variable for triggering debug log level - show both new, old object and diff during syncs and updates - use pretty package to pretty-print go structures -
This commit is contained in:
committed by
Murat Kabilov
parent
8c2a44a242
commit
3a4c6268be
@@ -38,6 +38,7 @@ type Config struct {
|
||||
DockerImage string `split_words:"true",default:"registry.opensource.zalan.do/acid/spilo-9.6:1.2-p12"`
|
||||
ServiceAccountName string `split_words:"true",default:"operator"`
|
||||
DbHostedZone string `split_words:"true",default:"db.example.com"`
|
||||
DebugLogging bool `split_words:"true",default:"false"`
|
||||
}
|
||||
|
||||
func LoadFromEnv() *Config {
|
||||
|
||||
@@ -3,10 +3,13 @@ package util
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/kr/pretty"
|
||||
|
||||
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/types"
|
||||
@@ -60,3 +63,18 @@ func PGUserPassword(user spec.PgUser) string {
|
||||
|
||||
return "md5" + hex.EncodeToString(s[:])
|
||||
}
|
||||
|
||||
func Pretty(x interface {}) (f fmt.Formatter) {
|
||||
return pretty.Formatter(x)
|
||||
}
|
||||
|
||||
func PrettyDiff(a, b interface{}) (result string) {
|
||||
diff := pretty.Diff(a, b)
|
||||
json, err := json.MarshalIndent(diff, "", " ")
|
||||
if err != nil {
|
||||
result = fmt.Sprintf("%v", diff)
|
||||
} else {
|
||||
result = string(json)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user