mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
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.
This commit is contained in:
parent
3957d4a027
commit
ea329aed69
@ -4,9 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/99designs/gqlgen/graphql/playground"
|
"github.com/99designs/gqlgen/graphql/playground"
|
||||||
@ -27,6 +29,7 @@ import (
|
|||||||
const webUIOpenConfigKey = "git-bug.webui.open"
|
const webUIOpenConfigKey = "git-bug.webui.open"
|
||||||
|
|
||||||
type webUIOptions struct {
|
type webUIOptions struct {
|
||||||
|
host string
|
||||||
port int
|
port int
|
||||||
open bool
|
open bool
|
||||||
noOpen bool
|
noOpen bool
|
||||||
@ -54,9 +57,10 @@ Available git config:
|
|||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.SortFlags = false
|
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.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.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")
|
flags.BoolVar(&options.readOnly, "read-only", false, "Whether to run the web UI in read-only mode")
|
||||||
|
|
||||||
return cmd
|
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)
|
webUiAddr := fmt.Sprintf("http://%s", addr)
|
||||||
|
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
|
@ -21,6 +21,10 @@ Available git config:
|
|||||||
|
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
|
.PP
|
||||||
|
\fB\-\-host\fP="127.0.0.1"
|
||||||
|
Network address or hostname to listen to (default to 127.0.0.1)
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-open\fP[=false]
|
\fB\-\-open\fP[=false]
|
||||||
Automatically open the web UI in the default browser
|
Automatically open the web UI in the default browser
|
||||||
@ -31,7 +35,7 @@ Available git config:
|
|||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-p\fP, \fB\-\-port\fP=0
|
\fB\-p\fP, \fB\-\-port\fP=0
|
||||||
Port to listen to (default is random)
|
Port to listen to (default to random available port)
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-read\-only\fP[=false]
|
\fB\-\-read\-only\fP[=false]
|
||||||
|
@ -17,9 +17,10 @@ git-bug webui [flags]
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
|
--host string Network address or hostname to listen to (default to 127.0.0.1) (default "127.0.0.1")
|
||||||
--open Automatically open the web UI in the default browser
|
--open Automatically open the web UI in the default browser
|
||||||
--no-open Prevent the automatic opening of the web UI in the default browser
|
--no-open Prevent the automatic opening of the web UI in the default browser
|
||||||
-p, --port int Port to listen to (default is random)
|
-p, --port int Port to listen to (default to random available port)
|
||||||
--read-only Whether to run the web UI in read-only mode
|
--read-only Whether to run the web UI in read-only mode
|
||||||
-h, --help help for webui
|
-h, --help help for webui
|
||||||
```
|
```
|
||||||
|
1
go.sum
1
go.sum
@ -476,6 +476,7 @@ github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc=
|
|||||||
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||||
github.com/xanzy/go-gitlab v0.40.1 h1:jHueLh5Inzv20TL5Yki+CaLmyvtw3Yq7blbWx7GmglQ=
|
github.com/xanzy/go-gitlab v0.40.1 h1:jHueLh5Inzv20TL5Yki+CaLmyvtw3Yq7blbWx7GmglQ=
|
||||||
github.com/xanzy/go-gitlab v0.40.1/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
|
github.com/xanzy/go-gitlab v0.40.1/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
|
||||||
|
github.com/xanzy/go-gitlab v0.44.0 h1:cEiGhqu7EpFGuei2a2etAwB+x6403E5CvpLn35y+GPs=
|
||||||
github.com/xanzy/go-gitlab v0.44.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
|
github.com/xanzy/go-gitlab v0.44.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
|
||||||
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
|
||||||
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
|
||||||
|
@ -1331,6 +1331,10 @@ _git-bug_webui()
|
|||||||
flags_with_completion=()
|
flags_with_completion=()
|
||||||
flags_completion=()
|
flags_completion=()
|
||||||
|
|
||||||
|
flags+=("--host=")
|
||||||
|
two_word_flags+=("--host")
|
||||||
|
local_nonpersistent_flags+=("--host")
|
||||||
|
local_nonpersistent_flags+=("--host=")
|
||||||
flags+=("--open")
|
flags+=("--open")
|
||||||
local_nonpersistent_flags+=("--open")
|
local_nonpersistent_flags+=("--open")
|
||||||
flags+=("--no-open")
|
flags+=("--no-open")
|
||||||
|
Loading…
Reference in New Issue
Block a user