Merge pull request #6210 from adamreese/ref/debug

ref(cmd/helm): unify log functions
pull/6207/head
Adam Reese 6 years ago committed by GitHub
commit 29d6853659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -53,7 +53,7 @@ func init() {
log.SetFlags(log.Lshortfile) log.SetFlags(log.Lshortfile)
} }
func logf(format string, v ...interface{}) { func debug(format string, v ...interface{}) {
if settings.Debug { if settings.Debug {
format = fmt.Sprintf("[debug] %s\n", format) format = fmt.Sprintf("[debug] %s\n", format)
log.Output(2, fmt.Sprintf(format, v...)) log.Output(2, fmt.Sprintf(format, v...))
@ -78,14 +78,14 @@ func main() {
initActionConfig(actionConfig, false) initActionConfig(actionConfig, false)
if err := cmd.Execute(); err != nil { if err := cmd.Execute(); err != nil {
logf("%+v", err) debug("%+v", err)
os.Exit(1) os.Exit(1)
} }
} }
func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) { func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) {
kc := kube.New(kubeConfig()) kc := kube.New(kubeConfig())
kc.Log = logf kc.Log = debug
clientset, err := kc.Factory.KubernetesClientSet() clientset, err := kc.Factory.KubernetesClientSet()
if err != nil { if err != nil {
@ -101,11 +101,11 @@ func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) {
switch os.Getenv("HELM_DRIVER") { switch os.Getenv("HELM_DRIVER") {
case "secret", "secrets", "": case "secret", "secrets", "":
d := driver.NewSecrets(clientset.CoreV1().Secrets(namespace)) d := driver.NewSecrets(clientset.CoreV1().Secrets(namespace))
d.Log = logf d.Log = debug
store = storage.Init(d) store = storage.Init(d)
case "configmap", "configmaps": case "configmap", "configmaps":
d := driver.NewConfigMaps(clientset.CoreV1().ConfigMaps(namespace)) d := driver.NewConfigMaps(clientset.CoreV1().ConfigMaps(namespace))
d.Log = logf d.Log = debug
store = storage.Init(d) store = storage.Init(d)
case "memory": case "memory":
d := driver.NewMemory() d := driver.NewMemory()
@ -118,7 +118,7 @@ func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) {
actionConfig.RESTClientGetter = kubeConfig() actionConfig.RESTClientGetter = kubeConfig()
actionConfig.KubeClient = kc actionConfig.KubeClient = kc
actionConfig.Releases = store actionConfig.Releases = store
actionConfig.Log = logf actionConfig.Log = debug
} }
func kubeConfig() genericclioptions.RESTClientGetter { func kubeConfig() genericclioptions.RESTClientGetter {

@ -79,7 +79,3 @@ func tpl(t string, vals map[string]interface{}, out io.Writer) error {
} }
return tt.Execute(out, vals) return tt.Execute(out, vals)
} }
func debug(format string, args ...interface{}) {
logf(format, args...)
}

Loading…
Cancel
Save