Skip to content

Commit f168841

Browse files
authored
feat(api)!: show host endpoint (#85)
`http://d/default/info` returns: ```json { "podmanSocketPath": "/Users/danhexon/vm_test/socks/libkrun/bugbox-machine-default-podman-api.sock", "sshPort": 61234, "sshUser": "root", "hostEndpoint": "host.containers.internal" } ``` BREAKING CHANGE: the `http://d/default/info` returned json array content is incompatible with the previous json content
1 parent 0ca13e0 commit f168841

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pkg/api/backend/info.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ import (
1212
"bauklotze/pkg/api/utils"
1313
)
1414

15+
type Resp struct {
16+
PodmanSocketPath string `json:"podmanSocketPath"`
17+
SSHPort int `json:"sshPort"`
18+
SSHUser string `json:"sshUser"`
19+
HostEndpoint string `json:"hostEndpoint"`
20+
}
21+
1522
// GetInfos Get machine configures
1623
func GetInfos(w http.ResponseWriter, r *http.Request) {
1724
mc := r.Context().Value(types.McKey).(*vmconfig.MachineConfig)
1825
if mc == nil {
1926
utils.Error(w, http.StatusInternalServerError, ErrMachineConfigNull)
2027
return
2128
}
22-
utils.WriteResponse(w, http.StatusOK, mc)
29+
30+
utils.WriteResponse(w, http.StatusOK, &Resp{
31+
PodmanSocketPath: mc.GvProxy.HostSocks[0],
32+
SSHPort: mc.SSH.Port,
33+
SSHUser: mc.SSH.RemoteUsername,
34+
HostEndpoint: "host.containers.internal",
35+
})
2336
}

0 commit comments

Comments
 (0)