Skip to content

Commit

Permalink
Merge pull request #48 from bpineau/flatlogs
Browse files Browse the repository at this point in the history
Flat values for log config
  • Loading branch information
bpineau authored Apr 25, 2018
2 parents 10f459e + 7046727 commit fe136d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ in uppercase, prefixed by "KF", and with underscore instead of dashs. ie.:
```
export KF_GIT_URL=https://user:token@github.com/myorg/myrepos.git
export KF_LOCAL_DIR=/tmp/kfdump
export KF_LOG_LEVEL=info
# exception, for kubectl compatibility:
export KUBECONFIG=/tmp/kconfig
Expand Down
7 changes: 3 additions & 4 deletions assets/katafygio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#api-server: http://127.0.0.1:8080
#kube-config: /etc/kubernetes/config

log:
level: "info"
output: "stderr"
#server: "localhost:514" # mandatory if log-output: "syslog"
log-level: "info"
log-output: "stderr"
#log-server: "localhost:514" # mandatory if log-output: "syslog"

# Where to save the yaml dumps
local-dir: /var/cache/katafygio
Expand Down
4 changes: 2 additions & 2 deletions cmd/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func loadConfigFile() {
viper.SetEnvKeyReplacer(replacer)
viper.AutomaticEnv()

if err := viper.ReadInConfig(); err == nil {
RootCmd.Printf("Using config file: %s", viper.ConfigFileUsed())
if err := viper.ReadInConfig(); err != nil {
RootCmd.Printf("Can't read config file: %v\n", err)
}
}
12 changes: 6 additions & 6 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func init() {
bindPFlag("dump-only", "dump-only")

RootCmd.PersistentFlags().StringVarP(&logLevel, "log-level", "v", "info", "Log level")
bindPFlag("log.level", "log-level")
bindPFlag("log-level", "log-level")

RootCmd.PersistentFlags().StringVarP(&logOutput, "log-output", "o", "stderr", "Log output")
bindPFlag("log.output", "log-output")
bindPFlag("log-output", "log-output")

RootCmd.PersistentFlags().StringVarP(&logServer, "log-server", "r", "", "Log server (if using syslog)")
bindPFlag("log.server", "log-server")
bindPFlag("log-server", "log-server")

RootCmd.PersistentFlags().StringVarP(&localDir, "local-dir", "e", "./kubernetes-backup", "Where to dump yaml files")
bindPFlag("local-dir", "local-dir")
Expand Down Expand Up @@ -90,9 +90,9 @@ func bindConf(cmd *cobra.Command, args []string) {
kubeConf = viper.GetString("kube-config")
dryRun = viper.GetBool("dry-run")
dumpMode = viper.GetBool("dump-only")
logLevel = viper.GetString("log.level")
logOutput = viper.GetString("log.output")
logServer = viper.GetString("log.server")
logLevel = viper.GetString("log-level")
logOutput = viper.GetString("log-output")
logServer = viper.GetString("log-server")
filter = viper.GetString("filter")
localDir = viper.GetString("local-dir")
gitURL = viper.GetString("git-url")
Expand Down

0 comments on commit fe136d3

Please sign in to comment.