feat: add report trigger

This allows users to quickly show the state of any configured application, as well as the state of their server. In doing so, we make it easy for them to provide information necessary for debugging in a single command.
This commit is contained in:
Jose Diaz-Gonzalez
2018-04-07 04:49:21 -04:00
parent a21761d48d
commit 4aac1fd936
34 changed files with 924 additions and 815 deletions

View File

@@ -2,45 +2,12 @@ package main
import (
"flag"
"fmt"
"os"
"reflect"
"strings"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/network"
)
func reportSingleApp(appName, infoFlag string) {
infoFlags := map[string]string{
"--network-bind-all-interfaces": common.PropertyGet("network", appName, "bind-all-interfaces"),
"--network-listeners": strings.Join(network.GetListeners(appName), " "),
}
if len(infoFlag) == 0 {
common.LogInfo2Quiet(fmt.Sprintf("%s network information", appName))
for k, v := range infoFlags {
key := common.UcFirst(strings.Replace(strings.TrimPrefix(k, "--"), "-", " ", -1))
common.LogVerbose(fmt.Sprintf("%s: %s", key, v))
}
return
}
for k, v := range infoFlags {
if infoFlag == k {
fmt.Fprintln(os.Stdout, v)
return
}
}
keys := reflect.ValueOf(infoFlags).MapKeys()
strkeys := make([]string, len(keys))
for i := 0; i < len(keys); i++ {
strkeys[i] = keys[i].String()
}
common.LogFail(fmt.Sprintf("Invalid flag passed, valid flags: %s", strings.Join(strkeys, ", ")))
}
// displays a network report for one or more apps
func main() {
flag.Parse()
@@ -58,10 +25,10 @@ func main() {
return
}
for _, appName := range apps {
reportSingleApp(appName, infoFlag)
network.ReportSingleApp(appName, infoFlag)
}
return
}
reportSingleApp(appName, infoFlag)
network.ReportSingleApp(appName, infoFlag)
}

View File

@@ -0,0 +1,15 @@
package main
import (
"flag"
"github.com/dokku/dokku/plugins/network"
)
// displays a network report for one or more apps
func main() {
flag.Parse()
appName := flag.Arg(0)
network.ReportSingleApp(appName, "")
}