command-line argument parsing with error handling for all commands that are referred to on the docs page.
This commit is contained in:
parent
815f1fa927
commit
5c0e3401f4
@ -21,4 +21,4 @@ COPY --from=builder /opt/converge/bin/agent \
|
|||||||
/opt/converge/docs/
|
/opt/converge/docs/
|
||||||
COPY --from=builder /opt/converge/static/ /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/iowrappers"
|
||||||
"converge/pkg/terminal"
|
"converge/pkg/terminal"
|
||||||
"converge/pkg/websocketutil"
|
"converge/pkg/websocketutil"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gliderlabs/ssh"
|
"github.com/gliderlabs/ssh"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
@ -133,12 +134,29 @@ func (f ReaderFunc) Read(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
wsURL := os.Args[1]
|
|
||||||
|
|
||||||
advanceWarningTime := 5 * time.Minute
|
usage := "agent [options] <wsUrl> \n" +
|
||||||
agentExpriryTime := 10 * time.Minute
|
"\n" +
|
||||||
tickerInterval := 60 * time.Second
|
"Run agent with <wsUrl> of the form ws[s]://<host>[:port]/agent/<ID>\n" +
|
||||||
agent.ConfigureAgent(advanceWarningTime, agentExpriryTime, tickerInterval)
|
"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)
|
conn, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,7 +27,7 @@ func catchAllHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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")
|
"directory where documentation is located, either relative to current directory or an absolute path")
|
||||||
|
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"converge/pkg/iowrappers"
|
"converge/pkg/iowrappers"
|
||||||
"converge/pkg/websocketutil"
|
"converge/pkg/websocketutil"
|
||||||
|
"fmt"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -35,6 +36,12 @@ func handleConnection(conn net.Conn, wsURL string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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]
|
tcpPort := os.Args[1]
|
||||||
wsURL := os.Args[2]
|
wsURL := os.Args[2]
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"converge/pkg/iowrappers"
|
"converge/pkg/iowrappers"
|
||||||
"converge/pkg/websocketutil"
|
"converge/pkg/websocketutil"
|
||||||
|
"fmt"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -27,9 +28,26 @@ func (stdio Stdio) Write(b []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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]
|
wsURL := os.Args[1]
|
||||||
|
|
||||||
_wsConn, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
|
_wsConn, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
_wsConn.SetReadDeadline(time.Time{})
|
_wsConn.SetReadDeadline(time.Time{})
|
||||||
_wsConn.SetWriteDeadline(time.Time{})
|
_wsConn.SetWriteDeadline(time.Time{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user