MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / GetRemoteContainersWithServices

Function GetRemoteContainersWithServices

cli/cmd/start/env.go:71–93  ·  view source on GitHub ↗

检测远程服务器的环境,是否安装docker、docker-compose、git

(sshRemote common.SSHRemote,
	workingDir string, dockerComposeServices []string)

Source from the content-addressed store, hash-verified

69
70// 检测远程服务器的环境,是否安装docker、docker-compose、git
71func GetRemoteContainersWithServices(sshRemote common.SSHRemote,
72 workingDir string, dockerComposeServices []string) (dockerComposeContainers []DockerComposeContainer, err error) {
73
74 // https://docs.docker.com/engine/api/v1.41/#operation/ContainerList
75 command := "sudo curl -s --unix-socket /var/run/docker.sock http://dummy/containers/json "
76 output, err := sshRemote.ExeSSHCommand(command)
77 common.CheckError(err)
78
79 if len(output) >= 0 { // 有返回结果的时候才需要转换
80 var originContainers []types.Container
81 err = json.Unmarshal([]byte(output), &originContainers)
82
83 // home dir
84 if workingDir[0:1] == "~" {
85 homeDir, _ := sshRemote.GetRemoteHome()
86 workingDir = common.FilePahtJoin4Linux(homeDir, workingDir[1:])
87 }
88
89 dockerComposeContainers = convertOriginContainer(originContainers, workingDir, dockerComposeServices)
90 }
91
92 return dockerComposeContainers, err
93}
94
95// 转换结构体
96func convertOriginContainer(containers []types.Container,

Callers 3

ExecuteVmStartCmdFunction · 0.85

Calls 3

convertOriginContainerFunction · 0.85
ExeSSHCommandMethod · 0.80
GetRemoteHomeMethod · 0.80

Tested by

no test coverage detected