sketch main: migrating things from /init into cmdline flags
As much as possible, I want NewAgent() to take as many arguments as it
can, and try to avoid doing different things with Init().
You can't quite do everything because the port that Docker has
open for forwarding starts as "0" and we call "docker port" to find it,
but besides that, almost everything is knowable up front.
diff --git a/loop/server/loophttp.go b/loop/server/loophttp.go
index 07127df..3897fb9 100644
--- a/loop/server/loophttp.go
+++ b/loop/server/loophttp.go
@@ -85,10 +85,10 @@
}
type InitRequest struct {
- HostAddr string `json:"host_addr"`
- OutsideHTTP string `json:"outside_http"`
- GitRemoteAddr string `json:"git_remote_addr"`
- Commit string `json:"commit"`
+ // Passed to agent so that the URL it prints in the termui prompt is correct (when skaband is not used)
+ HostAddr string `json:"host_addr"`
+
+ // POST /init will start the SSH server with these configs
SSHAuthorizedKeys []byte `json:"ssh_authorized_keys"`
SSHServerIdentity []byte `json:"ssh_server_identity"`
SSHContainerCAKey []byte `json:"ssh_container_ca_key"`
@@ -215,12 +215,8 @@
}
ini := loop.AgentInit{
- WorkingDir: "/app",
- InDocker: true,
- Commit: m.Commit,
- OutsideHTTP: m.OutsideHTTP,
- GitRemoteAddr: m.GitRemoteAddr,
- HostAddr: m.HostAddr,
+ InDocker: true,
+ HostAddr: m.HostAddr,
}
if err := agent.Init(ini); err != nil {
http.Error(w, "init failed: "+err.Error(), http.StatusInternalServerError)