Files
dokku/plugins/network/src/commands/commands.go
T
Jose Diaz-Gonzalez ac4b86fd8e feat: expose whether a network was created by dokku
`network:list` and `network:info` now expose a `DokkuManaged` boolean derived from the `com.dokku.network-name` label that `network:create` applies, and `network:list` gains a `--dokku-managed` flag to restrict output to dokku-created networks. This lets tooling distinguish networks dokku created from Docker built-ins and networks created by other tooling such as compose.
2026-07-08 00:03:29 -04:00

63 lines
1.7 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
)
const (
helpHeader = `Usage: dokku network[:COMMAND]
Manage network settings for an app
Additional commands:`
helpContent = `
network:create <network>, Creates an attachable docker network
network:destroy <network>, Destroys a docker network
network:exists <network>, Checks if a docker network exists
network:info <network> [--format text|json], Outputs information about a docker network
network:list [--format text|json] [--dokku-managed], Lists all docker networks
network:rebuild <app>, Rebuilds network settings for an app
network:rebuildall, Rebuild network settings for all apps
network:report [<app>] [<flag>], Displays a network report for one or more apps
network:set <app> <property> (<value>...), Set or clear a network property for an app`
)
func main() {
flag.Usage = usage
flag.Parse()
cmd := flag.Arg(0)
switch cmd {
case "network", "network:help":
usage()
case "help":
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: "ps",
Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())},
})
if err == nil && strings.Contains(result.StdoutContents(), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n network, Manage network settings for an app\n")
}
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {
fmt.Println("failed to retrieve DOKKU_NOT_IMPLEMENTED_EXIT environment variable")
dokkuNotImplementExitCode = 10
}
os.Exit(dokkuNotImplementExitCode)
}
}
func usage() {
common.CommandUsage(helpHeader, helpContent)
}