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

Function getRemoteWorkspaceContainerId

cli/cmd/start/vm.go:422–436  ·  view source on GitHub ↗

获取容器id

(sshRemote common.SSHRemote, workspaceInfo workspace.WorkspaceInfo, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

420
421// 获取容器id
422func getRemoteWorkspaceContainerId(sshRemote common.SSHRemote, workspaceInfo workspace.WorkspaceInfo, cmd *cobra.Command) string {
423 dcc, err := GetRemoteContainersWithServices(sshRemote,
424 workspaceInfo.WorkingDirectoryPath, []string{workspaceInfo.ConfigYaml.Workspace.DevContainer.ServiceName})
425 if err != nil {
426 common.SmartIDELog.ImportanceWithError(err)
427 }
428 if len(dcc) == 0 {
429 common.SmartIDELog.Error("没有查找到运行的容器!")
430 }
431 containerId, err := sshRemote.ExeSSHCommand(fmt.Sprintf("docker ps -f 'name=%s' -q", dcc[len(dcc)-1].ContainerName))
432 if err != nil {
433 common.SmartIDELog.Warning(err.Error())
434 }
435 return containerId
436}
437
438// 缓存git 用户名、密码
439func remoteContainerCredentialCache(sshRemote common.SSHRemote, containerId string, workspaceInfo workspace.WorkspaceInfo) {

Callers 1

ExecuteVmStartCmdFunction · 0.85

Calls 5

ImportanceWithErrorMethod · 0.80
ExeSSHCommandMethod · 0.80
WarningMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected