command-line argument parsing with error handling for all commands that are referred to on the docs page.
This commit is contained in:
parent
bc12d13c16
commit
0b57a31eaa
@ -21,4 +21,4 @@ COPY --from=builder /opt/converge/bin/agent \
|
||||
/opt/converge/docs/
|
||||
COPY --from=builder /opt/converge/static/ /opt/converge/docs/
|
||||
|
||||
ENTRYPOINT ["/opt/converge/bin/converge", "-docsdir", "/opt/converge/docs" ]
|
||||
ENTRYPOINT ["/opt/converge/bin/converge", "-d", "/opt/converge/docs" ]
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"converge/pkg/iowrappers"
|
||||
"converge/pkg/terminal"
|
||||
"converge/pkg/websocketutil"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/gorilla/websocket"
|
||||
@ -133,12 +134,29 @@ func (f ReaderFunc) Read(p []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
wsURL := os.Args[1]
|
||||
|
||||
advanceWarningTime := 5 * time.Minute
|
||||
agentExpriryTime := 10 * time.Minute
|
||||
tickerInterval := 60 * time.Second
|
||||
agent.ConfigureAgent(advanceWarningTime, agentExpriryTime, tickerInterval)
|
||||
usage := "agent [options] <wsUrl> \n" +
|
||||
"\n" +
|
||||
"Run agent with <wsUrl> of the form ws[s]://<host>[:port]/agent/<ID>\n" +
|
||||
"Here <ID> is the unique id of the agent that allows rendez-vous with an end-user.\n" +
|
||||
"The end-user must specify the same id when connecting using ssh.\n"
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, usage+"\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
advanceWarningTime := flag.Duration("warning-time", 5*time.Minute, "advance warning time before sessio ends")
|
||||
agentExpriryTime := flag.Duration("expiry-time", 10*time.Minute, "expiry time of the session")
|
||||
tickerInterval := flag.Duration("check-interval", 60*time.Second, "interval at which expiry is checked")
|
||||
|
||||
flag.Parse()
|
||||
if flag.NArg() != 1 {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
wsURL := flag.Arg(0)
|
||||
|
||||
agent.ConfigureAgent(*advanceWarningTime, *agentExpriryTime, *tickerInterval)
|
||||
|
||||
conn, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
|
||||
if err != nil {
|
||||
|
@ -27,7 +27,7 @@ func catchAllHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
downloadOption := flag.String("docsdir", "downloads",
|
||||
downloadOption := flag.String("d", "downloads",
|
||||
"directory where documentation is located, either relative to current directory or an absolute path")
|
||||
|
||||
flag.Usage = func() {
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"converge/pkg/iowrappers"
|
||||
"converge/pkg/websocketutil"
|
||||
"fmt"
|
||||
"github.com/gorilla/websocket"
|
||||
"log"
|
||||
"net"
|
||||
@ -35,6 +36,12 @@ func handleConnection(conn net.Conn, wsURL string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 3 {
|
||||
fmt.Fprintln(os.Stderr, "Usage: tcptows <localport> ws[s]://<host>[:port]/client/<ID>")
|
||||
fmt.Fprintln(os.Stderr)
|
||||
fmt.Fprintln(os.Stderr, "Here <ID> is the rendez-vous id of a continuous integratio job")
|
||||
os.Exit(1)
|
||||
}
|
||||
tcpPort := os.Args[1]
|
||||
wsURL := os.Args[2]
|
||||
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"converge/pkg/iowrappers"
|
||||
"converge/pkg/websocketutil"
|
||||
"fmt"
|
||||
"github.com/gorilla/websocket"
|
||||
"log"
|
||||
"net"
|
||||
@ -27,9 +28,26 @@ func (stdio Stdio) Write(b []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Fprintln(os.Stderr, "Usage: tcptows ws[s]://<host>[:port]/client/<ID>")
|
||||
fmt.Fprintln(os.Stderr)
|
||||
fmt.Fprintln(os.Stderr, "Here <ID> is the rendez-vous id of a continuous integratio job")
|
||||
fmt.Fprintln(os.Stderr, "Use this in an ssh command like this; ")
|
||||
fmt.Fprintln(os.Stderr)
|
||||
fmt.Fprintln(os.Stderr, " ssh -oProxyCommand='wsproxy ws[s]://<host>[:port]/client/<ID>' abc@localhost")
|
||||
fmt.Fprintln(os.Stderr)
|
||||
fmt.Fprintln(os.Stderr, "This lets ssh connect through wsproxy to the remote websocket on")
|
||||
fmt.Fprintln(os.Stderr, "Converge server.")
|
||||
fmt.Fprintln(os.Stderr)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wsURL := os.Args[1]
|
||||
|
||||
_wsConn, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_wsConn.SetReadDeadline(time.Time{})
|
||||
_wsConn.SetWriteDeadline(time.Time{})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user