Skip to content

Commit 8a8b6ba

Browse files
committed
Tune the verbosity as per pre 0.12.0
This retains the verbose print of configuration at start-up, but puts it behind a flag. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 65f70cb commit 8a8b6ba

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ import (
3838
func main() {
3939
var kubeconfig string
4040
var masterURL string
41-
var operator bool
41+
var (
42+
operator,
43+
verbose bool
44+
)
4245

4346
flag.StringVar(&kubeconfig, "kubeconfig", "",
4447
"Path to a kubeconfig. Only required if out-of-cluster.")
48+
flag.BoolVar(&verbose, "verbose", false, "Print verbose config information")
4549
flag.StringVar(&masterURL, "master", "",
4650
"The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
4751

@@ -74,7 +78,7 @@ func main() {
7478
log.Fatalf("Error reading config: %s", err.Error())
7579
}
7680

77-
config.Fprint()
81+
config.Fprint(verbose)
7882

7983
deployConfig := k8s.DeploymentConfig{
8084
RuntimeHTTPPort: 8080,

types/read_config.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,26 @@ type BootstrapConfig struct {
106106
FaaSConfig ftypes.FaaSConfig
107107
}
108108

109-
// Fprint pretty-prints the config with the std logger. One line per config value.
110-
func (c BootstrapConfig) Fprint() {
109+
// Fprint pretty-prints the config with the stdlib logger. One line per config value.
110+
// When the verbose flag is set to false, it prints the same output as prior to
111+
// the 0.12.0 release.
112+
func (c BootstrapConfig) Fprint(verbose bool) {
111113
log.Printf("HTTP Read Timeout: %s\n", c.FaaSConfig.GetReadTimeout())
112114
log.Printf("HTTP Write Timeout: %s\n", c.FaaSConfig.WriteTimeout)
113-
log.Printf("MaxIdleConns: %d\n", c.FaaSConfig.MaxIdleConns)
114-
log.Printf("MaxIdleConnsPerHost: %d\n", c.FaaSConfig.MaxIdleConnsPerHost)
115-
log.Printf("HTTPProbe: %v\n", c.HTTPProbe)
116-
log.Printf("DefaultFunctionNamespace: %s\n", c.DefaultFunctionNamespace)
117-
log.Printf("ProfilesNamespace: %s\n", c.ProfilesNamespace)
118115
log.Printf("ImagePullPolicy: %s\n", c.ImagePullPolicy)
119-
log.Printf("SetNonRootUser: %v\n", c.SetNonRootUser)
120-
log.Printf("ReadinessProbeInitialDelaySeconds: %d\n", c.ReadinessProbeInitialDelaySeconds)
121-
log.Printf("ReadinessProbeTimeoutSeconds: %d\n", c.ReadinessProbeTimeoutSeconds)
122-
log.Printf("ReadinessProbePeriodSeconds: %d\n", c.ReadinessProbePeriodSeconds)
123-
log.Printf("LivenessProbeInitialDelaySeconds: %d\n", c.LivenessProbeInitialDelaySeconds)
124-
log.Printf("LivenessProbeTimeoutSeconds: %d\n", c.LivenessProbeTimeoutSeconds)
125-
log.Printf("LivenessProbePeriodSeconds: %d\n", c.LivenessProbePeriodSeconds)
116+
log.Printf("DefaultFunctionNamespace: %s\n", c.DefaultFunctionNamespace)
117+
118+
if verbose {
119+
log.Printf("MaxIdleConns: %d\n", c.FaaSConfig.MaxIdleConns)
120+
log.Printf("MaxIdleConnsPerHost: %d\n", c.FaaSConfig.MaxIdleConnsPerHost)
121+
log.Printf("HTTPProbe: %v\n", c.HTTPProbe)
122+
log.Printf("ProfilesNamespace: %s\n", c.ProfilesNamespace)
123+
log.Printf("SetNonRootUser: %v\n", c.SetNonRootUser)
124+
log.Printf("ReadinessProbeInitialDelaySeconds: %d\n", c.ReadinessProbeInitialDelaySeconds)
125+
log.Printf("ReadinessProbeTimeoutSeconds: %d\n", c.ReadinessProbeTimeoutSeconds)
126+
log.Printf("ReadinessProbePeriodSeconds: %d\n", c.ReadinessProbePeriodSeconds)
127+
log.Printf("LivenessProbeInitialDelaySeconds: %d\n", c.LivenessProbeInitialDelaySeconds)
128+
log.Printf("LivenessProbeTimeoutSeconds: %d\n", c.LivenessProbeTimeoutSeconds)
129+
log.Printf("LivenessProbePeriodSeconds: %d\n", c.LivenessProbePeriodSeconds)
130+
}
126131
}

0 commit comments

Comments
 (0)