(params: DockerResolverParameters, containerId: string, remoteWorkspaceFolder: string | undefined, remoteUser: string | undefined, rootShellServer?: ShellServer)
| 493 | } |
| 494 | |
| 495 | export async function createContainerProperties(params: DockerResolverParameters, containerId: string, remoteWorkspaceFolder: string | undefined, remoteUser: string | undefined, rootShellServer?: ShellServer) { |
| 496 | const { common } = params; |
| 497 | const inspecting = 'Inspecting container'; |
| 498 | const start = common.output.start(inspecting); |
| 499 | const containerInfo = await inspectContainer(params, containerId); |
| 500 | common.output.stop(inspecting, start); |
| 501 | const containerUser = remoteUser || containerInfo.Config.User || 'root'; |
| 502 | const [, user, , group] = /([^:]*)(:(.*))?/.exec(containerUser) as (string | undefined)[]; |
| 503 | const containerEnv = envListToObj(containerInfo.Config.Env); |
| 504 | const remoteExec = dockerExecFunction(params, containerId, containerUser); |
| 505 | const remotePtyExec = await dockerPtyExecFunction(params, containerId, containerUser, common.loadNativeModule, common.allowInheritTTY); |
| 506 | const remoteExecAsRoot = dockerExecFunction(params, containerId, 'root'); |
| 507 | return getContainerProperties({ |
| 508 | params: common, |
| 509 | createdAt: containerInfo.Created, |
| 510 | startedAt: containerInfo.State.StartedAt, |
| 511 | remoteWorkspaceFolder, |
| 512 | containerUser: user === '0' ? 'root' : user, |
| 513 | containerGroup: group, |
| 514 | containerEnv, |
| 515 | remoteExec, |
| 516 | remotePtyExec, |
| 517 | remoteExecAsRoot, |
| 518 | rootShellServer, |
| 519 | }); |
| 520 | } |
| 521 | |
| 522 | export function envListToObj(list: string[] | null | undefined) { |
| 523 | // Handle Env is null (https://github.com/microsoft/vscode-remote-release/issues/2058). |
no test coverage detected