feat: add network:report command

This commit is contained in:
Jose Diaz-Gonzalez
2017-10-04 00:48:02 -04:00
parent fdbab2c291
commit ad732bd42b
8 changed files with 141 additions and 17 deletions

View File

@@ -4,10 +4,9 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/network"
)
// returns the listeners (host:port combinations) for a given app container
@@ -15,18 +14,6 @@ func main() {
flag.Parse()
appName := flag.Arg(0)
dokkuRoot := common.MustGetEnv("DOKKU_ROOT")
appRoot := strings.Join([]string{dokkuRoot, appName}, "/")
files, _ := filepath.Glob(appRoot + "/IP.web.*")
var listeners []string
for _, ipfile := range files {
portfile := strings.Replace(ipfile, "/IP.web.", "/PORT.web.", 1)
ipAddress := common.ReadFirstLine(ipfile)
port := common.ReadFirstLine(portfile)
listeners = append(listeners, fmt.Sprintf("%s:%s", ipAddress, port))
}
listeners := network.GetListeners(appName)
fmt.Fprint(os.Stdout, strings.Join(listeners, " "))
}