From c6a1c0dcbfbd27990a515f13bceca05b3e4d3f85 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 12 Mar 2019 21:07:58 -0400 Subject: [PATCH] feat: respect --quiet in config.go When setting environment variables, we should respect a passed `--quiet` flag - and the respective environment variable. This will allow users to have a nicer experience when using the config functions within their own plugins. --- plugins/config/config.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/config/config.go b/plugins/config/config.go index 5f46992dd..23a74943a 100644 --- a/plugins/config/config.go +++ b/plugins/config/config.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "os" "regexp" "github.com/dokku/dokku/plugins/common" @@ -46,8 +47,10 @@ func SetMany(appName string, entries map[string]string, restart bool) (err error keys = append(keys, k) } if len(entries) != 0 { - common.LogInfo1("Setting config vars") - fmt.Println(prettyPrintEnvEntries(" ", entries)) + common.LogInfo1Quiet("Setting config vars") + if os.Getenv("DOKKU_QUIET_OUTPUT") == "" { + fmt.Println(prettyPrintEnvEntries(" ", entries)) + } env.Write() triggerUpdate(appName, "set", keys) } @@ -72,11 +75,11 @@ func UnsetMany(appName string, keys []string, restart bool) (err error) { } for _, k := range keys { if _, hasKey := env.Map()[k]; hasKey { - common.LogInfo1(fmt.Sprintf("Unsetting %s", k)) + common.LogInfo1Quiet(fmt.Sprintf("Unsetting %s", k)) env.Unset(k) changed = true } else { - common.LogInfo1(fmt.Sprintf("Skipping %s, it is not set in the environment", k)) + common.LogInfo1Quiet(fmt.Sprintf("Skipping %s, it is not set in the environment", k)) } } if changed {