feat: silence env var setting
This commit is contained in:
1 parent
25a49624c7
commit
5719f43551
2 files changed
+31
-7
No files matched your search
@@ -74,6 +74,29 @@ func CommandUsage(helpHeader string, helpContent string) {
|
|||||||
fmt.Println(columnize.Format(content, config))
|
fmt.Println(columnize.Format(content, config))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnvWrap wraps a func with a setenv call and resets the value at the end
|
||||||
|
func EnvWrap(fn func() error, environ map[string]string) error {
|
||||||
|
var oldEnviron map[string]string
|
||||||
|
for key, value := range environ {
|
||||||
|
oldEnviron[key] = os.Getenv(key)
|
||||||
|
if err := os.Setenv(key, value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := fn(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value := range oldEnviron {
|
||||||
|
if err := os.Setenv(key, value); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetAppScheduler fetches the scheduler for a given application
|
// GetAppScheduler fetches the scheduler for a given application
|
||||||
func GetAppScheduler(appName string) string {
|
func GetAppScheduler(appName string) string {
|
||||||
appScheduler := ""
|
appScheduler := ""
|
||||||
@@ -308,7 +331,10 @@ func IsDeployed(appName string) bool {
|
|||||||
deployed = "true"
|
deployed = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandPropertySet("common", appName, "deployed", deployed, DefaultProperties, GlobalProperties)
|
EnvWrap(func() error {
|
||||||
|
CommandPropertySet("common", appName, "deployed", deployed, DefaultProperties, GlobalProperties)
|
||||||
|
return nil
|
||||||
|
}, map[string]string{"DOKKU_QUIET_OUTPUT": "1"})
|
||||||
}
|
}
|
||||||
|
|
||||||
return deployed == "true"
|
return deployed == "true"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TriggerAppList outputs each app name to stdout on a newline
|
// TriggerAppList outputs each app name to stdout on a newline
|
||||||
@@ -23,11 +22,10 @@ func TriggerAppList(filtered bool) error {
|
|||||||
|
|
||||||
// TriggerCorePostDeploy associates the container with a specified network
|
// TriggerCorePostDeploy associates the container with a specified network
|
||||||
func TriggerCorePostDeploy(appName string) error {
|
func TriggerCorePostDeploy(appName string) error {
|
||||||
quiet := os.Getenv("DOKKU_QUIET_OUTPUT")
|
return EnvWrap(func() error {
|
||||||
os.Setenv("DOKKU_QUIET_OUTPUT", "1")
|
CommandPropertySet("common", appName, "deployed", "true", DefaultProperties, GlobalProperties)
|
||||||
CommandPropertySet("common", appName, "deployed", "true", DefaultProperties, GlobalProperties)
|
return nil
|
||||||
os.Setenv("DOKKU_QUIET_OUTPUT", quiet)
|
}, map[string]string{"DOKKU_QUIET_OUTPUT": "1"})
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TriggerInstall runs the install step for the common plugin
|
// TriggerInstall runs the install step for the common plugin
|
||||||
|
|||||||
Reference in new issue
Block a user