diff options
author | Sascha <GlancingMind@outlook.com> | 2021-02-28 16:27:14 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-02-28 21:20:15 +0100 |
commit | ea329aed6909cac85680dbae37f6f4dcca134f8b (patch) | |
tree | 7183be55a5bc65cafa75f1a16f24cad84d8ad9fb /commands | |
parent | 3957d4a027b034f9b9a78b160691992b9f4de291 (diff) | |
download | git-bug-ea329aed6909cac85680dbae37f6f4dcca134f8b.tar.gz |
Add option to specify host address
'--host'-cmdline-option is added to the webui command.
Previously, the WebUI couldn't be hosted inside of a container. As the
WebUI-server only listend per default to localhost and there was no
option to change the address, the server should listend to. This means,
that the WebUI was only reachable from localhost. So only from inside of
the container but never from outside.
The '--host'-option allows to set the IP address or a hostname
which the WebUI-server should listen to. E.g. by setting 0.0.0.0 or ::
as address.
Update documentation for new option.
Update shell completion for new option.
Compilation seems to add another go-gitlab version.
Diffstat (limited to 'commands')
-rw-r--r-- | commands/webui.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/commands/webui.go b/commands/webui.go index 7e5fc752..d910a703 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -4,9 +4,11 @@ import ( "context" "fmt" "log" + "net" "net/http" "os" "os/signal" + "strconv" "time" "github.com/99designs/gqlgen/graphql/playground" @@ -27,6 +29,7 @@ import ( const webUIOpenConfigKey = "git-bug.webui.open" type webUIOptions struct { + host string port int open bool noOpen bool @@ -54,9 +57,10 @@ Available git config: flags := cmd.Flags() flags.SortFlags = false + flags.StringVar(&options.host, "host", "127.0.0.1", "Network address or hostname to listen to (default to 127.0.0.1)") flags.BoolVar(&options.open, "open", false, "Automatically open the web UI in the default browser") flags.BoolVar(&options.noOpen, "no-open", false, "Prevent the automatic opening of the web UI in the default browser") - flags.IntVarP(&options.port, "port", "p", 0, "Port to listen to (default is random)") + flags.IntVarP(&options.port, "port", "p", 0, "Port to listen to (default to random available port)") flags.BoolVar(&options.readOnly, "read-only", false, "Whether to run the web UI in read-only mode") return cmd @@ -71,7 +75,7 @@ func runWebUI(env *Env, opts webUIOptions, args []string) error { } } - addr := fmt.Sprintf("127.0.0.1:%d", opts.port) + addr := net.JoinHostPort(opts.host, strconv.Itoa(opts.port)) webUiAddr := fmt.Sprintf("http://%s", addr) router := mux.NewRouter() |